From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62419: 28.2; Elisp let-bound buffer-local variable and kill-local-variable Date: Sun, 26 Mar 2023 11:16:44 -0400 Message-ID: References: <19A857D6-D071-44DE-AF89-539A563FD782@gmail.com> <56FDA944-04A3-4993-93BE-3E3E0F1CD227@gmail.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35886"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62419@debbugs.gnu.org To: Matthew Malcomson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 26 17:17:41 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 1pgS7o-00092b-I6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Mar 2023 17:17:40 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgS7Y-0003jo-Ha; Sun, 26 Mar 2023 11:17:24 -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 1pgS7I-0003gc-7V for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2023 11:17:13 -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 1pgS7C-0007Lr-Nc for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2023 11:17:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pgS7C-0006O5-9p for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2023 11:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Mar 2023 15:17: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.167984381524536 (code B ref 62419); Sun, 26 Mar 2023 15:17:02 +0000 Original-Received: (at 62419) by debbugs.gnu.org; 26 Mar 2023 15:16:55 +0000 Original-Received: from localhost ([127.0.0.1]:45702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgS74-0006Ng-MD for submit@debbugs.gnu.org; Sun, 26 Mar 2023 11:16:55 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgS73-0006NQ-0p for 62419@debbugs.gnu.org; Sun, 26 Mar 2023 11:16:53 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A006980D1A; Sun, 26 Mar 2023 11:16:47 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 186AC80937; Sun, 26 Mar 2023 11:16:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1679843806; bh=k0Fs+dqX6KEhDAHwb6kUX0fnF2Ew+dr6niauL0PndO4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ZzVMlJS8HNeq+tGtsp3rCVe0PDLhEhgqCnTbDRR3roANnDWqn4x+764GWTf/q1dlp FAxhAfqFvzKPGy2ey3iuQdcpXRA9SgbotI8h6y3lgtXUmQ23oDINefoKcPlEUHWNSi 6+zrySm4gZHTmrEzfEKgGCJvn9WgA8s1Jr8n7nCpdAannSHOr/g8alJxos0L9D9vBg CZRuGKkRJU3nhd0SNADxkwPpiY89/zxMbwMH83MXrEtHnSpD7X0WSOb21l6noablWy 27pViljFkMmhYXitMOE+maQEWJmIh/N/JvcVL7JxdHmhBSL9EggCW2ipacYqS2lnJY sHMMsLUwGh27w== Original-Received: from pastel (unknown [216.154.34.24]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E49991201C8; Sun, 26 Mar 2023 11:16:45 -0400 (EDT) In-Reply-To: <56FDA944-04A3-4993-93BE-3E3E0F1CD227@gmail.com> (Matthew Malcomson's message of "Sun, 26 Mar 2023 16:01:22 +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:258693 Archived-At: >>> (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. >> >> AFAIK the behavior is "as intended": the `let` only affects *one* >> binding, either the global one or the buffer-local one. >> > > 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. Hmm... maybe you're right that the (setq auto-fill-function 'other-symbol) shouldn't set the global variable but the local one. It might be a bug in how we check whether there's a let-binding that should make us refrain from obeying the "automatically set buffer-locally". Good point. I'll have to take a closer look. > 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. Agreed. Stefan