From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthew Malcomson Newsgroups: gmane.emacs.bugs Subject: bug#62419: 28.2; Elisp let-bound buffer-local variable and kill-local-variable Date: Sun, 26 Mar 2023 16:01:22 +0100 Message-ID: <56FDA944-04A3-4993-93BE-3E3E0F1CD227@gmail.com> References: <19A857D6-D071-44DE-AF89-539A563FD782@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) 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="19157"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62419@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 26 17:02:26 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 1pgRt3-0004oN-UB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Mar 2023 17:02:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgRsj-0008NI-G8; Sun, 26 Mar 2023 11:02:05 -0400 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 1pgRsh-0008Mg-Aj for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2023 11:02:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pgRsg-0003xv-Kt for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2023 11:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pgRsg-00060y-21 for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2023 11:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthew Malcomson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Mar 2023 15:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62419 X-GNU-PR-Package: emacs Original-Received: via spool by 62419-submit@debbugs.gnu.org id=B62419.167984289223082 (code B ref 62419); Sun, 26 Mar 2023 15:02:02 +0000 Original-Received: (at 62419) by debbugs.gnu.org; 26 Mar 2023 15:01:32 +0000 Original-Received: from localhost ([127.0.0.1]:45681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgRsB-00060E-Uh for submit@debbugs.gnu.org; Sun, 26 Mar 2023 11:01:32 -0400 Original-Received: from mail-wm1-f47.google.com ([209.85.128.47]:42914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgRsA-000600-HU for 62419@debbugs.gnu.org; Sun, 26 Mar 2023 11:01:31 -0400 Original-Received: by mail-wm1-f47.google.com with SMTP id m6-20020a05600c3b0600b003ee6e324b19so3626578wms.1 for <62419@debbugs.gnu.org>; Sun, 26 Mar 2023 08:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679842884; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JbTYGRFp+nJ2xyM44imgHp6ov4HeWh9YgjhDC0q+Oyg=; b=hACl+wcklFJBPObc6gKPiYbdmFboM+m5t2BRisJi6oeicHbgce9nwLJ/2qE8H9Gg5e JSpTtkeoT3C31hcoIEVachtYUT/8UeDMRD2RakPzbWJjaOt52OuR5URQa9R5cMvHeErm gIzfhCsielM0BxkXUdjNwvHLOzQ6n6q/Ay5+T3ganXAvfLRqV+XGg1BK3HS2YnVSVQQ9 Pm1GnAcwYL2u8OMg95I/Jz2ZeXS7h5I98+768MNNOaXbaa2qNQbzmgIhGGTf0nFKcqjw Cygf9/7M4/He4P4zl9RmLVDnilIsvL/sjPbBUTUgH+5M5i1zvcKWW5VavzS+jUpPikNA efxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679842884; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JbTYGRFp+nJ2xyM44imgHp6ov4HeWh9YgjhDC0q+Oyg=; b=FWTrveE/90Lt4RGo4t2tdSXP2loldcj/gdXXjdawRR4xypsJ5iVOHxO2k2fPgzpl1l ZZKBKYU5Ypq6Igaj0zTqNhsWMjt486p4wc4A3MUns0TeiIWEDKT/greGxgUne4urE7QO ERMJfhi97bcg3NT+cdyPDM9qkbYMwzAQLkX3qMhcen17AjYdXVrNkoodaQsNSOuFkOK9 EaWzvr4WBqmuPDF/RBl0o2OPt4OdJMOMSE5vaciDDh73JFJ+e68+Q1UnP5gTjwDTEjrD Klwb2XGkQsOm4iSD4Cf/lJXBLql+bfj6/Pqe7k3eKfKATyAzJR+zq6SogE+h2rB5USE2 pZjA== X-Gm-Message-State: AO0yUKWCiXnC3AyrqpQVLC5Rry3vAyTINSLkL0wYlLQWo2oLgBpJVwrz v/6wSGb6f/HZfh/efg+Fe6JtsDpiSaQ+aw== X-Google-Smtp-Source: AK7set+EbR+gFkC9FeXkbyKeex2Sfwg+CXS5DfXsTAF/K//kYNxYNRRkZjCuS6tZ9oFGJCh1tC/P2g== X-Received: by 2002:a05:600c:214d:b0:3eb:39e7:3607 with SMTP id v13-20020a05600c214d00b003eb39e73607mr7116949wml.4.1679842884073; Sun, 26 Mar 2023 08:01:24 -0700 (PDT) Original-Received: from smtpclient.apple ([2a00:23c6:5484:ac01:18a8:8215:5cbb:57b9]) by smtp.gmail.com with ESMTPSA id o39-20020a05600c512700b003edddae1068sm5896694wms.9.2023.03.26.08.01.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Mar 2023 08:01:23 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3693.60.0.1.1) 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:258689 Archived-At: > On 26 Mar 2023, at 15:01, Stefan Monnier = wrote: >=20 >> (setq auto-fill-function 'local-symbol) >> (describe-variable 'auto-fill-function) >> ;; `auto-fill-function' is let-bound in the buffer scope >> (let ((auto-fill-function 'temp-symbol)) >> ;; Now there is no buffer-local variable for `auto-fill-function', = but the >> ;; `let' unwrapping info is still there. >> (kill-local-variable 'auto-fill-function) >> ;; Since the check in the emacs source is >> ;; a) Is there a buffer-local variable. >> ;; b) Is there a let-binding shadowing the current variable. >> ;; Then this `setq' sets the *global* variable. >> (setq auto-fill-function 'other-symbol)) >> ;; Exiting the `let' has special handling to avoid resetting a local = variable >> ;; when the local variable was `let' bound, which means that overall = the `setq' >> ;; set the global variable and the `let' has been lost. >=20 > AFAIK the behavior is "as intended": the `let` only affects *one* > binding, either the global one or the buffer-local one. >=20 Not going to push much on this since your suggested change to `newline` = would fix everything to me. But the part I think is strange is `setq` not creating a buffer-local = binding in this environment. (i.e. not to do with what `let` is affecting). The =E2=80=9Cspecial behaviour=E2=80=9D that a `setq` may act on a = global binding of an automatic buffer-local variable when inside a let = binding seems to me like the intention is to avoid =E2=80=9Cbypassing=E2=80= =9D a let on a global binding. I.e. currently the behaviour of `setq` on automatic buffer-local = variables is: - Outside `let`, always affect buffer-local (creating if = necessary) - In `let` of global binding, affect global binding. - In `let` of buffer-local binding, affect buffer-local - In `let` of buffer-local binding but where buffer-local value = has been killed, affect global value. I believe that last condition is strange and the behaviour of `setq` = would be more understandable without it. Especially since when viewed from the top-level (i.e. evaluate some lisp = which contains a `setq` of an automatic buffer-local variable and may or = may not have a `let`) the options are: - If `setq` is outside any `let`, it will affect a buffer-local = binding. - If `setq` is inside a `let` then it won=E2=80=99t be visible = once exited the `let` (i.e. it affects the binding that the `let` acted = on) - *Unless* the `let` was of a buffer-local binding and that = buffer-local binding was killed, in which case the `setq` will affect = the global binding. Either way, thanks for looking into this! Matthew