unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37957: BibTeX dialect not set if local variables disabled
@ 2019-10-28  9:44 Richard Copley
  2019-10-28 15:16 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Copley @ 2019-10-28  9:44 UTC (permalink / raw)
  To: 37957, winkler

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

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@gnu.org>
AuthorDate: Sat Jan 28 12:06:10 2012 -0600

lisp/textmodes/bibtex.el: allow bibtex-dialect as file-local variable
(Bug#10254)

[-- Attachment #2: Type: text/html, Size: 1279 bytes --]

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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-28  9:44 bug#37957: BibTeX dialect not set if local variables disabled Richard Copley
@ 2019-10-28 15:16 ` Lars Ingebrigtsen
       [not found]   ` <CAPM58og0EX6F9vpVfq4fnVK-QWevXYUccf5_W_QbTLZ=iGxDuQ@mail.gmail.com>
  2019-10-29  1:52   ` Roland Winkler
  0 siblings, 2 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-28 15:16 UTC (permalink / raw)
  To: Richard Copley; +Cc: 37957, winkler

Richard Copley <rcopley@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





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

* bug#37957: BibTeX dialect not set if local variables disabled
       [not found]   ` <CAPM58og0EX6F9vpVfq4fnVK-QWevXYUccf5_W_QbTLZ=iGxDuQ@mail.gmail.com>
@ 2019-10-28 16:21     ` Lars Ingebrigtsen
  2019-10-28 16:33       ` Richard Copley
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-28 16:21 UTC (permalink / raw)
  To: Richard Copley; +Cc: 37957

Richard Copley <rcopley@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





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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-28 16:21     ` Lars Ingebrigtsen
@ 2019-10-28 16:33       ` Richard Copley
  2019-10-28 16:42         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Copley @ 2019-10-28 16:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 37957

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

On Mon, 28 Oct 2019 at 16:21, Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Richard Copley <rcopley@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))"

[-- Attachment #2: Type: text/html, Size: 1128 bytes --]

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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-28 16:33       ` Richard Copley
@ 2019-10-28 16:42         ` Lars Ingebrigtsen
  2019-10-28 17:55           ` Richard Copley
  2019-10-28 18:54           ` Eli Zaretskii
  0 siblings, 2 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-28 16:42 UTC (permalink / raw)
  To: Richard Copley; +Cc: 37957

Richard Copley <rcopley@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





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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-28 16:42         ` Lars Ingebrigtsen
@ 2019-10-28 17:55           ` Richard Copley
  2019-10-29 11:24             ` Lars Ingebrigtsen
  2019-10-28 18:54           ` Eli Zaretskii
  1 sibling, 1 reply; 12+ messages in thread
From: Richard Copley @ 2019-10-28 17:55 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 37957

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

On Mon, 28 Oct 2019 at 16:42, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Richard Copley <rcopley@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

[-- Attachment #2: Type: text/html, Size: 1532 bytes --]

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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-28 16:42         ` Lars Ingebrigtsen
  2019-10-28 17:55           ` Richard Copley
@ 2019-10-28 18:54           ` Eli Zaretskii
  1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2019-10-28 18:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: rcopley, 37957

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Mon, 28 Oct 2019 17:42:37 +0100
> Cc: 37957@debbugs.gnu.org
> 
> Richard Copley <rcopley@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.





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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-28 15:16 ` Lars Ingebrigtsen
       [not found]   ` <CAPM58og0EX6F9vpVfq4fnVK-QWevXYUccf5_W_QbTLZ=iGxDuQ@mail.gmail.com>
@ 2019-10-29  1:52   ` Roland Winkler
  2019-10-30 16:32     ` Richard Copley
  1 sibling, 1 reply; 12+ messages in thread
From: Roland Winkler @ 2019-10-29  1:52 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Richard Copley, 37957

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





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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-28 17:55           ` Richard Copley
@ 2019-10-29 11:24             ` Lars Ingebrigtsen
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-29 11:24 UTC (permalink / raw)
  To: Richard Copley; +Cc: 37957

Richard Copley <rcopley@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





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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-29  1:52   ` Roland Winkler
@ 2019-10-30 16:32     ` Richard Copley
  2019-10-30 18:21       ` Roland Winkler
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Copley @ 2019-10-30 16:32 UTC (permalink / raw)
  To: Roland Winkler; +Cc: Lars Ingebrigtsen, 37957

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

On Tue, 29 Oct 2019 at 01:52, Roland Winkler <winkler@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.

[-- Attachment #2: Type: text/html, Size: 1429 bytes --]

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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-30 16:32     ` Richard Copley
@ 2019-10-30 18:21       ` Roland Winkler
  2020-12-02 19:54         ` Roland Winkler
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Winkler @ 2019-10-30 18:21 UTC (permalink / raw)
  To: Richard Copley; +Cc: Lars Ingebrigtsen, 37957

On Wed Oct 30 2019 Richard Copley wrote:
> On Tue, 29 Oct 2019 at 01:52, Roland Winkler <winkler@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





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

* bug#37957: BibTeX dialect not set if local variables disabled
  2019-10-30 18:21       ` Roland Winkler
@ 2020-12-02 19:54         ` Roland Winkler
  0 siblings, 0 replies; 12+ messages in thread
From: Roland Winkler @ 2020-12-02 19:54 UTC (permalink / raw)
  To: Richard Copley, Lars Ingebrigtsen, 37957-done

Fixed with commit 40f42945ed1ee76c16ee4c58c7f37a412a3aa407.





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

end of thread, other threads:[~2020-12-02 19:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28  9:44 bug#37957: BibTeX dialect not set if local variables disabled Richard Copley
2019-10-28 15:16 ` Lars Ingebrigtsen
     [not found]   ` <CAPM58og0EX6F9vpVfq4fnVK-QWevXYUccf5_W_QbTLZ=iGxDuQ@mail.gmail.com>
2019-10-28 16:21     ` Lars Ingebrigtsen
2019-10-28 16:33       ` Richard Copley
2019-10-28 16:42         ` Lars Ingebrigtsen
2019-10-28 17:55           ` Richard Copley
2019-10-29 11:24             ` Lars Ingebrigtsen
2019-10-28 18:54           ` Eli Zaretskii
2019-10-29  1:52   ` Roland Winkler
2019-10-30 16:32     ` Richard Copley
2019-10-30 18:21       ` Roland Winkler
2020-12-02 19:54         ` Roland Winkler

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).