unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
@ 2024-07-05 10:00 Liu Hui
  2024-07-06 22:38 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Liu Hui @ 2024-07-05 10:00 UTC (permalink / raw)
  To: 71946

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

Hi,

I find that bibtex-validate has a minor issue for non-file buffers
with syntax errors:

1. emacs -Q
2. create an empty buffer containing the following text:

@article{1,
  title = {Title},
  author = {authors},
  year = {2019}

3. M-x bibtex-mode, then M-x bibtex-validate
   => Wrong type argument: stringp, nil

This patch fixes the problem. Thanks.

[-- Attachment #2: 0001-Fix-bibtex-validation-for-non-file-buffers.patch --]
[-- Type: text/x-patch, Size: 1593 bytes --]

From b90a6838fa75e9023bcb61b6f545a5a7916e3b3c Mon Sep 17 00:00:00 2001
From: Liu Hui <liuhui1610@gmail.com>
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 when
errors are found in non-file buffers.
---
 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 @@ bibtex-validate
             (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.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-09-25  4:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-05 10:00 bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers Liu Hui
2024-07-06 22:38 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-13 10:26 ` Eli Zaretskii
     [not found]   ` <87a5fzlcl9.fsf@gnu.org>
2024-09-22 19:57     ` Roland Winkler
     [not found]     ` <875xqnlccs.fsf@gnu.org>
2024-09-23 11:44       ` Eli Zaretskii
2024-09-25  4:24         ` Roland Winkler
2024-07-20  9:49 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).