GNU bug report logs - #70779
[PATCH] Emacs 30 and warning about missing lexical-binding declaration

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Sun, 5 May 2024 11:05:01 UTC

Severity: normal

Tags: patch

Done: Arash Esbati <arash <at> gnu.org>

To reply to this bug, email your comments to 70779 AT debbugs.gnu.org.
There is no need to reopen the bug first.

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-auctex <at> gnu.org:
bug#70779; Package auctex. (Sun, 05 May 2024 11:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arash Esbati <arash <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Sun, 05 May 2024 11:05:02 GMT) Full text and rfc822 format available.

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

From: Arash Esbati <arash <at> gnu.org>
To: "auctex-bugs" <bug-auctex <at> gnu.org>
Subject: [PATCH] Emacs 30 and warning about missing lexical-binding declaration
Date: Sun, 05 May 2024 13:03:26 +0200
Hi all,

Emacs 30 now emits a warning when it loads an .el file without the
lexical-binding cookie (commits 81bad84a6 and 1121f17d7c).  This is the
entry from Emacs NEWS:

    *** Warn about missing 'lexical-binding' directive.
    The compiler now warns if an Elisp file lacks the standard
    '-*- lexical-binding: ... -*-' cookie on the first line.
    This line typically looks something like

        ;;; My little pony mode  -*- lexical-binding: t -*-

    It is needed to inform the compiler about which dialect of ELisp
    your code is using: the modern dialect with lexical binding or
    the old dialect with only dynamic binding.

    Lexical binding avoids some name conflicts and allows the compiler to
    detect more mistakes and generate more efficient code, so it is
    recommended.  For how to adapt your code to lexical binding, see the
    manual section "(elisp) Converting to Lexical Binding".

    If your code cannot be converted to lexical binding, you can insert
    the line

        ;;; -*- lexical-binding: nil -*-

    first in the file to declare that it uses the old dialect.

This change affects all auto-parsed style files when AUCTeX loads them.
I suggest the following change to `TeX-auto-store' in tex.el:

--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index cda1d7f6..32cfd21e 100644
--- a/tex.el
+++ b/tex.el
@@ -4267,6 +4267,8 @@ If TEX is a directory, generate style files for all files in the directory."
         (TeX-unload-style style)
         (with-current-buffer (generate-new-buffer file)
           (erase-buffer)
+          (insert (concat ";;" (make-string 40 ?\s)
+                          "-*- lexical-binding: t; -*-\n\n"))
           (insert "(TeX-add-style-hook\n \""
                   style "\"\n (lambda ()")
           (unless (string= tex-cmd-opts "")
--8<---------------cut here---------------end--------------->8---

Any comments welcome.

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#70779; Package auctex. (Sun, 05 May 2024 12:44:02 GMT) Full text and rfc822 format available.

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

From: Arash Esbati <arash <at> gnu.org>
To: 70779 <at> debbugs.gnu.org
Subject: Re: bug#70779: [PATCH] Emacs 30 and warning about missing
 lexical-binding declaration
Date: Sun, 05 May 2024 14:42:51 +0200
Arash Esbati <arash <at> gnu.org> writes:

> I suggest the following change to `TeX-auto-store' in tex.el:

Which can be reduced to:

