[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
From: |
Eli Zaretskii |
Subject: |
bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers |
Date: |
Sat, 13 Jul 2024 13:26:28 +0300 |
> From: Liu Hui <liuhui1610@gmail.com>
> Date: Fri, 5 Jul 2024 18:00:00 +0800
>
> 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.
>
> 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
Thanks.
Roland, is this patch okay with you, and if so, is it safe enough to
be installed on the emacs-30 release branch?