emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Richard Lawrence <richard.lawrence@berkeley.edu>
To: emacs-orgmode@gnu.org
Subject: Re: managing articles in my personal library, and their citational material, using org mode instead of bibtex
Date: Wed, 20 Nov 2013 08:52:58 -0800	[thread overview]
Message-ID: <87ob5fgglx.fsf@berkeley.edu> (raw)
In-Reply-To: 87vbzo8ikr.fsf@gmail.com

Eric Schulte <schulte.eric@gmail.com> writes:

> Ian Barton <lists@wilkesley.net> 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

  parent reply	other threads:[~2013-11-20 16:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  1:40 managing articles in my personal library, and their citational material, using org mode instead of bibtex Christopher W. Ryan
2013-11-19  8:28 ` Ian Barton
2013-11-19 16:25   ` Eric Schulte
2013-11-20  2:48     ` Alan L Tyree
2013-11-20  3:37       ` Eric Schulte
2013-11-20  6:16         ` Alan L Tyree
2013-11-20  6:27           ` Jambunathan K
2013-11-21 21:14             ` Alan L Tyree
2013-11-22  4:04               ` Eric Schulte
2013-11-22  5:37                 ` Alan L Tyree
2013-11-25 10:06               ` Jambunathan K
2013-11-20 16:52     ` Richard Lawrence [this message]
2013-11-21 22:00       ` Eric Schulte
2013-11-22  4:03         ` Eric Schulte
2013-11-23  0:06         ` Richard Lawrence
2013-11-19 10:41 ` Karl Voit
2013-11-25 18:29 ` John Kitchin
2013-11-21  0:49 Jorge A. Alfaro Murillo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ob5fgglx.fsf@berkeley.edu \
    --to=richard.lawrence@berkeley.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).