Browse Source

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.
Eric Schulte 10 years ago
parent
commit
d689755ca5
1 changed files with 7 additions and 3 deletions
  1. 7 3
      lisp/org-bibtex.el

+ 7 - 3
lisp/org-bibtex.el

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