From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jens Schmidt Newsgroups: gmane.emacs.devel Subject: Re: Emacs script options Date: Mon, 20 Nov 2023 21:10:35 +0100 Message-ID: <208d9b6b-af64-432b-bc1d-f57e00ec0801@vodafonemail.de> References: <1325582.1700277236@archlinux> <8734x2zwnc.fsf@whxvd.name> <7953.1700336960@archlinux> <24ea16b3-e3e7-457b-99b9-3f3805de3f66@vodafonemail.de> <87v89xx83i.fsf@whxvd.name> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7856"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Greg Minshall , emacs-devel@gnu.org To: Sebastian Miele Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 20 21:11:51 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 1r5AcZ-0001sJ-Kg for ged-emacs-devel@m.gmane-mx.org; Mon, 20 Nov 2023 21:11:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Abk-0001lw-CI; Mon, 20 Nov 2023 15:11:00 -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 1r5Abi-0001l0-RT for emacs-devel@gnu.org; Mon, 20 Nov 2023 15:10:58 -0500 Original-Received: from mr5.vodafonemail.de ([145.253.228.165]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Abg-0002p0-AC for emacs-devel@gnu.org; Mon, 20 Nov 2023 15:10:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-mb-mr2-23sep; t=1700511054; bh=HTMnjCbIF7PIpzsMwIR2sldZe9JQZoFBUL6KKvfHNRQ=; h=Message-ID:Date:User-Agent:Subject:Content-Language:To:References: From:In-Reply-To:Content-Type:From; b=l+/9a3cuwwIqS3aN3rj35nmpKqmZreVPfM0p3N1AFRYmgVnt7s/med7ttotLQ7iE0 VyHKm+7dEB/3Q+X7mNTDb3blX2gGLwA2Oda6gwMm3NVdbvOOyF1uSWyrdVnjRV4WHS RflkOXglx9cvm/fIuTXkIjOA95CBgBT21vjR23dY= Original-Received: from smtp.vodafone.de (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mr5.vodafonemail.de (Postfix) with ESMTPS id 4SYzCf1SB8z1yFC; Mon, 20 Nov 2023 20:10:54 +0000 (UTC) Original-Received: from [192.168.178.41] (port-92-196-72-214.dynamic.as20676.net [92.196.72.214]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 4SYzCR59fzzKm4T; Mon, 20 Nov 2023 20:10:40 +0000 (UTC) Content-Language: de-DE-frami, en-US In-Reply-To: <87v89xx83i.fsf@whxvd.name> X-purgate-type: clean X-purgate: clean X-purgate-size: 2043 X-purgate-ID: 155817::1700511050-D8FF358E-1EFE2C8A/0/0 Received-SPF: pass client-ip=145.253.228.165; envelope-from=jschmidt4gnu@vodafonemail.de; helo=mr5.vodafonemail.de 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, RCVD_IN_MSPIKE_H2=-0.001, 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:313072 Archived-At: On 2023-11-20 07:10, Sebastian Miele wrote: > This is the trick that Doom Emacs employs, see > https://github.com/doomemacs/doomemacs/blob/master/bin/doom. Aw, I was afraid that somebody might have code-golfed that already. > 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. > When I discovered the problem some while ago, I wanted to report it as > an issue to Doom Emacs, but the bars for reporting issues to that > specific project were set to high for me to actually go through the > process. > > But maybe it should be reported as an Emacs bug? I think chances are good that this gets accepted. 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. Would you or Greg report that as a bug?