emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* using an exported zotero library with org-mode
@ 2012-06-19 12:53 Myles English
  2012-06-19 16:47 ` Yagnesh Raghava Yakkala
  0 siblings, 1 reply; 4+ messages in thread
From: Myles English @ 2012-06-19 12:53 UTC (permalink / raw)
  To: emacs-orgmode Mode


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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-22  3:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-19 12:53 using an exported zotero library with org-mode Myles English
2012-06-19 16:47 ` Yagnesh Raghava Yakkala
2012-06-19 20:37   ` Myles English
2012-06-19 22:06     ` Yagnesh Raghava Yakkala

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).