GNU bug report logs - #37957
BibTeX dialect not set if local variables disabled

Previous Next

Package: emacs;

Reported by: Richard Copley <rcopley <at> gmail.com>

Date: Mon, 28 Oct 2019 09:47:01 UTC

Severity: normal

Done: "Roland Winkler" <winkler <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 37957 in the body.
You can then email your comments to 37957 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#37957; Package emacs. (Mon, 28 Oct 2019 09:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Richard Copley <rcopley <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 28 Oct 2019 09:47:02 GMT) Full text and rfc822 format available.

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

From: Richard Copley <rcopley <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org, Roland Winkler <winkler <at> gnu.org>
Subject: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 09:44:15 +0000
[Message part 1 (text/plain, inline)]
From "emacs -Q",
* Set the variable 'enable-local-variables' to nil.
* Visit a BibTeX (*.bib) file.
* Wait one minute or eval (bibtex-parse-buffers-stealthily).

Lisp error: (wrong-type-argument number-or-marker-p nil)
Backtrace:
  1+(nil)
  (buffer-substring-no-properties (1+ (match-beginning
bibtex-type-in-head)) (match-end bibtex-type-in-head))
  bibtex-type-in-head()
  (assoc-string (bibtex-type-in-head) bibtex-entry-alist t)
  [...]
  bibtex-parse-keys(t)
  bibtex-parse-buffers-stealthily()
  [...]

On visiting a BibTeX file, if enable-local-variables is nil,
'bibtex-set-dialect' doesn't get called. This causes errors later on. For
example, when 'bibtex-parse-buffers-stealthily' is called, we get the above
error, because 'bibtex-entry-head' has not been set. Glancing at the
history of  'bibtex-major-mode', this commit seems a likely candidate:

ace88aa20f32b298e7f2e8e6115b5661504f8724
Author: Roland Winkler <winkler <at> gnu.org>
AuthorDate: Sat Jan 28 12:06:10 2012 -0600

lisp/textmodes/bibtex.el: allow bibtex-dialect as file-local variable
(Bug#10254)
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Mon, 28 Oct 2019 15:17:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: 37957 <at> debbugs.gnu.org, winkler <at> gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 16:16:00 +0100
Richard Copley <rcopley <at> gmail.com> writes:

> From "emacs -Q",
> * Set the variable 'enable-local-variables' to nil.
> * Visit a BibTeX (*.bib) file.
> * Wait one minute or eval (bibtex-parse-buffers-stealthily).
>
> Lisp error: (wrong-type-argument number-or-marker-p nil)
> Backtrace:
>   1+(nil)
>   (buffer-substring-no-properties (1+ (match-beginning bibtex-type-in-head))
> (match-end bibtex-type-in-head))
>   bibtex-type-in-head()

Do you have an example .bib file that can be used to reproduce this bug?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Mon, 28 Oct 2019 16:22:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 17:21:24 +0100
Richard Copley <rcopley <at> gmail.com> writes:

> An empty file or scratch buffer, or the first BibTeX sample file you
> can find on the web, will work fine. The contents aren't relevant.

I was unable to reproduce the bug with an empty buffer, so if you could
include one in the bug report, that would make things easier.

(And don't drop the debbugs address from the Cc -- otherwise the mail
won't make it to the bug tracker.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Mon, 28 Oct 2019 16:34:01 GMT) Full text and rfc822 format available.

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

From: Richard Copley <rcopley <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 16:33:04 +0000
[Message part 1 (text/plain, inline)]
On Mon, 28 Oct 2019 at 16:21, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Richard Copley <rcopley <at> gmail.com> writes:
>
> > An empty file or scratch buffer, or the first BibTeX sample file you
> > can find on the web, will work fine. The contents aren't relevant.
>
> I was unable to reproduce the bug with an empty buffer, so if you could
> include one in the bug report, that would make things easier.
>

No, it would be a waste of everybody's time. Try this one liner:

emacs -Q -eval "(with-current-buffer \"*empty*\" (setq
enable-local-variables nil) (bibtex-mode)
(bibtex-parse-buffers-stealthily))"
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Mon, 28 Oct 2019 16:43:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 17:42:37 +0100
Richard Copley <rcopley <at> gmail.com> writes:

