* 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
* bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
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
2024-07-20 9:49 ` Eli Zaretskii
2 siblings, 0 replies; 7+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-06 22:38 UTC (permalink / raw)
To: Liu Hui; +Cc: 71946
Liu Hui <liuhui1610@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]...
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
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-07-20 9:49 ` Eli Zaretskii
2 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-07-13 10:26 UTC (permalink / raw)
To: Liu Hui, Roland Winkler; +Cc: 71946
> 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?
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
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
@ 2024-07-20 9:49 ` Eli Zaretskii
2 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2024-07-20 9:49 UTC (permalink / raw)
To: Liu Hui; +Cc: 71946-done
> 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.
Thanks, installed on the emacs-30 branch and closing the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
[not found] ` <87a5fzlcl9.fsf@gnu.org>
@ 2024-09-22 19:57 ` Roland Winkler
[not found] ` <875xqnlccs.fsf@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Roland Winkler @ 2024-09-22 19:57 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 71946, Liu Hui
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bibtex.patch --]
[-- Type: text/x-diff, Size: 1205 bytes --]
--- 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
[not found] ` <875xqnlccs.fsf@gnu.org>
@ 2024-09-23 11:44 ` Eli Zaretskii
2024-09-25 4:24 ` Roland Winkler
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-09-23 11:44 UTC (permalink / raw)
To: Roland Winkler; +Cc: 71946, liuhui1610
> From: Roland Winkler <winkler@gnu.org>
> Cc: Liu Hui <liuhui1610@gmail.com>, 71946@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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#71946: 30.0.50; [PATCH] Fix bibtex validation for non-file buffers
2024-09-23 11:44 ` Eli Zaretskii
@ 2024-09-25 4:24 ` Roland Winkler
0 siblings, 0 replies; 7+ messages in thread
From: Roland Winkler @ 2024-09-25 4:24 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 71946, liuhui1610
On Mon, Sep 23 2024, Eli Zaretskii wrote:
> Thanks, please install on the emacs-30 branch.
Done. commit bd25a98b4e7
^ permalink raw reply [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).