emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 1/5] org-bibtex.el (org-bibtex-read): Split in two functions


From: Stefan-W. Hahn
Subject: [O] [PATCH 1/5] org-bibtex.el (org-bibtex-read): Split in two functions for internal use
Date: Sun, 23 Mar 2014 11:16:07 +0100

* org-bibtex.el (org-bibtex-read): Organize `org-bibtex-read' function
into two functions, so that it can be used by other functions without
storing the result in `org-bibtex-entries'.

TINY CHANGE

Signed-off-by: Stefan-W. Hahn <address@hidden>
---
 lisp/org-bibtex.el | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index ed645e5..7a12c30 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -603,10 +603,9 @@ (defun org-bibtex-create-in-current-entry (&optional arg)
   (interactive "P")
   (org-bibtex-create arg t))
 
-(defun org-bibtex-read ()
+(defun org-bibtex-read-internal ()
   "Read a bibtex entry and save to `org-bibtex-entries'.
 This uses `bibtex-parse-entry'."
-  (interactive)
   (let ((keyword (lambda (str) (intern (concat ":" (downcase str)))))
        (clean-space (lambda (str) (replace-regexp-in-string
                                    "[[:space:]\n\r]+" " " str)))
@@ -617,16 +616,21 @@ (defun org-bibtex-read ()
                        (= (aref str 0) (car pair))
                        (= (aref str (1- (length str))) (cdr pair)))
               (setf str (substring str 1 (1- (length str)))))) str)))
-    (push (mapcar
-           (lambda (pair)
-             (cons (let ((field (funcall keyword (car pair))))
-                     (case field
-                       (:=type= :type)
-                       (:=key= :key)
-                       (otherwise field)))
-                   (funcall clean-space (funcall strip-delim (cdr pair)))))
-           (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
-          org-bibtex-entries)))
+    (mapcar
+     (lambda (pair)
+       (cons (let ((field (funcall keyword (car pair))))
+              (case field
+                (:=type= :type)
+                (:=key= :key)
+                (otherwise field)))
+            (funcall clean-space (funcall strip-delim (cdr pair)))))
+     (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))))
+
+(defun org-bibtex-read ()
+  "Read a bibtex entry and save to `org-bibtex-entries'.
+This uses `bibtex-parse-entry'."
+  (interactive)
+  (push (org-bibtex-read-internal) org-bibtex-entries))
 
 (defun org-bibtex-read-buffer (buffer)
   "Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.
-- 
1.8.3.2.733.gf8abaeb




reply via email to

[Prev in Thread] Current Thread [Next in Thread]