[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs script options
From: |
Sebastian Miele |
Subject: |
Re: Emacs script options |
Date: |
Tue, 21 Nov 2023 09:51:55 +0100 |
> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> Date: Mon, 2023-11-20 21:10 +0100
>
> On 2023-11-20 07:10, Sebastian Miele wrote:
>
>> But it has a problem with lexical binding. Consider:
>>
>> #!/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 I run it as a script, the output is "nil nil", i.e., the script
>> definitely does not run with lexical binding enabled. When I evaluate
>> it in a buffer, the output is "t t".
>
> 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.
Thank you for the additional investigation into and information about
the issue.
> Would you or Greg report that as a bug?
Done, https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67321.
- Re: Emacs script options, (continued)
- Re: Emacs script options, Jens Schmidt, 2023/11/19
- Re: Emacs script options, Jens Schmidt, 2023/11/19
- Re: Emacs script options, Greg Minshall, 2023/11/19
- Re: Emacs script options, Jens Schmidt, 2023/11/21
- Re: Emacs script options, Sebastian Miele, 2023/11/22
- Re: Emacs script options, Jens Schmidt, 2023/11/22
- Re: Emacs script options, Greg Minshall, 2023/11/23
- Re: Emacs script options, Jens Schmidt, 2023/11/26
- Re: Emacs script options, Sebastian Miele, 2023/11/20
- Re: Emacs script options, Jens Schmidt, 2023/11/20
- Re: Emacs script options,
Sebastian Miele <=