Browse Source

org-bibtex: Fix type error in non-file buffers

* lisp/org-bibtex.el (org-bibtex): Fix type error in cases where the
  buffer is not visiting a file.  In an indirect buffer, use the file
  name for the base buffer.
Kyle Meyer 3 years ago
parent
commit
4eccbce9dc
1 changed files with 4 additions and 2 deletions
  1. 4 2
      lisp/org-bibtex.el

+ 4 - 2
lisp/org-bibtex.el

@@ -555,8 +555,10 @@ Headlines are exported using `org-bibtex-headline'."
   (interactive
    (list (read-file-name
 	  "Bibtex file: " nil nil nil
-	  (file-name-nondirectory
-	   (concat (file-name-sans-extension (buffer-file-name)) ".bib")))))
+	  (let ((file (buffer-file-name (buffer-base-buffer))))
+	    (and file
+		 (file-name-nondirectory
+		  (concat (file-name-sans-extension file) ".bib")))))))
   (let ((error-point
          (catch 'bib
            (let ((bibtex-entries