From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: managing articles in my personal library, and their citational material, using org mode instead of bibtex Date: Thu, 21 Nov 2013 15:00:00 -0700 Message-ID: <87fvqpza8v.fsf@gmail.com> References: <528AC19F.3000803@binghamton.edu> <528B2149.5040702@wilkesley.net> <87vbzo8ikr.fsf@gmail.com> <87ob5fgglx.fsf@berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjcJB-0008A7-Vd for emacs-orgmode@gnu.org; Thu, 21 Nov 2013 17:01:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjcJ8-0007wb-3M for emacs-orgmode@gnu.org; Thu, 21 Nov 2013 17:01:09 -0500 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:52400) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjcJ7-0007wX-JX for emacs-orgmode@gnu.org; Thu, 21 Nov 2013 17:01:06 -0500 Received: by mail-pa0-f41.google.com with SMTP id lf10so373302pab.14 for ; Thu, 21 Nov 2013 14:01:04 -0800 (PST) In-Reply-To: <87ob5fgglx.fsf@berkeley.edu> (Richard Lawrence's message of "Wed, 20 Nov 2013 08:52:58 -0800") 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: Richard Lawrence Cc: emacs-orgmode@gnu.org Richard Lawrence writes: > Eric Schulte writes: > >> Ian Barton writes: >> >>> On 19/11/13 01:40, Christopher W. Ryan wrote: >>>> Not sure "citational" is even a word, but hopefully it conveys my meaning! >>>> >>>> I've been using LaTeX for academic writing and reading for quite some >>>> time, with emacs as my editor. I'm pretty familiar with managing a .bib >>>> file containing all the references I've collected, and using it in LaTeX >>>> \cite commands. >>>> >>>> I've come to org-mode more recently. I'm trying to imagine how I might >>>> use it to manage my "personal library." I have a directory full of pdf >>>> files, each a downloaded article. Some articles I reference in papers I >>>> write; others I just read and want to keep. I also have a .bib file >>>> where I put the citational material for all those articles. Whenever I >>>> download an article, I add its entry to my .bib file. I tend to manage >>>> this with JabRef because it searches Medline so easily, but I also will >>>> edit the .bib file directly when necessary. >>>> >>>> I like the idea of an org file containing the citational information >>>> (authors, title, journal, etc) *plus* links to the pdfs on my hard >>>> drive, or on the internet. I could also include my notes about the >>>> articles. But what would that org file look like? How do I insert a >>>> reference to an article into the org file which contains the article I >>>> am writing? >>>> >>>> I'd be grateful for any explanations, or links to tutorials. >>>> > > I am also a grad student, and I use a setup which is similar to Eric's, > but rather than importing from bibtex, I use Org's capture features to > directly input the bibliographic data when I come across something I > want to add to my reading list. I don't maintain a separate .bib file > at all; rather I generate it as needed from the Org file containing my > reading list. > > This setup allows me to think of readings as TODO items included in my > agenda, take notes and make links in the entry, and also keep > bibliographic data in Org (which I export via org-bibtex). > > Here's what my setup looks like: > > 1) A capture template for new readings. My template looks like this: > > ** %^{Todo state|FIND|PRINT|READ|NOTES} [#%^{Priority|A|B|C}] %^{Description|Reading} %^g > %^{TITLE}p %^{AUTHOR}p %^{AREA}p %? > :PROPERTIES: > :Entered: %U > :END: > > This template does not have a field for adding links to PDFs, but you > could easily add that. > > 2) A hook to add bibliographic data to reading entries when finalizing a > capture. I put this in my Org setup: > > ;; post-processing in capture templates > (defun add-bibliographic-data () > ; this is a bit hacky: we detect the AUTHOR property, and create bibtex entries if > ; it is present > (message "optionally adding bibliographic data") > (if (and (org-entry-get (point) "AUTHOR") > (y-or-n-p "Add bibliographic data? ")) > ; with prefix arg to get all fields: > (org-bibtex-create-in-current-entry 1) > nil)) > > (add-hook 'org-capture-before-finalize-hook (lambda () (add-bibliographic-data))) > > There may be a better way to do this, but it works for me! > > 3) Elisp functions to export my entire reading list to .bib (these > assume that your readings are not in a separate file, but under a top-level > entry called "Reading list" in some other file): > > ;; lib/el/bib-export.el in my dissertation tree: > (setq dissertation-bib-file "~/Documents/philosophy/dissertation/build/dissertation.bib") > > (defun add-headline-to-bib-buffer (bib-buffer) > "Export headline at point to Bibtex into the given buffer" > (let ((bib-entry (org-bibtex-headline)) > (custom-id (org-entry-get (point) "CUSTOM_ID"))) > (if (and custom-id bib-entry) > (with-current-buffer bib-buffer > (insert bib-entry))))) > > (defun export-subtree-to-bib-buffer (headline bib-buffer) > "Export the entries in the subtree at point to Bibtex into the given buffer." > (save-excursion > (goto-char (org-find-exact-headline-in-buffer headline)) > (org-map-entries > (lambda () (add-headline-to-bib-buffer bib-buffer)) > t ; match: all entries below this one > 'tree ; scope: just this subtree > ))) > > (defun reading-list-to-bibtex () > "Export 'Reading list' headline in current buffer to dissertation.bib" > (interactive) > (let ((org-buffer (current-buffer)) > (bib-buffer (create-file-buffer "dissertation.bib"))) > (export-subtree-to-bib-buffer "Reading list" bib-buffer) > (with-current-buffer bib-buffer > (write-file dissertation-bib-file)))) > > 4) A Makefile entry to call the export functions: > > BATCH_EMACS=$(EMACS) --batch -Q > > bib: tasks.org lib/el/bib-export.el > $(BATCH_EMACS) --load lib/el/bib-export.el --file tasks.org --funcall reading-list-to-bibtex > > > Thus, I can run "make bib" in my dissertation tree and get a fresh > export of all my readings to a .bib file. > > Hope that helps! > > Best, > Richard > Very cool, I think some of these functions could be merged into contrib/lisp/org-bibtex-extras.el to very good effect. In the mean time I just pushed up a small change to this file which will resolve cite: links and export them correctly to LaTeX. Cheers, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D