* [PATCH 1/5] org-bibtex.el (org-bibtex-read): Split in two functions for internal use
2014-03-23 10:16 ` [RFC] " Stefan-W. Hahn
@ 2014-03-23 10:16 ` Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 2/5] org-bibtex.el: Use `org-bibtex-read-internal' in `org-bibtex-store-link' Stefan-W. Hahn
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-03-23 10:16 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode, Stefan-W. Hahn
* 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 <stefan.hahn@s-hahn.de>
---
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/5] org-bibtex.el: Use `org-bibtex-read-internal' in `org-bibtex-store-link'
2014-03-23 10:16 ` [RFC] " Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 1/5] org-bibtex.el (org-bibtex-read): Split in two functions for internal use Stefan-W. Hahn
@ 2014-03-23 10:16 ` Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 3/5] org-bibtex.el: Replace double used fieldnames ":key" and ":byte" Stefan-W. Hahn
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-03-23 10:16 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode, Stefan-W. Hahn
* org-bibtex.el (org-bibtex-store-link): To have the same conversion,
especially removing of {{...}}, of a bibtex entry use
`org-bibtex-read-internal' in `org-bibtex-store-link'.
TINY CHANGE
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
lisp/org-bibtex.el | 46 ++++++++++++++++++++--------------------------
1 file changed, 20 insertions(+), 26 deletions(-)
diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index 7a12c30..4fd1153 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -453,33 +453,27 @@ (defun org-bibtex-store-link ()
(let* ((search (org-create-file-search-in-bibtex))
(link (concat "file:" (abbreviate-file-name buffer-file-name)
"::" search))
- (entry (mapcar ; repair strings enclosed in "..." or {...}
- (lambda(c)
- (if (string-match
- "^\\(?:{\\|\"\\)\\(.*\\)\\(?:}\\|\"\\)$" (cdr c))
- (cons (car c) (match-string 1 (cdr c))) c))
- (save-excursion
- (bibtex-beginning-of-entry)
- (bibtex-parse-entry)))))
+ (entry (org-bibtex-read-internal)))
+
(org-store-link-props
- :key (cdr (assoc "=key=" entry))
- :author (or (cdr (assoc "author" entry)) "[no author]")
- :editor (or (cdr (assoc "editor" entry)) "[no editor]")
- :title (or (cdr (assoc "title" entry)) "[no title]")
- :booktitle (or (cdr (assoc "booktitle" entry)) "[no booktitle]")
- :journal (or (cdr (assoc "journal" entry)) "[no journal]")
- :publisher (or (cdr (assoc "publisher" entry)) "[no publisher]")
- :pages (or (cdr (assoc "pages" entry)) "[no pages]")
- :url (or (cdr (assoc "url" entry)) "[no url]")
- :year (or (cdr (assoc "year" entry)) "[no year]")
- :month (or (cdr (assoc "month" entry)) "[no month]")
- :address (or (cdr (assoc "address" entry)) "[no address]")
- :volume (or (cdr (assoc "volume" entry)) "[no volume]")
- :number (or (cdr (assoc "number" entry)) "[no number]")
- :annote (or (cdr (assoc "annote" entry)) "[no annotation]")
- :series (or (cdr (assoc "series" entry)) "[no series]")
- :abstract (or (cdr (assoc "abstract" entry)) "[no abstract]")
- :btype (or (cdr (assoc "=type=" entry)) "[no type]")
+ :key (cdr (assoc :key entry))
+ :author (or (cdr (assoc :author entry)) "[no author]")
+ :editor (or (cdr (assoc :editor entry)) "[no editor]")
+ :title (or (cdr (assoc :title entry)) "[no title]")
+ :booktitle (or (cdr (assoc :booktitle entry)) "[no booktitle]")
+ :journal (or (cdr (assoc :journal entry)) "[no journal]")
+ :publisher (or (cdr (assoc :publisher entry)) "[no publisher]")
+ :pages (or (cdr (assoc :pages entry)) "[no pages]")
+ :url (or (cdr (assoc :url entry)) "[no url]")
+ :year (or (cdr (assoc :year entry)) "[no year]")
+ :month (or (cdr (assoc :month entry)) "[no month]")
+ :address (or (cdr (assoc :address entry)) "[no address]")
+ :volume (or (cdr (assoc :volume entry)) "[no volume]")
+ :number (or (cdr (assoc :number entry)) "[no number]")
+ :annote (or (cdr (assoc :annote entry)) "[no annotation]")
+ :series (or (cdr (assoc :series entry)) "[no series]")
+ :abstract (or (cdr (assoc :abstract entry)) "[no abstract]")
+ :btype (or (cdr (assoc :type entry)) "[no type]")
:type "bibtex"
:link link
:description org-bibtex-description))))
--
1.8.3.2.733.gf8abaeb
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/5] org-bibtex.el: Replace double used fieldnames ":key" and ":byte".
2014-03-23 10:16 ` [RFC] " Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 1/5] org-bibtex.el (org-bibtex-read): Split in two functions for internal use Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 2/5] org-bibtex.el: Use `org-bibtex-read-internal' in `org-bibtex-store-link' Stefan-W. Hahn
@ 2014-03-23 10:16 ` Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 4/5] org-bibtex.el: Change property names in `org-bibtex-store-link' API Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 5/5] org-bibtex.el: Clarifying description of `org-bibtex-type-property-name' Stefan-W. Hahn
4 siblings, 0 replies; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-03-23 10:16 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode, Stefan-W. Hahn
* org-bibtex.el (org-bibtex-read-internal): Change property names.
The bibtex parser returns
=key= for the key of the bibtex entry
=type= for the type of the bibtex entry.
These both should not be mixed up with the ":key" and ":type" entries of a
bibtex item. So they get renamed to ":bibkey" and ":bibtype" respectively.
TINY CHANGE
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
lisp/org-bibtex.el | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index 4fd1153..b4b707a 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -456,7 +456,7 @@ (defun org-bibtex-store-link ()
(entry (org-bibtex-read-internal)))
(org-store-link-props
- :key (cdr (assoc :key entry))
+ :key (cdr (assoc :bibkey entry))
:author (or (cdr (assoc :author entry)) "[no author]")
:editor (or (cdr (assoc :editor entry)) "[no editor]")
:title (or (cdr (assoc :title entry)) "[no title]")
@@ -473,8 +473,8 @@ (defun org-bibtex-store-link ()
:annote (or (cdr (assoc :annote entry)) "[no annotation]")
:series (or (cdr (assoc :series entry)) "[no series]")
:abstract (or (cdr (assoc :abstract entry)) "[no abstract]")
- :btype (or (cdr (assoc :type entry)) "[no type]")
- :type "bibtex"
+ :btype (or (cdr (assoc :bibtype entry)) "[no bibtype]")
+ :type "bibtex" ; hides bibtex entry :type
:link link
:description org-bibtex-description))))
@@ -614,8 +614,8 @@ (defun org-bibtex-read-internal ()
(lambda (pair)
(cons (let ((field (funcall keyword (car pair))))
(case field
- (:=type= :type)
- (:=key= :key)
+ (:=type= :bibtype)
+ (:=key= :bibkey)
(otherwise field)))
(funcall clean-space (funcall strip-delim (cdr pair)))))
(save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))))
@@ -660,12 +660,12 @@ (defun org-bibtex-write ()
(insert (funcall val :title))
(org-bibtex-put "TITLE" (funcall val :title))
(org-bibtex-put org-bibtex-type-property-name
- (downcase (funcall val :type)))
+ (downcase (funcall val :bibtype)))
(dolist (pair entry)
(case (car pair)
(:title nil)
(:type nil)
- (:key (org-bibtex-put org-bibtex-key-property (cdr pair)))
+ (:bibkey (org-bibtex-put org-bibtex-key-property (cdr pair)))
(:keywords (if org-bibtex-tags-are-keywords
(mapc
(lambda (kw)
--
1.8.3.2.733.gf8abaeb
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/5] org-bibtex.el: Change property names in `org-bibtex-store-link' API.
2014-03-23 10:16 ` [RFC] " Stefan-W. Hahn
` (2 preceding siblings ...)
2014-03-23 10:16 ` [PATCH 3/5] org-bibtex.el: Replace double used fieldnames ":key" and ":byte" Stefan-W. Hahn
@ 2014-03-23 10:16 ` Stefan-W. Hahn
2014-03-23 10:16 ` [PATCH 5/5] org-bibtex.el: Clarifying description of `org-bibtex-type-property-name' Stefan-W. Hahn
4 siblings, 0 replies; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-03-23 10:16 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode, Stefan-W. Hahn
* org-bibtex.el (org-bibtex-store-link): Change property names in API.
Because it is confusing to have a ":key" property in
`org-bibtex-store-link' which is not the ":key" entry of a bibtex entry
but the key of the entry, this should be changed. The new name of the
property is ":bibkey".
To be consistent the property ":btype" is renamed to ":bibtype".
TINY CHANGE
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
lisp/org-bibtex.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index b4b707a..d8ab649 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -39,7 +39,7 @@
;; :editor :url :number :journal
;; :title :year :series :address
;; :booktitle :month :annote :abstract
-;; :key :btype
+;; :bibkey :bibtype
;;
;; Here is an example of a capture template that use some of this
;; information (:author :year :title :journal :pages):
@@ -456,7 +456,7 @@ (defun org-bibtex-store-link ()
(entry (org-bibtex-read-internal)))
(org-store-link-props
- :key (cdr (assoc :bibkey entry))
+ :bibkey (cdr (assoc :bibkey entry))
:author (or (cdr (assoc :author entry)) "[no author]")
:editor (or (cdr (assoc :editor entry)) "[no editor]")
:title (or (cdr (assoc :title entry)) "[no title]")
@@ -473,7 +473,7 @@ (defun org-bibtex-store-link ()
:annote (or (cdr (assoc :annote entry)) "[no annotation]")
:series (or (cdr (assoc :series entry)) "[no series]")
:abstract (or (cdr (assoc :abstract entry)) "[no abstract]")
- :btype (or (cdr (assoc :bibtype entry)) "[no bibtype]")
+ :bibtype (or (cdr (assoc :bibtype entry)) "[no bibtype]")
:type "bibtex" ; hides bibtex entry :type
:link link
:description org-bibtex-description))))
--
1.8.3.2.733.gf8abaeb
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/5] org-bibtex.el: Clarifying description of `org-bibtex-type-property-name'.
2014-03-23 10:16 ` [RFC] " Stefan-W. Hahn
` (3 preceding siblings ...)
2014-03-23 10:16 ` [PATCH 4/5] org-bibtex.el: Change property names in `org-bibtex-store-link' API Stefan-W. Hahn
@ 2014-03-23 10:16 ` Stefan-W. Hahn
4 siblings, 0 replies; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-03-23 10:16 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode, Stefan-W. Hahn
* org-bibtex.el: Clarifying description of `org-bibtex-type-property-name'.
TINY CHANGE
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
lisp/org-bibtex.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index d8ab649..7e1d8da 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -285,7 +285,9 @@ (defcustom org-bibtex-no-export-tags nil
:type '(repeat :tag "Tag" (string)))
(defcustom org-bibtex-type-property-name "btype"
- "Property in which to store bibtex entry type (e.g., article)."
+ "Org property in which to store bibtex entry type (e.g.,
+article) when converting between parsed bibtex entry and org-mode
+property database."
:group 'org-bibtex
:version "24.1"
:type 'string)
--
1.8.3.2.733.gf8abaeb
^ permalink raw reply related [flat|nested] 10+ messages in thread