3

By default reftex-mode recognizes LaTeX-like citations, which have a format like \cite{Smith15}. (Locating the cursor above a reference shows a description of it in the mini-buffer and pressing C-& opens the bibliography file in the right spot).

I would like reftex-mode to also recognize my Pandoc-like citations, which have a format like @Smith15 (regexp:"@[A-Z][A-Za-z0-9]+").

Reftex-mode has some functions that allow extending it (e.g., reftex-cite-format, reftex-view-crossref-extra), but it is not clear how to use them to detect this type of citation.

Any ideas?

erikstokes
  • 12,686
  • 2
  • 34
  • 56
scaramouche
  • 1,772
  • 10
  • 24
  • 1
    This [post](http://stackoverflow.com/questions/13607156/autocomplete-pandoc-style-citations-from-a-bibtex-file-in-emacs) is related: it discusses how to use RefTeX to _insert_ Pandoc citations, but not how to make it _recognize_ Pandoc citations. – scaramouche Feb 24 '15 at 14:53

1 Answers1

2

Unfortunately, the format of citations is hard-coded as the latex one in reftex source code (see function reftex-view-crossref in file reftex-dcr.el), so there's no easy way to change it. However, if what you need is just to be able to look up the citation at point, the following does it:

(require 'reftex-dcr)
(defun my-reftex-view-pandoc-cite ()
   "View pandoc citation"
   (interactive)
   (let ((w (word-at-point)))
    (if (eq ?@ (elt w 0))
    (setq dw (reftex-view-cr-cite "" (substring w 1) 'tmp-window))
      (if (and (eq arg 2) (windowp dw)) (select-window dw))
      (error "Not on a citation")
      )))

You don't need to enable reftex-mode but you have to tell RefTex about your bibliography file:

(setq reftex-default-bibliography '("biblio"))

Something similar could be done for the 'idle display' feature, but it may be more complex.

JeanPierre
  • 7,323
  • 1
  • 18
  • 37