emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem with org-bibtex-read with fields type, key
@ 2014-02-21 16:17 Stefan-W. Hahn
  2014-03-19 11:08 ` Bastien
  2014-03-23 10:16 ` [RFC] " Stefan-W. Hahn
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-02-21 16:17 UTC (permalink / raw)
  To: emacs-orgmode

Good evening,

I have a little problem with org-bibtex function org-bibtex-read:

My bibtex entries have the keyword "type" and "key". When
reading such an entry with org-bibtex-read I get an alist
with the entries ":type" and ":key" each twice.

,----
| (defun org-bibtex-read ()
|   ...
|              (cons (let ((field (funcall keyword (car pair))))
|                      (case field
|                        (:=type= :type)
|                        (:=key= :key)
|                        (otherwise field)))
|                    (funcall clean-space (funcall strip-delim (cdr pair)))))
|   ...
`----

Seems to be because of the conversation of "=type=" and "=key=".
Am I the only person having problems with it?

Is there some advice?

With kind regards,
Stefan
  
-- 
Stefan-W. Hahn                          It is easy to make things.
                                        It is hard to make things simple.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Problem with org-bibtex-read with fields type, key
  2014-02-21 16:17 Problem with org-bibtex-read with fields type, key Stefan-W. Hahn
@ 2014-03-19 11:08 ` Bastien
  2014-03-21 19:26   ` Stefan-W. Hahn
  2014-03-23 10:16 ` [RFC] " Stefan-W. Hahn
  1 sibling, 1 reply; 10+ messages in thread
From: Bastien @ 2014-03-19 11:08 UTC (permalink / raw)
  To: Stefan-W. Hahn; +Cc: emacs-orgmode

Hi Stefan,

"Stefan-W. Hahn" <info@s-hahn.de> writes:

> I have a little problem with org-bibtex function org-bibtex-read:
>
> My bibtex entries have the keyword "type" and "key". When
> reading such an entry with org-bibtex-read I get an alist
> with the entries ":type" and ":key" each twice.

Yes, I confirm the bug -- by any chance, did you have time to
sort this out?  (I see you already committed a fix to org-bibtex.el)

Thanks in advance,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Problem with org-bibtex-read with fields type, key
  2014-03-19 11:08 ` Bastien
@ 2014-03-21 19:26   ` Stefan-W. Hahn
  2014-03-21 22:02     ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-03-21 19:26 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Mail von Bastien, Wed, 19 Mar 2014 at 12:08:47 +0100:

Hello Bastian,

> Yes, I confirm the bug -- by any chance, did you have time to
> sort this out?  (I see you already committed a fix to org-bibtex.el)

sorry, just saw your reply.

I will get into it and try to make a proposal.

With kind regards,
Stefan

-- 
Stefan-W. Hahn                          It is easy to make things.
                                        It is hard to make things simple.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Problem with org-bibtex-read with fields type, key
  2014-03-21 19:26   ` Stefan-W. Hahn
@ 2014-03-21 22:02     ` Bastien
  0 siblings, 0 replies; 10+ messages in thread
From: Bastien @ 2014-03-21 22:02 UTC (permalink / raw)
  To: Stefan-W. Hahn; +Cc: emacs-orgmode

"Stefan-W. Hahn" <stefan.hahn@s-hahn.de> writes:

> I will get into it and try to make a proposal.

Thanks in advance!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] Problem with org-bibtex-read with fields type, key
  2014-02-21 16:17 Problem with org-bibtex-read with fields type, key Stefan-W. Hahn
  2014-03-19 11:08 ` Bastien
@ 2014-03-23 10:16 ` 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
                     ` (4 more replies)
  1 sibling, 5 replies; 10+ messages in thread
From: Stefan-W. Hahn @ 2014-03-23 10:16 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Good morning,

this patch series tries to dig with the problem of the double used property
names ":key" and ":type" in org-bibtex.

This is just a proposal, because it changes also the API of
`org-bibtex-store-link' and therefore needs a confirmation.

[PATCH 1/5] org-bibtex.el (org-bibtex-read): Split in two functions
[PATCH 2/5] org-bibtex.el: Use `org-bibtex-read-internal' in

 Patch 1 and 2 are somehow unproblematic but resolve a problem not
 mentioned before.

[PATCH 3/5] org-bibtex.el: Replace double used fieldnames ":key" and

 Patch 3 tries to resolve the original problem.

[PATCH 4/5] org-bibtex.el: Change property names in

 Patch 4 goes a little bit further an renames two porperties in
 `org-bibtex-store-link'. This is an API change which tries to make
 the content behind the properties clearer.

[PATCH 5/5] org-bibtex.el: Clarifying description of

 Patch 5 is just a documentation clarification.


Looking forward of some comments.

With kind regards,
Stefan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [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

end of thread, other threads:[~2014-03-23 10:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21 16:17 Problem with org-bibtex-read with fields type, key Stefan-W. Hahn
2014-03-19 11:08 ` Bastien
2014-03-21 19:26   ` Stefan-W. Hahn
2014-03-21 22:02     ` Bastien
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   ` [PATCH 3/5] org-bibtex.el: Replace double used fieldnames ":key" and ":byte" 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

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).