org-bibtex: prompts for file name when writing to .bib file

Thanks to Tom Dye for this suggestion

* lisp/org-bibtex.el (org-bibtex): Now prompts for a file name.
This commit is contained in:
Eric Schulte 2011-04-28 10:02:33 -06:00
parent daef7d8631
commit d689755ca5

View file

@ -441,12 +441,16 @@ With optional argument OPTIONAL, also prompt for optional fields."
;;; Bibtex <-> Org-mode headline translation functions
(defun org-bibtex ()
(defun org-bibtex (&optional filename)
"Export each headline in the current file to a bibtex entry.
Headlines are exported using `org-bibtex-export-headline'."
(interactive)
(interactive
(list (read-file-name
"Bibtex file: " nil nil nil
(file-name-nondirectory
(concat (file-name-sans-extension (buffer-file-name)) ".bib")))))
(let ((bibtex-entries (remove nil (org-map-entries #'org-bibtex-headline))))
(with-temp-file (concat (file-name-sans-extension (buffer-file-name)) ".bib")
(with-temp-file filename
(insert (mapconcat #'identity bibtex-entries "\n")))))
(defun org-bibtex-check (&optional optional)