From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sebastian Miele Newsgroups: gmane.emacs.devel Subject: Re: Emacs script options Date: Wed, 22 Nov 2023 19:17:12 +0100 Message-ID: <874jhdfxxp.fsf@whxvd.name> References: <1325582.1700277236@archlinux> <8734x2zwnc.fsf@whxvd.name> <7953.1700336960@archlinux> <24ea16b3-e3e7-457b-99b9-3f3805de3f66@vodafonemail.de> <58266.1700443175@archlinux> <5eac9978-270e-40b2-8272-dabb29ec5daa@vodafonemail.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7377"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Greg Minshall , emacs-devel@gnu.org To: Jens Schmidt Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 22 19:25:56 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r5rv8-0001h3-Ht for ged-emacs-devel@m.gmane-mx.org; Wed, 22 Nov 2023 19:25:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5ruJ-0002px-S5; Wed, 22 Nov 2023 13:25:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5ruH-0002pX-Bs for emacs-devel@gnu.org; Wed, 22 Nov 2023 13:25:01 -0500 Original-Received: from mout-p-202.mailbox.org ([80.241.56.172]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1r5ruE-0003DO-R0 for emacs-devel@gnu.org; Wed, 22 Nov 2023 13:25:01 -0500 Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Sb8mN1D44z9t00; Wed, 22 Nov 2023 19:24:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whxvd.name; s=MBO0001; t=1700677492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7/AqN81i/f+vtuNp279LQl/UVJSDA/hn91G8Bgeo8JY=; b=hnFVdlTQ/0tfznDzaH8bdbmNdcRnoyGCA/pRwtRI7WEnlpPgO8iJyJjbEzsOKpBKekde6F 87n7qy5+9PKpNu/YH61+rYxuqhHXkkH1R1krw8WVzBlCi9MXrbdjUw4UwFJekoP01DR8td 9qzVQCfUe+M9qnyU/TPlIpoqU3xlCv14aXA1ZgjgZ+U9w5MbcN6LcJawXFVErZ3B5wtM0v e4Fx5jqpHUmzVXC7rsuFB4n2/F4kyaZTz2Nm8BGCVHWT7ouOvnn/MM11RarZz6fvvko1rj tuhoIUFgWjTqcxwvuASqVHw+mUN9XSvPNVYGDYtyKA7Mu6lLc2AFkciDSrUG7Q== In-reply-to: <5eac9978-270e-40b2-8272-dabb29ec5daa@vodafonemail.de> X-Rspamd-Queue-Id: 4Sb8mN1D44z9t00 Received-SPF: pass client-ip=80.241.56.172; envelope-from=iota@whxvd.name; helo=mout-p-202.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:313132 Archived-At: > From: Jens Schmidt > 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=C3=B6llemann mentioned yet another trick on https://debbugs.gnu.org/67321: > From: Gerd M=C3=B6llmann > Date: Wed, 2023-11-22 15:59 +0100 > > cat >somefile < ; -*- lexical-binding: t -*- > (message "%s" lexical-binding) > EOF > emacs --script somefile