> No, it would be a waste of everybody's time. Try this one liner:
>
> emacs -Q -eval "(with-current-buffer \"*empty*\" (setq enable-local-variables nil)
> (bibtex-mode) (bibtex-parse-buffers-stealthily))"

"No buffer named *empty*"

But even if I fix the expression, I'm still not able to reproduce the
bug in Emacs 27.  You didn't include the Emacs version in your bug
report, unfortunately.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Mon, 28 Oct 2019 17:57:01 GMT) Full text and rfc822 format available.

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

From: Richard Copley <rcopley <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 17:55:37 +0000
[Message part 1 (text/plain, inline)]
On Mon, 28 Oct 2019 at 16:42, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> Richard Copley <rcopley <at> gmail.com> writes:
>
> > No, it would be a waste of everybody's time. Try this one liner:
> >
> > emacs -Q -eval "(with-current-buffer \"*empty*\" (setq
enable-local-variables nil)
> > (bibtex-mode) (bibtex-parse-buffers-stealthily))"
>
> "No buffer named *empty*"

emacs -Q -eval "(with-current-buffer \"*scratch*\" (setq
enable-local-variables nil) (bibtex-mode)
(bibtex-parse-buffers-stealthily))"

> But even if I fix the expression, I'm still not able to reproduce the
> bug in Emacs 27. You didn't include the Emacs version in your bug
> report, unfortunately.

Curious! Works for me on current master (built from a fresh checkout just
now) and the FSF builds of Emacs 24.5 (i686) and Emacs 26.3 (x86_64), on
Windows.
Ah hah, but not on Debian (on Emacs built from master a few months ago).
That's a surprise.

Just to be sure, here's an unambiguous specification of a recipe that does
work, for me, in all of those environments. From 'emacs -Q',

M-x set-variable RET enable-local-variables RET nil RET
M-x bibtex-mode RET
M-: (bibtex-parse-buffers-stealthily) RET
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Mon, 28 Oct 2019 18:55:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: rcopley <at> gmail.com, 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 20:54:29 +0200
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Mon, 28 Oct 2019 17:42:37 +0100
> Cc: 37957 <at> debbugs.gnu.org
> 
> Richard Copley <rcopley <at> gmail.com> writes:
> 
> > No, it would be a waste of everybody's time. Try this one liner:
> >
> > emacs -Q -eval "(with-current-buffer \"*empty*\" (setq enable-local-variables nil)
> > (bibtex-mode) (bibtex-parse-buffers-stealthily))"
> 
> "No buffer named *empty*"
> 
> But even if I fix the expression, I'm still not able to reproduce the
> bug in Emacs 27.  You didn't include the Emacs version in your bug
> report, unfortunately.

FWIW, reproduces fine here, both with Emacs 26.3 and Emacs 27, both on
MS-Windows and on GNU/Linux.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Tue, 29 Oct 2019 01:53:02 GMT) Full text and rfc822 format available.

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

From: "Roland Winkler" <winkler <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Richard Copley <rcopley <at> gmail.com>, 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Mon, 28 Oct 2019 20:52:27 -0500
On Mon Oct 28 2019 Lars Ingebrigtsen wrote:
> Do you have an example .bib file that can be used to reproduce this bug?

