emacs-orgmode
[Top][All Lists]
Advanced

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

[O] using an exported zotero library with org-mode


From: Myles English
Subject: [O] using an exported zotero library with org-mode
Date: Tue, 19 Jun 2012 13:53:39 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Hi,

In case anyone else is wondering about this.

There are now several examples of managing bibliographies and associated
papers in orgmode [1][2][3].  Typically these involve a collection of pdf 
journal
papers, a .bib file, notes.org and draft_paper.org.  There has also been
a bit of discussion of zotero on this list.

The difference here is that I have been using Zotero [4] as the 'capture'; to
download papers and bibrefs.  I recently found out that Zotero can export a
library of journal papers and includes the path to the attachment (the pdf
file) in the "file = {}" field.

The main advantage I am pointing out here is that the pdf file doesn't not
need to be renamed manually.

So, if the Zotero collection is exported from the GUI to ~/tmp/bib/library,
then the result is ~/tmp/library/library.bib, with entries such as "file =
{my.pdf:files/1/my.pdf:application/pdf}" and the pdf at
~/tmp/library/files/1/my.pdf

RefTex can't currently access the 'file' field (first noted in Sept 2011
  [5]) and so needs this patch:

#+BEGIN_SRC elisp :tangle allow-file-field.patch
diff --git a/lisp/reftex-cite.el b/lisp/reftex-cite.el
index e1d2e92..f6adbcd 100644
--- a/lisp/reftex-cite.el
+++ b/lisp/reftex-cite.el
@@ -1063,8 +1063,10 @@ While entering the regexp, completion on knows citation 
keys is possible.
                ((= l ?T) (reftex-abbreviate-title
                           (reftex-get-bib-field "title" entry)))
                ((= l ?v) (reftex-get-bib-field "volume" entry))
-               ((= l ?y) (reftex-get-bib-field "year" entry)))))
-
+               ((= l ?y) (reftex-get-bib-field "year" entry))
+              ;; zotero path to the (pdf) file
+               ((= l ?z) (nth 1 (split-string
+                                (reftex-get-bib-field "file" entry) ":"))))))
       (if (string= rpl "")
           (setq b (match-beginning 2) e (match-end 2))
         (setq b (match-beginning 3) e (match-end 3)))
#+END_SRC

And then the now-familiar setup in .emacs making use of the %z place
holder for the path to the pdf:

#+BEGIN_SRC elisp
    (setq reftex-default-bibliography 
(quote("/home/myles/tmp/bib/library/library.bib")))
    
    ;; so that the functions contained in the strings can be evaluated
    ;; 
http://old.nabble.com/adding-datestamp-to-reftex-set-cite-format-td31794462.html
    (defadvice reftex-format-citation (before eval-citation-format)
      (setq format (eval format)))
    
      (defun org-mode-reftex-setup ()
        (load-library "reftex")
        (and (buffer-file-name)
             (file-exists-p (buffer-file-name))
             (reftex-parse-all)
             (progn
             ;enable auto-revert-mode to update reftex when bibtex file changes 
on disk
             ;;(global-auto-revert-mode t)
             (reftex-parse-all)
             ;add a custom reftex cite format to insert links
             (reftex-set-cite-format
              '((?b . "[[bib:%l][%l-bib]]")
                (?n . "[[notes:%l][%l-notes]]")
                (?p . "[[library:%l][%z]]")
                (?t . "%t")
                (?h . (concat "* %l - %t\n:PROPERTIES:\n:Created: "
                              "<" (substring (format-time-string 
(org-time-stamp-format t t)) 1 -1) ">"
                              "\n:Custom_ID: %l\n:file: 
[[library:%z][file]]\n:bib: [[bib:%l][bib]]\n:END:\n"))))))
        (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
        (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search))
    
      (add-hook 'org-mode-hook 'org-mode-reftex-setup)
  
  (setq org-link-abbrev-alist
        '(("bib" . "~/tmp/bib/library/library.bib::%s")
          ("notes" . "~/tmp/bib/notes.org::#%s")
          ("library" . "~/tmp/bib/library/%s")))
#+END_SRC

A potential problem is what happens when the collection is re-exported
from zotero?  But I will burn that bridge when I come to it.

Any comments are of course welcome but I am really just posting for
posterity.

Myles


Footnotes: 
[1]  http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/
[2]  http://article.gmane.org/gmane.emacs.orgmode/2406/match=bibliography
[3]  
http://tincman.wordpress.com/2011/01/04/research-paper-management-with-emacs-org-mode-and-reftex/
[4]  http://www.zotero.org/
[5]  http://comments.gmane.org/gmane.emacs.auctex.devel/2662




reply via email to

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