From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#67321: 29.1.90; Different parsing rules for -*- lexical-binding:t; -*- in different circumstances Date: Tue, 21 Nov 2023 11:46:31 +0100 Message-ID: References: <8734wzts37.fsf@whxvd.name> 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="39926"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67321@debbugs.gnu.org To: Sebastian Miele Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 21 11:47:14 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1r5OHi-000ADC-Kd for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Nov 2023 11:47:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5OHW-0004qV-K1; Tue, 21 Nov 2023 05:47:02 -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 1r5OHU-0004mN-8f for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2023 05:47:00 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5OHU-00042d-08 for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2023 05:47:00 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r5OHW-0003zn-6r for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2023 05:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Nov 2023 10:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67321 X-GNU-PR-Package: emacs Original-Received: via spool by 67321-submit@debbugs.gnu.org id=B67321.170056360715339 (code B ref 67321); Tue, 21 Nov 2023 10:47:02 +0000 Original-Received: (at 67321) by debbugs.gnu.org; 21 Nov 2023 10:46:47 +0000 Original-Received: from localhost ([127.0.0.1]:55233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5OHH-0003zL-2A for submit@debbugs.gnu.org; Tue, 21 Nov 2023 05:46:47 -0500 Original-Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]:52620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5OHC-0003z5-G0 for 67321@debbugs.gnu.org; Tue, 21 Nov 2023 05:46:45 -0500 Original-Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-507bd64814fso7561894e87.1 for <67321@debbugs.gnu.org>; Tue, 21 Nov 2023 02:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700563593; x=1701168393; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w/VEUMJo+rDxvtdO/CCheDgcVN2VBJorID9WScuoriw=; b=fAtuG/ipJm8buqiBAjVfLjlwrpZ5qafGv8/HCLIsXWd687Zu3uoXpdE5GF30YPNFNE VIp5jRpnhvznuPIu3q2QsU0PjLouV6QPctODaC0Gsq2mGNLI8Zpq4V/qk7f1UrFimhpO HUJ9tsir2HXRs51UcOmhoxJ/kc1gK6ybrtmin4StpHnQzc0N0yvtaGZRLHIiL+6mAeYS fPN5ZqnkrtvgtYIqH9CFtce8/Qj8+3k5yjK+hIfCIJlSeLssG+pRUlCG+MDStSu5vSYO X71enb+F2cSljiEJ14otsRGS69zhh4tXtjUl6aMMSOTqIxvnDmhpOXFMG5+FvCjpMm7p BKrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700563593; x=1701168393; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=w/VEUMJo+rDxvtdO/CCheDgcVN2VBJorID9WScuoriw=; b=ojx7UMZ4juwLMy4v1NFYRN2rw2TuZdJ2FrxQlOW44Vx8chh5PZXkL5B5hwx4o10qRh 0Y/A71ak+M3ZFHyjcqknE6udih4hlSCKSkEjBb1E6cI+K9hBeXxYyH5QZDLwWOWGBVBm QwmNUgIuy2IKC/O9eoo9SsFCGTMRO9p/o553uYdrk6NhYNsVVYZ99gtEBQryyPRg7CEg vckYv5luLouf+kd/IE44GUgCZuSGaXiQuEAVtM/l4Z9N8nbd1E7CFIWBnGVtAp+a/5oI WCu9Qli+OQ7Vm5tisPm9EPFeTmT6rfgCwMWAVy5YqsjZtTn85LGHQMoibRCOeplObggS urRQ== X-Gm-Message-State: AOJu0YyPFHvhYhYBpQ7QCepKj/5eAIYf3m/GLv6FTpyKDGujpb0AMbgI i1g+QJVHRXMJ2pviniA5qCjsS0lgTHs= X-Google-Smtp-Source: AGHT+IGYV2slhfkZZZ/cCkNbWu5HcExTb0T4UtXuBPkTIa/6LVOuUyhPsDo0UjrSb4JygKk1HzQu8Q== X-Received: by 2002:ac2:531a:0:b0:50a:6f8a:6461 with SMTP id c26-20020ac2531a000000b0050a6f8a6461mr7200101lfh.58.1700563592980; Tue, 21 Nov 2023 02:46:32 -0800 (PST) Original-Received: from Pro.fritz.box (p4fe3a849.dip0.t-ipconnect.de. [79.227.168.73]) by smtp.gmail.com with ESMTPSA id kk17-20020a170907767100b0099cce6f7d50sm5091606ejc.64.2023.11.21.02.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:46:32 -0800 (PST) In-Reply-To: <8734wzts37.fsf@whxvd.name> (Sebastian Miele's message of "Tue, 21 Nov 2023 09:16:13 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274706 Archived-At: Sebastian Miele writes: > Put the following into a file named, e.g., =E2=80=98test-script=E2=80=99,= and =E2=80=98chmod +x=E2=80=99 > it. > > #!/bin/sh > : ; exec emacs --script "$0" -- "$@" #; -*- lexical-binding: t; mode: e= macs-lisp; -*- > > (defmacro lexical-binding-p () > '(let* ((x t) > (f (lambda () x)) > (x nil)) > (funcall f))) > > (message "%s %s" lexical-binding (lexical-binding-p)) > > When the script is run, the output is "nil nil", signifying that lexical > binding is not enabled. > > Then find the file in an interactive Emacs session, and interactively > evaluate (C-x C-e) the two expressions. The output now is "t t", i.e., > lexical binding is in use. > > https://lists.gnu.org/archive/html/emacs-devel/2023-11/msg01041.html > contains more details, which are repeated here: > >> From: Jens Schmidt >> Date: Mon, 2023-11-20 21:10 +0100 >> >> 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. >> >> [=E2=80=A6] It seems that the scripting machinery expects a semicolon i= n 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. > > ((emacs) Specifying File Variables) states no restrictions on what must > (not) precede or follow a "-*- =E2=80=A6 -*-" on the first or second line= of a > file. > > Expected: At least consistent behavior. Ideally, lexical binding > should be enabled in all cases. > > In GNU Emacs 29.1.90 (build 1, x86_64-pc-linux-gnu, GTK+ Version Same in master, BTW, and everything you write is correct, I think. I guess one could recognize the ": ; exec" idiom (do nothing successfully and then exec emacs) in command-line--load-script, but that feels really strange and brittle. Can I ask why that idiom is used?