summaryrefslogtreecommitdiff
path: root/lisp/org-bibtex.el
diff options
context:
space:
mode:
authorSebastien Delafond <seb@debian.org>2013-08-11 16:27:56 +0200
committerSébastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:27 +0200
commit53b246b7d66bfa03ab9bcf47d4647913b401e3d6 (patch)
treeb5ea4e732c2219456d13048feb05b37b22a76391 /lisp/org-bibtex.el
parent8606e2621fc00fd8b334a06924aeef3aab7a2e4d (diff)
parente32a45ed36d6000db4b39171149072d11b77af72 (diff)
Imported Debian patch 8.0.7-1
Diffstat (limited to 'lisp/org-bibtex.el')
-rw-r--r--lisp/org-bibtex.el54
1 files changed, 41 insertions, 13 deletions
diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index f8e07ad..39902c0 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -1,11 +1,11 @@
;;; org-bibtex.el --- Org links to BibTeX entries
;;
-;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
;;
-;; Authors: Bastien Guerry <bzg at altern dot org>
+;; Authors: Bastien Guerry <bzg at gnu dot org>
;; Carsten Dominik <carsten dot dominik at gmail dot com>
;; Eric Schulte <schulte dot eric at gmail dot com>
-;; Keywords: org, wp, remember
+;; Keywords: org, wp, capture
;;
;; This file is part of GNU Emacs.
;;
@@ -31,7 +31,7 @@
;; the link that contains the author name, the year and a short title.
;;
;; It also stores detailed information about the entry so that
-;; remember templates can access and enter this information easily.
+;; capture templates can access and enter this information easily.
;;
;; The available properties for each entry are listed here:
;;
@@ -41,14 +41,14 @@
;; :booktitle :month :annote :abstract
;; :key :btype
;;
-;; Here is an example of a remember template that use some of this
+;; Here is an example of a capture template that use some of this
;; information (:author :year :title :journal :pages):
;;
-;; (setq org-remember-templates
+;; (setq org-capure-templates
;; '((?b "* READ %?\n\n%a\n\n%:author (%:year): %:title\n \
;; In %:journal, %:pages.")))
;;
-;; Let's say you want to remember this BibTeX entry:
+;; Let's say you want to capture this BibTeX entry:
;;
;; @Article{dolev83,
;; author = {Danny Dolev and Andrew C. Yao},
@@ -61,7 +61,7 @@
;; month = {Mars}
;; }
;;
-;; M-x `org-remember' on this entry will produce this buffer:
+;; M-x `org-capture' on this entry will produce this buffer:
;;
;; =====================================================================
;; * READ <== [point here]
@@ -88,13 +88,13 @@
;;
;; - All Bibtex information is taken from the document compiled by
;; Andrew Roberts from the Bibtex manual, available at
-;; http://www.andy-roberts.net/misc/latex/sessions/bibtex/bibentries.pdf
+;; http://www.andy-roberts.net/res/writing/latex/bibentries.pdf
;;
;;; History:
;;
;; The link creation part has been part of Org-mode for a long time.
;;
-;; Creating better remember template information was inspired by a request
+;; Creating better capture template information was inspired by a request
;; of Austin Frank: http://article.gmane.org/gmane.emacs.orgmode/4112
;; and then implemented by Bastien Guerry.
;;
@@ -120,7 +120,6 @@
(declare-function bibtex-generate-autokey "bibtex" ())
(declare-function bibtex-parse-entry "bibtex" (&optional content))
(declare-function bibtex-url "bibtex" (&optional pos no-browse))
-(declare-function longlines-mode "longlines" (&optional arg))
(declare-function org-babel-trim "ob" (string &optional regexp))
@@ -381,7 +380,7 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords' is t."
(buf-name (format "*Bibtex Help %s*" name)))
(with-output-to-temp-buffer buf-name
(princ (cdr (assoc field org-bibtex-fields))))
- (with-current-buffer buf-name (longlines-mode t))
+ (with-current-buffer buf-name (visual-line-mode 1))
(org-fit-window-to-buffer (get-buffer-window buf-name))
((lambda (result) (when (> (length result) 0) result))
(read-from-minibuffer (format "%s: " name))))))
@@ -624,6 +623,27 @@ This uses `bibtex-parse-entry'."
(save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
org-bibtex-entries)))
+(defun org-bibtex-read-buffer (buffer)
+ "Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.
+Return the number of saved entries."
+ (interactive "bbuffer: ")
+ (let ((start-length (length org-bibtex-entries)))
+ (with-current-buffer buffer
+ (save-excursion
+ (goto-char (point-max))
+ (while (not (= (point) (point-min)))
+ (backward-char 1)
+ (org-bibtex-read)
+ (bibtex-beginning-of-entry))))
+ (let ((added (- (length org-bibtex-entries) start-length)))
+ (message "parsed %d entries" added)
+ added)))
+
+(defun org-bibtex-read-file (file)
+ "Read FILE with `org-bibtex-read-buffer'."
+ (interactive "ffile: ")
+ (org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile)))
+
(defun org-bibtex-write ()
"Insert a heading built from the first element of `org-bibtex-entries'."
(interactive)
@@ -665,6 +685,14 @@ This uses `bibtex-parse-entry'."
(org-bibtex-write)
(error "Yanked text does not appear to contain a BibTeX entry"))))
+(defun org-bibtex-import-from-file (file)
+ "Read bibtex entries from FILE and insert as Org-mode headlines after point."
+ (interactive "ffile: ")
+ (dotimes (_ (org-bibtex-read-file file))
+ (save-excursion (org-bibtex-write))
+ (re-search-forward org-property-end-re)
+ (open-line 1) (forward-char 1)))
+
(defun org-bibtex-export-to-kill-ring ()
"Export current headline to kill ring as bibtex entry."
(interactive)
@@ -679,7 +707,7 @@ This function relies `org-search-view' to locate results."
(org-agenda-search-view-always-boolean t))
(org-search-view nil
(format "%s +{:%s%s:}"
- string org-bibtex-prefix
+ string (or org-bibtex-prefix "")
org-bibtex-type-property-name))))
(provide 'org-bibtex)