From 8ddd4e1cc1286eeef6e77715c82c4e9b9c5de92d Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Fri, 5 Jul 2024 17:50:08 +0800 Subject: [PATCH] Fix bibtex validation for non-file buffers * 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index a6da34d6a41..1473fc2bd6b 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -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 -- 2.39.2