]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bibtex validation for non-file buffers
authorLiu Hui <liuhui1610@gmail.com>
Fri, 5 Jul 2024 09:50:08 +0000 (17:50 +0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 22 Jul 2024 10:37:48 +0000 (12:37 +0200)
* lisp/textmodes/bibtex.el (bibtex-validate): Use buffer name
to show errors in non-file buffers.  (Bug#71946)

(cherry picked from commit 816c53c2d9d6f2aabffdced23d10a0c902193235)

lisp/textmodes/bibtex.el

index a6da34d6a41bcda939f4ce6d5335c9b9f801d76e..1473fc2bd6bd48d8f15c771118f6b9fcd934d8f1 100644 (file)
@@ -4638,13 +4638,16 @@ Return t if test was successful, nil otherwise."
             (bibtex-progress-message 'done)))))
 
     (if error-list
-        (let ((file (file-name-nondirectory (buffer-file-name)))
-              (dir default-directory)
-              (err-buf "*BibTeX validation errors*"))
+        (let* ((file-p (buffer-file-name))
+               (file (if file-p (file-name-nondirectory file-p) (buffer-name)))
+               (dir default-directory)
+               (err-buf "*BibTeX validation errors*"))
           (setq error-list (sort error-list #'car-less-than-car))
           (with-current-buffer (get-buffer-create err-buf)
             (setq default-directory dir)
             (unless (eq major-mode 'compilation-mode) (compilation-mode))
+            (setq-local compilation-parse-errors-filename-function
+                        (if file-p #'identity #'get-buffer))
             (let ((inhibit-read-only t))
               (delete-region (point-min) (point-max))
               (insert (substitute-command-keys