From a7ed5b9b76c299bd5c0a11c75d71f1500a03c520 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sat, 28 Mar 2009 14:56:05 +0100 Subject: [PATCH] Citations: Use RefTeX to insert citations RefTeX can now be used to create a citation in Org-mode buffers. Setup the buffer with #+BIBLIOGRAPHY: bibbase style and create citations with `C-c C-x ['. --- doc/orgcard.tex | 8 +------- lisp/ChangeLog | 4 ++++ lisp/org.el | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/doc/orgcard.tex b/doc/orgcard.tex index 3aa691da6..ed0277a72 100644 --- a/doc/orgcard.tex +++ b/doc/orgcard.tex @@ -682,18 +682,12 @@ after ``{\tt :}'', and dictionary words elsewhere. \key{quit agenda, remove agenda buffer}{q} \key{exit agenda, remove all agenda buffers}{x} -\section{Calendar and Diary Integration} - -Include Emacs diary entries into Org-mode agenda with: -\beginexample% -(setq org-agenda-include-diary t) -\endexample - \section{LaTeX and cdlatex-mode} \key{preview LaTeX fragment}{C-c C-x C-l} \key{expand abbreviation (cdlatex-mode)}{TAB} \key{insert/modify math symbol (cdlatex-mode)}{` / '} +\key{insert citation using RefTeX}{C-c C-x [} \section{Exporting and Publishing} diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bcca0012c..d1b82e7da 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2009-03-28 Carsten Dominik + + * org.el (org-reftex-citation): New command. + 2009-03-27 Carsten Dominik * org-agenda.el (org-agenda-cmp-user-defined): New option. diff --git a/lisp/org.el b/lisp/org.el index c143ab052..415309a94 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13516,6 +13516,9 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." (define-key org-mode-map "\C-c\C-xg" 'org-feed-update-all) (define-key org-mode-map "\C-c\C-xG" 'org-feed-goto-inbox) +(define-key org-mode-map "\C-c\C-x[" 'org-reftex-citation) + + (when (featurep 'xemacs) (org-defkey org-mode-map 'button3 'popup-mode-menu)) @@ -15376,6 +15379,36 @@ this line is also exported in fixed-width font." (goto-char (match-end 0)) (insert org-quote-string " ")))))))) +(defun org-reftex-citation () + "Use reftex-citation to insert a citation into the buffer. +This looks for a line like + +#+BIBLIOGRAPHY: foo plain option:-d + +and derives from it that foo.bib is the bbliography file relevant +for this document. It then installs the necessary environment for RefTeX +to work in this buffer and calls `reftex-citation' to insert a citation +into the buffer. + +Export of such citations to both LaTeX and HTML is handled by the contributed +package org-exp-bibtex by Taru Karttunen." + (interactive) + (let ((reftex-docstruct-symbol 'rds) + (reftex-cite-format "\\cite{%l}") + rds bib) + (save-excursion + (save-restriction + (widen) + (let ((case-fold-search t) + (re "^#\\+bibliography:[ \t]+\\([^ \t\n]+\\)")) + (if (not (save-excursion + (or (re-search-forward re nil t) + (re-search-backward re nil t)))) + (error "No bibliography defined in file") + (setq bib (concat (match-string 1) ".bib") + rds (list (list 'bib bib))))))) + (call-interactively 'reftex-citation))) + ;;;; Functions extending outline functionality (defun org-beginning-of-line (&optional arg) @@ -15995,7 +16028,6 @@ Still experimental, may disappear in the future." ;; make tree, check each match with the callback (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback))) - ;;;; Finish up (provide 'org)