--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index cda1d7f6..30f80c7e 100644
--- a/tex.el
+++ b/tex.el
@@ -4267,6 +4267,7 @@ If TEX is a directory, generate style files for all files in the directory."
         (TeX-unload-style style)
         (with-current-buffer (generate-new-buffer file)
           (erase-buffer)
+          (insert ";;" (make-string 40 ?\s) "-*- lexical-binding: t; -*-\n\n")
           (insert "(TeX-add-style-hook\n \""
                   style "\"\n (lambda ()")
           (unless (string= tex-cmd-opts "")
--8<---------------cut here---------------end--------------->8---

Any comments welcome.

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#70779; Package auctex. (Mon, 06 May 2024 05:28:01 GMT) Full text and rfc822 format available.

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

From: Arash Esbati <arash <at> gnu.org>
To: 70779 <at> debbugs.gnu.org
Subject: Re: bug#70779: [PATCH] Emacs 30 and warning about missing
 lexical-binding declaration
Date: Mon, 06 May 2024 07:27:26 +0200
Arash Esbati <arash <at> gnu.org> writes:

> Arash Esbati <arash <at> gnu.org> writes:
>
>> I suggest the following change to `TeX-auto-store' in tex.el:
>
> Which can be reduced to:
>
> diff --git a/tex.el b/tex.el
> index cda1d7f6..30f80c7e 100644
> --- a/tex.el
> +++ b/tex.el
> @@ -4267,6 +4267,7 @@ If TEX is a directory, generate style files for all files in the directory."
>          (TeX-unload-style style)
>          (with-current-buffer (generate-new-buffer file)
>            (erase-buffer)
> +          (insert ";;" (make-string 40 ?\s) "-*- lexical-binding: t; -*-\n\n")
>            (insert "(TeX-add-style-hook\n \""
>                    style "\"\n (lambda ()")
>            (unless (string= tex-cmd-opts "")

That change in Emacs in reverted (d51de0c5d9), but still, I think we can
turn lexical-binding on in auto-parsed style files as well.  I will
install this in a day or two if there are no other comments.

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#70779; Package auctex. (Mon, 06 May 2024 06:57:01 GMT) Full text and rfc822 format available.

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

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Arash Esbati <arash <at> gnu.org>
Cc: 70779 <at> debbugs.gnu.org
Subject: Re: bug#70779: [PATCH] Emacs 30 and warning about missing
 lexical-binding declaration
Date: Mon, 06 May 2024 15:56:11 +0900
Hi Arash,

>>>>> Arash Esbati <arash <at> gnu.org> writes:

> That change in Emacs in reverted (d51de0c5d9), but still, I think we can
> turn lexical-binding on in auto-parsed style files as well.  I will
> install this in a day or two if there are no other comments.

I'm not actually against your proposal, but why do we need 40 spaces here?

>> +          (insert ";;" (make-string 40 ?\s) "-*- lexical-binding: t; -*-\n\n")
                           ^^^^^^^^^^^^^^^^^^^^

Best regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW




Information forwarded to bug-auctex <at> gnu.org:
bug#70779; Package auctex. (Mon, 06 May 2024 11:58:02 GMT) Full text and rfc822 format available.

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

From: Arash Esbati <arash <at> gnu.org>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 70779 <at> debbugs.gnu.org
Subject: Re: bug#70779: [PATCH] Emacs 30 and warning about missing
 lexical-binding declaration
Date: Mon, 06 May 2024 13:56:47 +0200
Hi Keita,

Ikumi Keita <ikumi <at> ikumi.que.jp> writes:

> I'm not actually against your proposal, but why do we need 40 spaces here?
>
>>> +          (insert ";;" (make-string 40 ?\s) "-*- lexical-binding: t; -*-\n\n")

Thanks for your response; we don't really need them, it was driven by my
habit of having prop-lines justified right.  A simple

  ;; -*- lexical-binding: t;

looked odd to me.  What do you think is appropriate?  I don't have a
strong opinion on this (and actually, I think I've found another more
serious bug while looking at the auto-generated file which I will
report.)

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#70779; Package auctex. (Mon, 06 May 2024 12:36:02 GMT) Full text and rfc822 format available.

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

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Arash Esbati <arash <at> gnu.org>
Cc: 70779 <at> debbugs.gnu.org
Subject: Re: bug#70779: [PATCH] Emacs 30 and warning about missing
 lexical-binding declaration
Date: Mon, 06 May 2024 21:34:46 +0900
Hi Arash,

>>>>> Arash Esbati <arash <at> gnu.org> writes:
> Thanks for your response; we don't really need them, it was driven by my
> habit of having prop-lines justified right.  A simple

>   ;; -*- lexical-binding: t;

> looked odd to me.

Hmm, it doesn't to me. :-)

> What do you think is appropriate?

I think these auto files are generally not intended for human eyes. So
we wouldn't have to care much about the justtification of the prop line.
I vote for simpler form.

Best,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW




Reply sent to Arash Esbati <arash <at> gnu.org>:
You have taken responsibility. (Mon, 06 May 2024 15:04:02 GMT) Full text and rfc822 format available.

Notification sent to Arash Esbati <arash <at> gnu.org>:
bug acknowledged by developer. (Mon, 06 May 2024 15:04:02 GMT) Full text and rfc822 format available.

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

From: Arash Esbati <arash <at> gnu.org>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 70779-done <at> debbugs.gnu.org
Subject: Re: bug#70779: [PATCH] Emacs 30 and warning about missing
 lexical-binding declaration
Date: Mon, 06 May 2024 17:02:46 +0200
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:

> I think these auto files are generally not intended for human eyes. So
> we wouldn't have to care much about the justtification of the prop line.
> I vote for simpler form.

Yes, Sir ;-)  I installed the simple version, closing.

Best, Arash




This bug report was last modified 26 days ago.

Previous Next


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