From: Eli Zaretskii <eliz@gnu.org>
To: Sebastian Miele <iota@whxvd.name>
Cc: 67321@debbugs.gnu.org
Subject: bug#67321: 29.1.90; Different parsing rules for -*- lexical-binding:t; -*- in different circumstances
Date: Tue, 21 Nov 2023 14:43:12 +0200 [thread overview]
Message-ID: <834jhfi8f3.fsf@gnu.org> (raw)
In-Reply-To: <8734wzts37.fsf@whxvd.name> (message from Sebastian Miele on Tue, 21 Nov 2023 09:16:13 +0100)
merge 67321 64272
thanks
> From: Sebastian Miele <iota@whxvd.name>
> Date: Tue, 21 Nov 2023 09:16:13 +0100
>
> Put the following into a file named, e.g., ‘test-script’, and ‘chmod +x’
> it.
>
> #!/bin/sh
> : ; exec emacs --script "$0" -- "$@" #; -*- lexical-binding: t; mode: emacs-lisp; -*-
>
> (defmacro lexical-binding-p ()
> '(let* ((x t)
> (f (lambda () x))
> (x nil))
> (funcall f)))
>
> (message "%s %s" lexical-binding (lexical-binding-p))
>
> When the script is run, the output is "nil nil", signifying that lexical
> binding is not enabled.
>
> Then find the file in an interactive Emacs session, and interactively
> evaluate (C-x C-e) the two expressions. The output now is "t t", i.e.,
> lexical binding is in use.
>
> https://lists.gnu.org/archive/html/emacs-devel/2023-11/msg01041.html
> contains more details, which are repeated here:
>
> > From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> > Date: Mon, 2023-11-20 21:10 +0100
> >
> > I tried byte-compiling something similar yesterday, which also
> > indicated that the byte-compiler compiles with lexical bindings. Only
> > the scripting machinery sees dynamical bindings.
> >
> > […] It seems that the scripting machinery expects a semicolon in the
> > very first column, without that the lexical-binding line is not
> > recognized. Even a space before the semicolon breaks the recognition.
> >
> > The problem is in function `lisp_file_lexically_bound_p' from lread.c,
> > which is indeed much more strict in its recognition of the -*- ... -*-
> > stanza than the functions `set-auto-mode-1' and
> > `hack-local-variables-prop-line' from files.el. The Emacs manual
> > ((emacs) Specifying File Variables) only mentions that the stanza has
> > to be in the first line (or the second one if the first is taken by a
> > she-bang), without any restriction where the comment has to start.
>
> ((emacs) Specifying File Variables) states no restrictions on what must
> (not) precede or follow a "-*- … -*-" on the first or second line of a
> file.
>
> Expected: At least consistent behavior. Ideally, lexical binding
> should be enabled in all cases.
There's more here than meets the eye, see bug#64272.
prev parent reply other threads:[~2023-11-21 12:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 8:16 bug#67321: 29.1.90; Different parsing rules for -*- lexical-binding:t; -*- in different circumstances Sebastian Miele
2023-11-21 10:06 ` Andreas Schwab
2023-11-21 11:07 ` Sebastian Miele
2023-11-21 10:46 ` Gerd Möllmann
2023-11-22 13:07 ` Sebastian Miele
2023-11-22 14:59 ` Gerd Möllmann
2023-11-22 18:10 ` Sebastian Miele
2023-11-22 19:18 ` Gerd Möllmann
2023-11-21 12:43 ` Eli Zaretskii [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=834jhfi8f3.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=67321@debbugs.gnu.org \
--cc=iota@whxvd.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.