GNU bug report logs - #71946
30.0.50; [PATCH] Fix bibtex validation for non-file buffers

Previous Next

Package: emacs;

Reported by: Liu Hui <liuhui1610 <at> gmail.com>

Date: Fri, 5 Jul 2024 10:01:02 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71946 in the body.
You can then email your comments to 71946 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#71946; Package emacs. (Fri, 05 Jul 2024 10:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Liu Hui <liuhui1610 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 05 Jul 2024 10:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Liu Hui <liuhui1610 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
Date: Fri, 5 Jul 2024 18:00:00 +0800
[Message part 1 (text/plain, inline)]
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.
[0001-Fix-bibtex-validation-for-non-file-buffers.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71946; Package emacs. (Sat, 06 Jul 2024 22:40:02 GMT) Full text and rfc822 format available.

Message #8 received at 71946 <at> debbugs.gnu.org (full text, mbox):

From: Jeremy Bryant <jb <at> jeremybryant.net>
To: Liu Hui <liuhui1610 <at> gmail.com>
Cc: 71946 <at> debbugs.gnu.org
Subject: Re: bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file
 buffers
Date: Sat, 06 Jul 2024 23:38:28 +0100
Liu Hui <liuhui1610 <at> gmail.com> writes:

> 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

I have tested this recipe and reproduced this bug

>
> This patch fixes the problem. Thanks.

I have no comments on this patch yet.

>
> [2. text/x-patch; 0001-Fix-bibtex-validation-for-non-file-buffers.patch]...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71946; Package emacs. (Sat, 13 Jul 2024 10:27:02 GMT) Full text and rfc822 format available.

Message #11 received at 71946 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Liu Hui <liuhui1610 <at> gmail.com>, Roland Winkler <winkler <at> gnu.org>
Cc: 71946 <at> debbugs.gnu.org
Subject: Re: 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 <at> 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 <at> 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?




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 20 Jul 2024 09:50:02 GMT) Full text and rfc822 format available.

Notification sent to Liu Hui <liuhui1610 <at> gmail.com>:
bug acknowledged by developer. (Sat, 20 Jul 2024 09:50:02 GMT) Full text and rfc822 format available.

Message #16 received at 71946-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Liu Hui <liuhui1610 <at> gmail.com>
Cc: 71946-done <at> debbugs.gnu.org
Subject: Re: bug#71946: 30.0.50;
 [PATCH] Fix bibtex validation for non-file buffers
Date: Sat, 20 Jul 2024 12:49:17 +0300
> From: Liu Hui <liuhui1610 <at> 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.

Thanks, installed on the emacs-30 branch and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 17 Aug 2024 11:24:09 GMT) Full text and rfc822 format available.

Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 22 Sep 2024 19:53:02 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Roland Winkler <winkler <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 22 Sep 2024 19:55:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71946; Package emacs. (Sun, 22 Sep 2024 19:58:01 GMT) Full text and rfc822 format available.

Message #25 received at 71946 <at> debbugs.gnu.org (full text, mbox):

From: Roland Winkler <winkler <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71946 <at> debbugs.gnu.org, Liu Hui <liuhui1610 <at> gmail.com>
Subject: Re: bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file
 buffers
Date: Sun, 22 Sep 2024 14:57:05 -0500
[Message part 1 (text/plain, inline)]
On Sat, Jul 13 2024, Eli Zaretskii wrote:
> Roland, is this patch okay with you, and if so, is it safe enough to
> be installed on the emacs-30 release branch?

(For the records: resending this message with bug#71946 unarchived
so that this message goes into the bug tracker.)

I am sorry, due to a silly mistake on my side, I saw your email only
now.  I saw that you already installed the patch in the emacs-30 relase
branch.

I tested the patch, it works for me, and I believe the already installed
patch should be safe in 99.9% of all scenarios I can think of.  However
I'd suggest two minor modifications, see the patch attached below:

- rename FILE-P to IS-FILE to be consistent with the emacs lisp coding
  conventions.

- Set compilation-parse-errors-filename-function only if we do not want
  its default value.

Shall I install this patch in the emacs-30 release branch or in master?

Roland


[bibtex.patch (text/x-diff, inline)]
--- bibtex.el~	2024-09-22 13:41:29.890443820 -0500
+++ bibtex.el	2024-09-22 14:23:17.726487214 -0500
@@ -4638,16 +4638,17 @@
             (bibtex-progress-message 'done)))))
 
     (if error-list
-        (let* ((file-p (buffer-file-name))
-               (file (if file-p (file-name-nondirectory file-p) (buffer-name)))
+        (let* ((is-file (buffer-file-name))
+               (file (if is-file (file-name-nondirectory is-file) (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))
+            (unless is-file
+              (setq-local compilation-parse-errors-filename-function
+                          #'get-buffer))
             (let ((inhibit-read-only t))
               (delete-region (point-min) (point-max))
               (insert (substitute-command-keys

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71946; Package emacs. (Mon, 23 Sep 2024 11:46:01 GMT) Full text and rfc822 format available.

Message #28 received at 71946 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Roland Winkler <winkler <at> gnu.org>
Cc: 71946 <at> debbugs.gnu.org, liuhui1610 <at> gmail.com
Subject: Re: bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file
 buffers
Date: Mon, 23 Sep 2024 14:44:48 +0300
> From: Roland Winkler <winkler <at> gnu.org>
> Cc: Liu Hui <liuhui1610 <at> gmail.com>,  71946 <at> debbugs.gnu.org
> Date: Sun, 22 Sep 2024 14:25:39 -0500
> 
> On Sun, Sep 22 2024, Roland Winkler wrote:
> > However I'd suggest two minor modifications, see the patch attached
> > below:
> 
> Very embarrassing.  Please ignore the previous patch.  But it should
> read as attached.

Thanks, please install on the emacs-30 branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71946; Package emacs. (Wed, 25 Sep 2024 04:28:02 GMT) Full text and rfc822 format available.

Message #31 received at 71946 <at> debbugs.gnu.org (full text, mbox):

From: Roland Winkler <winkler <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71946 <at> debbugs.gnu.org, liuhui1610 <at> gmail.com
Subject: Re: bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file
 buffers
Date: Tue, 24 Sep 2024 23:24:39 -0500
On Mon, Sep 23 2024, Eli Zaretskii wrote:
> Thanks, please install on the emacs-30 branch.

Done.  commit bd25a98b4e7




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 23 Oct 2024 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 141 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.