From mboxrd@z Thu Jan 1 00:00:00 1970 From: Myles English Subject: using an exported zotero library with org-mode Date: Tue, 19 Jun 2012 13:53:39 +0100 Message-ID: <87ipeniht8.fsf@ed.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sgxqe-0002EE-TR for emacs-orgmode@gnu.org; Tue, 19 Jun 2012 08:48:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgxqZ-0004M0-Ex for emacs-orgmode@gnu.org; Tue, 19 Jun 2012 08:47:56 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:44670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgxqZ-0004LS-3t for emacs-orgmode@gnu.org; Tue, 19 Jun 2012 08:47:51 -0400 Received: by eekb47 with SMTP id b47so2171357eek.0 for ; Tue, 19 Jun 2012 05:47:48 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org 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