From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
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: Wed, 22 Nov 2023 15:59:15 +0100 [thread overview]
Message-ID: <m2msv5sukc.fsf@Pro.fritz.box> (raw)
In-Reply-To: <87cyw1gb9c.fsf@whxvd.name> (Sebastian Miele's message of "Wed, 22 Nov 2023 14:07:38 +0100")
Sebastian Miele <iota@whxvd.name> writes:
>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>> Date: Tue, 2023-11-21 11:46 +0100
>>
>>> #!/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))
>>
>> Can I ask why that idiom is used?
>
> The idiom allows arbitrary shell processing before, and possibly even
> after, actually running Emacs in the script.
>
> See https://github.com/doomemacs/doomemacs/blob/master/bin/doom for an
> example including both pre- and postprocessing, and lots of comments
> about what is done there, and why.
>
> Another case that recently popped up on emacs-devel is that it allows to
> insert the "--" for cleanly separating the script commandline options
> from options that Emacs may interpret, see
> https://lists.gnu.org/archive/html/emacs-devel/2023-11/msg00896.html.
>
> I do not know anymore why I considered the trick in the past. I do not
> want to spend the time to look into my scripts to find that bits that
> would become cumbersome without such tricks. Because of the problem
> with lexical-binding not being picked up, and because I, for now, have
> the luxury of only using Linux, I can use another trick. But being able
> to mangle the command line of Emacs before running Emacs definitely is a
> useful thing. The portable alternative would be to have one separate
> (shell) wrapper around every Emacs script that needs such mangling.
Thanks, Sebastian. I got the trick, though it took me a minute. Clever,
clever :-).
TBH, I don't see a good reason why that should be used instead of the
much simpler
cat >somefile <<EOF
; -*- lexical-binding: t -*-
(message "%s" lexical-binding)
EOF
emacs --script somefile
So, I personally would not like to spend the time to change Emacs,
sorry.
next prev parent reply other threads:[~2023-11-22 14:59 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 [this message]
2023-11-22 18:10 ` Sebastian Miele
2023-11-22 19:18 ` Gerd Möllmann
2023-11-21 12:43 ` Eli Zaretskii
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=m2msv5sukc.fsf@Pro.fritz.box \
--to=gerd.moellmann@gmail.com \
--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.