emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory
@ 2014-07-09 17:10 Konrad Herbst
  2014-07-09 18:36 ` Vikas Rawal
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Konrad Herbst @ 2014-07-09 17:10 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

Hello everybody,

I would like to provide a patch for the ox-bibtex.el module which can 
now handle bibtexfile destinations of the form:

#+BIBLIOGRAPHY: /home/user/Literature/foo.bib plain option:-d

but still accepts bibfiles in the working directory.

I really like this module as it makes on-the-fly literature referencing 
so easy, but I really missed the "feature" to use  include global 
bib-files for example. As I recognized other users had the same feeling, 
as these threads on the list show:
  - problem of path in using ox-bibtex, Joseph Vidal-Rosset, 2014-01-05 
08:35:58 GMT
  - [O] ox-bibtex: How to use Bib file in a different directory?, 
Richard Stanton, 2014-02-17 11:09:39 -8:00.

As motivation I think this solution is more convenient than creating 
symbolic links or changing environment variables/config-files.

I used functions like 'file-name-base`, so in principle this 
implementation should be OS-independent but I did not test this, maybe 
this should be tried for MS-OS paths for example.
Hope this is of any use.

Best,
Konrad Herbst

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-bibtex.el-Extend-to-use-bibtex-files-not-in-curre.patch --]
[-- Type: text/x-patch; name="0001-ox-bibtex.el-Extend-to-use-bibtex-files-not-in-curre.patch", Size: 3639 bytes --]

From 9c17d3df2de6a39229970461da80fb6d04bb6467 Mon Sep 17 00:00:00 2001
From: Konrad Herbst <k.herbst@stud.uni-heidelberg.de>
Date: Wed, 9 Jul 2014 15:26:10 +0200
Subject: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current
 working directory

* contrib/lisp/ox-bibtex.el (org-bibtex-process-bib-files): Process bibtexfilename so that it does not have to be in the same directory.
---
 contrib/lisp/ox-bibtex.el | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/contrib/lisp/ox-bibtex.el b/contrib/lisp/ox-bibtex.el
index 7caa2e2..7cb8972 100644
--- a/contrib/lisp/ox-bibtex.el
+++ b/contrib/lisp/ox-bibtex.el
@@ -36,7 +36,7 @@
 ;;
 ;; The usage is as follows:
 ;;
-;;   #+BIBLIOGRAPHY: bibfilebasename stylename optional-options
+;;   #+BIBLIOGRAPHY: bibfilename stylename optional-options
 ;;
 ;; e.g. given foo.bib and using style plain:
 ;;
@@ -44,6 +44,10 @@
 ;;
 ;; "stylename" can also be "nil", in which case no style will be used.
 ;;
+;; Full filepaths are also possible:
+;;
+;;   #+BIBLIOGRAPHY: /home/user/Literature/foo.bib plain option:-d
+;;
 ;; Optional options are of the form:
 ;;
 ;;   option:-foobar pass '-foobar' to bibtex2html
