From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#65209: 30.0.50; Unexpected behaviour of setq-local Date: Tue, 22 Aug 2023 05:09:44 +0200 Message-ID: <87wmxnojrb.fsf@web.de> References: <87msyu2tmm.fsf@web.de> <80D7C281-C3DD-4DCA-9B14-1569E849CBC7@gmail.com> <87wmxqqq7d.fsf@web.de> <83350exl6h.fsf@gnu.org> 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="40084"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: gerd.moellmann@gmail.com, 65209@debbugs.gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 22 05:11:21 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 1qYHnc-000AHI-HG for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Aug 2023 05:11:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYHnK-0004Qe-GR; Mon, 21 Aug 2023 23:11:02 -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 1qYHnI-0004Q2-98 for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2023 23:11:00 -0400 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 1qYHnI-0008U7-0D for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2023 23:11:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qYHnK-0007Qm-GU for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2023 23:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Aug 2023 03:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65209 X-GNU-PR-Package: emacs Original-Received: via spool by 65209-submit@debbugs.gnu.org id=B65209.169267380228472 (code B ref 65209); Tue, 22 Aug 2023 03:11:02 +0000 Original-Received: (at 65209) by debbugs.gnu.org; 22 Aug 2023 03:10:02 +0000 Original-Received: from localhost ([127.0.0.1]:58207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYHmL-0007P6-BL for submit@debbugs.gnu.org; Mon, 21 Aug 2023 23:10:01 -0400 Original-Received: from mout.web.de ([212.227.17.11]:40853) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYHmI-0007Oi-BQ for 65209@debbugs.gnu.org; Mon, 21 Aug 2023 23:09:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1692673785; x=1693278585; i=michael_heerdegen@web.de; bh=Cp5Crbrpi9f1KA2GESOTfLbJBEkZB+rsWycYhby23f8=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=nJkm8nZOeR10uRhPo8/oOtptHARHebhV4WHpLC4hke/12vUyefjfFa0+8p9ybSkTVCAHNc0 FRKTc0rNPt1BKDDrP5QQ50nReNqpCn4F3E86Aut0Z2gU0iVhARavp7+tupGqUVaDtv8s+gIbe gbWbTxGvDRlN41M6YKLMTnCjD+fRimHJUWW7qK1g156Or5YXQOGfBs8EHepTh9gxpBuXZ0M2Q 4Gjd2WsYfe162sjnuRl4dSvCw+onFoPGo/22JqQjvBdcZ3ryKhRzRKNloR85Wblv0NEYi+2Hl Fl5OoCpmNQPXPa7pzt3XS26XR/SfI3h4Om7l7PcDJcrAktoSWkgA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from drachen.dragon ([84.60.174.218]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Ma0Tu-1qBEZJ1kFY-00Vw8Q; Tue, 22 Aug 2023 05:09:45 +0200 In-Reply-To: <83350exl6h.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 20 Aug 2023 09:49:42 +0300") X-Provags-ID: V03:K1:k9M+aJgCLynklK0EQLyHwVGFp7CuTnJz/1wIvREAgt59kFu6zfE dBoGGSEVgAbivdLVu6xRtdHOS8Kb5TqhyHbpuITyi+8ne2WQH6J0/fwajMy3fb/A50+9vPt p6ezOEPfR4agneE73bUjxPKdRrjeVJI1FFejpBAwUn/vuuN9ondQOGvaovXkCzVgNiCLqAw 4tAtsSqBZhaujs7lAwVJQ== UI-OutboundReport: notjunk:1;M01:P0:WG8LnhyIdm4=;eQUddKLYktKpAp5IDgk8N0DSQcj BTSEoaR9VrN4/oOzgCpp+KP0U6C3Pqyj2ElzyJBvUKeNxrsuxt22XcmzZeRNrse495jtc0JtY 7wWzGozgw7zZx1EhjzMY3zQ86xPyBiO4oYt7ZRkzkDFILErjim6D7L4kI0BHU56kv2SH/Q7Sd /TpJwHcC88Yn8qAjFxYbTQTniS0SkjJn3OVLxRvOB+l/Q/TFWJ8HhkYfnAi+qmtnwFJPzN8s3 UehXmdf6CKKFmNpbPoGdiH+B0chXNyvKYz1ZL+Y/H+v5KlDdIcUgSoDa2fFiVmura0NTbCc4I Td58m6s70MJhsSijEuES1qdqUdxJZgtnUG1nyRRuh6wMpETKwJqL+Z+f2bRAVUm47OkgJUJDU 0OtXBv+tlCC65KSf3GdyxWPNEDl+bRYZcJi4ymARyXah4NN1DfUOT4J9DJCfYdxLT50wArAt4 J8wbd1nxEJjqIcl0I78NatZSTbev6cgj4hbLHMRIJQlDqE4Z18u83NCHzihYjC3WP8HC8opU8 en7kiWiyd3ctXHy18SlGmXFIe8HpqgTFkq+8JHyfoksbEqtg9GysBKN8Y4FEh6Dk2EC2MuPe/ rYwy2Aps0/AqpRzGjQKGM+Q01d0kq1LLyOkVYmq2PjVy36zHWQfH28JaF4myHkOzzdf3N646V bPegpn7L6ztUlE0aN1eab6kZXSnhUlu1VESiSVtXVra6cV/pVpq2AueNmEbE7f9P3MC1QMYRv cCnhitSCNZQ0kfffE3zGsB3AqwkqMPPkfwTCHQTZr2xB4+Pmd4SrseDpWxV/B1JGBSB0Mh+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:268136 Archived-At: Eli Zaretskii writes: > > Ehm - does somebody care about the manual? > > What do you mean? My wish would be that the manual says a bit more about how let-binding and buffer-local play together. We have this | *Warning:* When a variable has buffer-local bindings in one or more | buffers, =E2=80=98let=E2=80=99 rebinds the binding that=E2=80=99s current= ly in effect. For | instance, if the current buffer has a buffer-local value, =E2=80=98let=E2= =80=99 | temporarily rebinds that. If no buffer-local bindings are in effect, | =E2=80=98let=E2=80=99 rebinds the default value. If inside the =E2=80=98= let=E2=80=99 you then change to | a different current buffer in which a different binding is in effect, | you won=E2=80=99t see the =E2=80=98let=E2=80=99 binding any more. And if= you exit the =E2=80=98let=E2=80=99 | while still in the other buffer, you won=E2=80=99t see the unbinding occur | (though it will occur properly). in (info "(elisp) Intro to Buffer-Local") [good] and also some words about `set-default' being prevented from setting the default value inside `let' in (info "(elisp) Default Value"). But the manual leaves open some questions (after reading the manual I was not able to tell that the bug in this report was a bug): How are bindings working when not changing the current buffer inside the let? If I create a buffer-local binding and the `let' is left, what binding is left in the buffer - is the variable in that buffer still buffer local, or does leaving the let maybe also remove the local variable? This example derived from Stefan's test clarifies most questions: #+begin_src emacs-lisp ;; -*- lexical-binding: t -*- (defvar-local my-var :default) (let (inside-let local-inside-let inside-let-other-buffer local-outer outer) (with-temp-buffer (let ((my-var :let-bound)) (setq inside-let my-var) (setq-local my-var :buffer-local) (setq local-inside-let my-var) (setq inside-let-other-buffer (with-temp-buffer my-var))) (setq local-outer my-var) (setq outer (with-temp-buffer my-var))) (list inside-let local-inside-let inside-let-other-buffer local-outer outer)) ;; --> (:let-bound :buffer-local :let-bound ;; :buffer-local :default) #+end_src Then, sometimes one sees this warning (e.g. when evaluating the above example): | Making my-var buffer-local while locally let-bound! People will want to know what it means and whether (or when) they need to care about it or can ignore it. Finally, should we also talk about lexical variables vs. buffer-local? They are different again: #+begin_src emacs-lisp (with-temp-buffer (let ((var :let-bound)) (set (make-local-variable 'var) :buffer-local) var)) ;; --> :let-bound, not :buffer-local! #+end_src Michael.