I can, indeed, reproduce this with `emacs -Q', setting
enable-local-variables to nil and then loading any BibTeX file.

Yet it is not clear to me what is the proper solution for this.

Currently, bibtex-mode makes bibtex-set-dialect an element of
hack-local-variables-hook.  This hook is called only if
enable-local-variables is non-nil.  Of course, bibtex-mode could
call bibtex-set-dialect directly if enable-local-variables is nil.
Yet I guess that enable-local-variables being nil may break more
things if hack-local-variables-hook is not called.

If nothing else, we could mention in the docstring of
hack-local-variables-hook that this hook is not called if
enable-local-variables is nil.

Roland




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Tue, 29 Oct 2019 11:25:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Tue, 29 Oct 2019 12:24:32 +0100
Richard Copley <rcopley <at> gmail.com> writes:

>> But even if I fix the expression, I'm still not able to reproduce the
>> bug in Emacs 27. You didn't include the Emacs version in your bug
>> report, unfortunately.
>
> Curious! Works for me on current master (built from a fresh checkout just now)
> and the FSF builds of Emacs 24.5 (i686) and Emacs 26.3 (x86_64), on Windows.
> Ah hah, but not on Debian (on Emacs built from master a few months ago).
> That's a surprise.

How odd.  I am indeed using Debian, and the test case doesn't fail on
the trunk, nor on Emacs 26.1 included in the distribution.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Wed, 30 Oct 2019 16:34:01 GMT) Full text and rfc822 format available.

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

From: Richard Copley <rcopley <at> gmail.com>
To: Roland Winkler <winkler <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Wed, 30 Oct 2019 16:32:30 +0000
[Message part 1 (text/plain, inline)]
On Tue, 29 Oct 2019 at 01:52, Roland Winkler <winkler <at> gnu.org> wrote:
> On Mon Oct 28 2019 Lars Ingebrigtsen wrote:
> > Do you have an example .bib file that can be used to reproduce this bug?
>
> I can, indeed, reproduce this with `emacs -Q', setting
> enable-local-variables to nil and then loading any BibTeX file.
>
> Yet it is not clear to me what is the proper solution for this.
>
> Currently, bibtex-mode makes bibtex-set-dialect an element of
> hack-local-variables-hook.  This hook is called only if
> enable-local-variables is non-nil.  Of course, bibtex-mode could
> call bibtex-set-dialect directly if enable-local-variables is nil.
> Yet I guess that enable-local-variables being nil may break more
> things if hack-local-variables-hook is not called.

Did you have something in mind? I don't see how it might break anything for
BibTeX mode. If it breaks something elsewhere, that is a separate bug.

> If nothing else, we could mention in the docstring of
> hack-local-variables-hook that this hook is not called if
> enable-local-variables is nil.

Perhaps, but it is clear from the existing docstring ("[...] run after
processing a file’s local variables specs"), in my opinion.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37957; Package emacs. (Wed, 30 Oct 2019 18:22:01 GMT) Full text and rfc822 format available.

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

From: "Roland Winkler" <winkler <at> gnu.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 37957 <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Wed, 30 Oct 2019 13:21:48 -0500
On Wed Oct 30 2019 Richard Copley wrote:
> On Tue, 29 Oct 2019 at 01:52, Roland Winkler <winkler <at> gnu.org> wrote:
> > Yet I guess that enable-local-variables being nil may break more
> > things if hack-local-variables-hook is not called.
> 
> Did you have something in mind? I don't see how it might break
> anything for BibTeX mode. If it breaks something elsewhere, that
> is a separate bug.

I was thinking of other packages using hack-local-variables-hook.
Yet I just checked that for the packages distributed with emacs,
this hook appears to be not overly popular.  So maybe my worries are
not justified.

> > If nothing else, we could mention in the docstring of
> > hack-local-variables-hook that this hook is not called if
> > enable-local-variables is nil.
> 
> Perhaps, but it is clear from the existing docstring ("[...] run after
> processing a file’s local variables specs"), in my opinion.

When I added bibtex-set-dialect to hack-local-variables-hook, I did
not even anticipate the existence of a user variable
enable-local-variables that could make this patch go wrong.  I see
no damage if this point gets mentioned in the docstring of
hack-local-variables-hook.

Roland




Reply sent to "Roland Winkler" <winkler <at> gnu.org>:
You have taken responsibility. (Wed, 02 Dec 2020 19:55:02 GMT) Full text and rfc822 format available.

Notification sent to Richard Copley <rcopley <at> gmail.com>:
bug acknowledged by developer. (Wed, 02 Dec 2020 19:55:02 GMT) Full text and rfc822 format available.

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

From: "Roland Winkler" <winkler <at> gnu.org>
To: Richard Copley <rcopley <at> gmail.com>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 37957-done <at> debbugs.gnu.org
Subject: Re: bug#37957: BibTeX dialect not set if local variables disabled
Date: Wed, 2 Dec 2020 13:54:00 -0600
Fixed with commit 40f42945ed1ee76c16ee4c58c7f37a412a3aa407.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 31 Dec 2020 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 115 days ago.

Previous Next


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