[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] User-customizable RefTeX citations

From: Tassilo Horn
Subject: Re: [AUCTeX-devel] User-customizable RefTeX citations
Date: Wed, 10 Oct 2012 09:33:40 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux)

Antoine Levitt <address@hidden> writes:

>> I would like to use RefTeX to insert a customized citation-style that
>> includes a link to a paper's PDF file.  The bibtex reference manager
>> I use creates a "file" field in each bibtex entry that has the
>> following form:
>> file = {:home/username/path/to/paper name.pdf:pdf}
> I guess you're using jabref. That's what I'm using too.
> It's unrelated to what you're after, but it'd be nice to have some
> degree of support for this (just a command to attach a file to an entry
> in bibtex mode,

You can use hippie-expand to complete file names and paths inside
buffers.  That would allow you to type

  /home/username/path/to/paper name.pdf

quickly.  Well, you'd need to replace the root / with : and add the
:pdf.  That's a quite weird syntax, and file is no standard bibtex data
field whatsoever.

> and a command to open the pdf under the current \cite{} would be
> nice).

Here's a function that given a key and a field name returns the value of
that entry's field.

--8<---------------cut here---------------start------------->8---
(defun th-reftex-get-data (key data)
  (let* ((files (reftex-get-bibfile-list))
         (entry (condition-case nil
                      (reftex-pop-to-bibtex-entry key files nil nil nil t))
                   (if files
                       (message "cite: no such database entry: %s" key)
                     (message "%s" (substitute-command-keys
                                    (format reftex-no-info-message "cite"))))
    (when entry
      (cdr (assoc data (reftex-parse-bibtex-entry entry))))))
--8<---------------cut here---------------end--------------->8---

You could use it to define a command to find the pdf in emacs (which
would open doc-view).

--8<---------------cut here---------------start------------->8---
(defun th-reftex-open-file ()
  (let ((file (th-reftex-get-data (current-word) "file")))
    (when file
      (let ((name (concat "/" (save-match-data
                                (string-match ":\\(.*\\):pdf" file)
                                (match-string 1 file)))))
        (find-file name)))))
--8<---------------cut here---------------end--------------->8---

Simply place point in the \cite{...} and do M-x th-reftex-open-file.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]