[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: |
Wed, 22 Nov 2023 19:17:12 +0100 |
> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> Date: Tue, 2023-11-21 22:13 +0100
>
> On 2023-11-20 02:19, Greg Minshall wrote:
>
>> no way, NO way near hack'y enough. :)
>
> I couldn't stand the fact that my hack was taken already plus
> that it is flawed, so I set off to extend it with a work-around
> for the lexical-binding issue.
>
> While there are surely other methods to achieve what below code
> does, supposedly also more stable ones, I wanted to go for
> brevity to keep the non-script overhead small:
>
> ------------------------- escript -------------------------
> #!/bin/sh
> : ; exec emacs --script "$0" -- "$@" #; -*- lexical-binding: t -*-
>
> ;; Work around `eval-buffer' not recognizing the lexical-binding
> ;; stanza when the comment containing it does not start at first
> ;; column (bug#67321).
> (unless (ignore-errors (funcall (let ((v t)) (lambda () v))))
> (with-current-buffer (car eval-buffer-list)
> (goto-char (point-min)) (search-forward "; -*-")
> (delete-region (point-min) (match-beginning 0))
> (eval-buffer)))
>
> ;; Script payload.
> (message "%S:%S" lexical-binding command-line-args-left)
>
> ;; Explicitly exit Emacs to not return from the second-level
> ;; `eval-buffer'.
> (kill-emacs 0)
>
> ;;; Local Variables:
> ;;; mode: emacs-lisp
> ;;; End:
> ------------------------- escript -------------------------
Thank you, I noted this trick for the future.
For the record, Gerd Möllemann mentioned yet another trick on
https://debbugs.gnu.org/67321:
> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Date: Wed, 2023-11-22 15:59 +0100
>
> cat >somefile <<EOF
> ; -*- lexical-binding: t -*-
> (message "%s" lexical-binding)
> EOF
> emacs --script somefile
Re: Emacs script options, Sebastian Miele, 2023/11/18
- Re: Emacs script options, Greg Minshall, 2023/11/18
- 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 <=
- 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, 2023/11/21