@@ -187,7 +191,16 @@ Return new parse tree."
 	(when (equal (org-element-property :key keyword) "BIBLIOGRAPHY")
 	  (let ((arguments (org-bibtex-get-arguments keyword))
 		(file (org-bibtex-get-file keyword))
-		temp-file)
+		temp-file
+		out-file)
+	    ;; Test if filename is given with .bib-extension and strip
+    	    ;; it off. Filenames with another extensions will be
+	    ;; untouched and will finally rise an error in bibtex2html.
+	    (setq file (if (equal (file-name-extension file) "bib")
+			   (file-name-sans-extension file) file))
+	    ;; Outpufiles of bibtex2html will be put into current working directory
+	    ;; so define a variable for this.
+	    (setq out-file (file-name-base file))
 	    ;; limit is set: collect citations throughout the document
 	    ;; in TEMP-FILE and pass it to "bibtex2html" as "-citefile"
 	    ;; argument.
@@ -219,7 +232,7 @@ Return new parse tree."
 	    (and temp-file (delete-file temp-file))
 	    ;; Open produced HTML file, and collect Bibtex key names
 	    (with-temp-buffer
-	      (insert-file-contents (concat file ".html"))
+	      (insert-file-contents (concat out-file ".html"))
 	      ;; Update `org-bibtex-html-entries-alist'.
 	      (goto-char (point-min))
 	      (while (re-search-forward
@@ -233,14 +246,14 @@ Return new parse tree."
 	       ((org-export-derived-backend-p backend 'html)
 		(insert (format "<div id=\"bibliography\">\n<h2>%s</h2>\n"
 				(org-export-translate "References" :html info)))
-		(insert-file-contents (concat file ".html"))
+		(insert-file-contents (concat out-file ".html"))
 		(insert "\n</div>"))
 	       ((org-export-derived-backend-p backend 'ascii)
 		;; convert HTML references to text w/pandoc
 		(unless (eq 0 (call-process "pandoc" nil nil nil
-					    (concat file ".html")
+					    (concat out-file ".html")
 					    "-o"
-					    (concat file ".txt")))
+					    (concat out-file ".txt")))
 		  (error "Executing pandoc failed"))
 		(insert
 		 (format
@@ -249,7 +262,7 @@ Return new parse tree."
 		   "References"
 		   (intern (format ":%s" (plist-get info :ascii-charset)))
 		   info)))
-		(insert-file-contents (concat file ".txt"))
+		(insert-file-contents (concat out-file ".txt"))
 		(goto-char (point-min))
 		(while (re-search-forward
 			"\\[ \\[bib\\][^ ]+ \\(\\]\\||[\n\r]\\)" nil t)
-- 
2.0.0


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

* Re: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory
  2014-07-09 17:10 [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory Konrad Herbst
@ 2014-07-09 18:36 ` Vikas Rawal
  2014-07-28 15:17 ` Bastien
  2014-08-02 19:27 ` Nicolas Goaziou
  2 siblings, 0 replies; 7+ messages in thread
From: Vikas Rawal @ 2014-07-09 18:36 UTC (permalink / raw)
  To: Konrad Herbst; +Cc: org-mode mailing list

> 
> I would like to provide a patch for the ox-bibtex.el module which can now handle bibtexfile destinations of the form:
> 
> #+BIBLIOGRAPHY: /home/user/Literature/foo.bib plain option:-d
> 

Great. I have had to deal with creating symlinks in my working directory and have never liked it.

Vikas

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

* Re: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory
  2014-07-09 17:10 [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory Konrad Herbst
  2014-07-09 18:36 ` Vikas Rawal
@ 2014-07-28 15:17 ` Bastien
  2014-08-02 19:27 ` Nicolas Goaziou
  2 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2014-07-28 15:17 UTC (permalink / raw)
  To: Konrad Herbst; +Cc: emacs-orgmode

Hi Konrad,

Konrad Herbst <k.herbst@stud.uni-heidelberg.de> writes:

> I would like to provide a patch for the ox-bibtex.el module which can 
> now handle bibtexfile destinations of the form:
>
> #+BIBLIOGRAPHY: /home/user/Literature/foo.bib plain option:-d
>
> but still accepts bibfiles in the working directory.

Thanks for the patch -- it goes beyond what can be accepted without
signing the FSF copyright assignment.  Would you be willing to sign
it?  Here is the form:

http://orgmode.org/cgit.cgi/org-mode.git/plain/request-assign-future.txt

Also, maybe John K. and other bibtex experts can have a look at the
patch and comment it?

Thanks,

-- 
 Bastien

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

* Re: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory
  2014-07-09 17:10 [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory Konrad Herbst
  2014-07-09 18:36 ` Vikas Rawal
  2014-07-28 15:17 ` Bastien
@ 2014-08-02 19:27 ` Nicolas Goaziou
  2014-08-03  8:57   ` Konrad Herbst
  2 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2014-08-02 19:27 UTC (permalink / raw)
  To: Konrad Herbst; +Cc: emacs-orgmode

Hello,

Konrad Herbst <k.herbst@stud.uni-heidelberg.de> writes:

> From: Konrad Herbst <k.herbst@stud.uni-heidelberg.de>
> Date: Wed, 9 Jul 2014 15:26:10 +0200
> Subject: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current
>  working directory
>
> * contrib/lisp/ox-bibtex.el (org-bibtex-process-bib-files): Process
> bibtexfilename so that it does not have to be in the same directory.

Applied. Thank you.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory
  2014-08-02 19:27 ` Nicolas Goaziou
@ 2014-08-03  8:57   ` Konrad Herbst
  2014-08-03 17:14     ` Thomas S. Dye
  0 siblings, 1 reply; 7+ messages in thread
From: Konrad Herbst @ 2014-08-03  8:57 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

thanks.
I am quite new to this. What is about this FSF copyright assignment 
Bastien mentioned? I filled it and send it to assign@gnu.org but since 
then nothing happened. How long does this usually take?

Best,
Konrad

Am 08/02/2014 09:27 PM, schrieb Nicolas Goaziou:
> Hello,
>
> Konrad Herbst <k.herbst@stud.uni-heidelberg.de> writes:
>
>> From: Konrad Herbst <k.herbst@stud.uni-heidelberg.de>
>> Date: Wed, 9 Jul 2014 15:26:10 +0200
>> Subject: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current
>>   working directory
>>
>> * contrib/lisp/ox-bibtex.el (org-bibtex-process-bib-files): Process
>> bibtexfilename so that it does not have to be in the same directory.
>
> Applied. Thank you.
>
>
> Regards,
>

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

* Re: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory
  2014-08-03  8:57   ` Konrad Herbst
@ 2014-08-03 17:14     ` Thomas S. Dye
  2014-08-03 18:29       ` Nick Dokos
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas S. Dye @ 2014-08-03 17:14 UTC (permalink / raw)
  To: Konrad Herbst; +Cc: emacs-orgmode

Aloha Konrad,

IIRC, it took my assignment about a month to be completed.

All the best,
Tom

Konrad Herbst <k.herbst@stud.uni-heidelberg.de> writes:

> Hello,
>
> thanks.
> I am quite new to this. What is about this FSF copyright assignment
> Bastien mentioned? I filled it and send it to assign@gnu.org but since
> then nothing happened. How long does this usually take?
>
> Best,
> Konrad
>
> Am 08/02/2014 09:27 PM, schrieb Nicolas Goaziou:
>> Hello,
>>
>> Konrad Herbst <k.herbst@stud.uni-heidelberg.de> writes:
>>
>>> From: Konrad Herbst <k.herbst@stud.uni-heidelberg.de>
>>> Date: Wed, 9 Jul 2014 15:26:10 +0200
>>> Subject: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current
>>>   working directory
>>>
>>> * contrib/lisp/ox-bibtex.el (org-bibtex-process-bib-files): Process
>>> bibtexfilename so that it does not have to be in the same directory.
>>
>> Applied. Thank you.
>>
>>
>> Regards,
>>
>
>

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory
  2014-08-03 17:14     ` Thomas S. Dye
@ 2014-08-03 18:29       ` Nick Dokos
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Dokos @ 2014-08-03 18:29 UTC (permalink / raw)
  To: emacs-orgmode

tsd@tsdye.com (Thomas S. Dye) writes:

> Aloha Konrad,
>
> IIRC, it took my assignment about a month to be completed.

Mine too - I don't remember the details, so don't hold me to it, but I
think I found out that it had gone through from Bastien first, rather
than the FSF. Eventually, I think I got a signed copy of the assignment
from the FSF (I don't remember whether it was a scanned PDF in email, or
a paper copy in snail mail), but it took a few more days/weeks.

So don't give up hope yet.

Nick

>
> All the best,
> Tom
>
> Konrad Herbst <k.herbst@stud.uni-heidelberg.de> writes:
>
>> Hello,
>>
>> thanks.
>> I am quite new to this. What is about this FSF copyright assignment
>> Bastien mentioned? I filled it and send it to assign@gnu.org but since
>> then nothing happened. How long does this usually take?
>>
>> Best,
>> Konrad
>>
>> Am 08/02/2014 09:27 PM, schrieb Nicolas Goaziou:
>>> Hello,
>>>
>>> Konrad Herbst <k.herbst@stud.uni-heidelberg.de> writes:
>>>
>>>> From: Konrad Herbst <k.herbst@stud.uni-heidelberg.de>
>>>> Date: Wed, 9 Jul 2014 15:26:10 +0200
>>>> Subject: [PATCH] ox-bibtex.el: Extend to use bibtex files not in current
>>>>   working directory
>>>>
>>>> * contrib/lisp/ox-bibtex.el (org-bibtex-process-bib-files): Process
>>>> bibtexfilename so that it does not have to be in the same directory.
>>>
>>> Applied. Thank you.
>>>
>>>
>>> Regards,
>>>
>>
>>

-- 
Nick

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

end of thread, other threads:[~2014-08-03 18:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-09 17:10 [PATCH] ox-bibtex.el: Extend to use bibtex files not in current, working directory Konrad Herbst
2014-07-09 18:36 ` Vikas Rawal
2014-07-28 15:17 ` Bastien
2014-08-02 19:27 ` Nicolas Goaziou
2014-08-03  8:57   ` Konrad Herbst
2014-08-03 17:14     ` Thomas S. Dye
2014-08-03 18:29       ` Nick Dokos

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