Received: (at 76470) by debbugs.gnu.org; 21 Feb 2025 17:02:03 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 21 12:02:03 2025 Received: from localhost ([127.0.0.1]:34219 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tlWPZ-000823-7t for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 12:02:03 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:42199) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1tlWPU-0007op-Id for 76470 <at> debbugs.gnu.org; Fri, 21 Feb 2025 12:01:58 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-38f5fc33602so1340164f8f.0 for <76470 <at> debbugs.gnu.org>; Fri, 21 Feb 2025 09:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740157310; x=1740762110; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=3JAelmCcaBlaangTBoLwQ1JC8XPe0tVMGN4X9C4TLS0=; b=UrbHQgElK/v5cCoNl8t2QnlwOwfiJV2Z7kHBF3wpcFVCHvzdxAC+sIFv1Fu0XAUnUm Nq25DjQwqOIkELsBtF4pS4h6nn/lZSa05FgV0vczyRmNOzFSyCTRmqvJry0xHD5+AxD7 jU5X1agOYlTYhDpKqDfUYODgggtEccouHcFTI+DZAElNsI+Rna+UdeH+6PSZtkiUzveo WoMzi3soIuPJRe+KhpLgcp2AjLMBxGq572femdPa+1DdaRbmxK60ZC2rmXBtV+OwXrmz WAxQyDBDMBld1HCmOKD/kZRkG3a/wv2YRyGh0YkstFG5dHkobuIxDvJVMGhGA2NLumGi 386Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740157310; x=1740762110; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3JAelmCcaBlaangTBoLwQ1JC8XPe0tVMGN4X9C4TLS0=; b=OPeCpi9mfCVqpYBxaq1mJigWuzbjIvJSCbkDreZvJVNw9mnN30cCm2uHv8y9n2VDkb jBamIF/G2umsvacuZ9hOicN/q/Sre0a5ggBD2RjfXO8lkXmR73zuzylFQOFulrz0QaYH 44pG4PCvXSG1CaAGidq0XFacpru+jjPRiTwa7TSMWBdYlLoJwo9qKnoSUiWOnWDbNGjL d79gnFQhNBVaoDQ/+UGzvn8BZsDB5JiU4sY8KI7Wpcjtbub5BW0rGhfYjJcxJ9DNK7YO P7uwRaziBYkwRN0QCdyoPKz/CGMVNUojcN89njo/eHG7WkH7U4mHt+Rf0fIcPh9G5nHc D+bQ== X-Gm-Message-State: AOJu0YxSxHtfpd9r/UfpIVu8XzT3YEZ1TUbHHYvTkZO3ai3BU6eVyspj 8zkileDkX+KSKu2zZZQuJtQHoN9+2FTEjPSIKWgWj4Lddu1GMN/dgoK0XOJHqItFbLQ2j1SD5xj MVoLtKGWaDEiiviiIhwQKEsO6WrR2cEy5W0E= X-Gm-Gg: ASbGncugQHQPJiju+115UdqtsS7PCQ5G+NfaW4IdZH6n9dWkG2ex6keAZ67NKVQscez mEVClxqOiwmTCg0FWUk/KVuRDL3jQfonKLIaGf6xdUd2vK4tCBDiq9Yx1FMjUchi0/oXvTWsqg+ Jl3juHm4c= X-Google-Smtp-Source: AGHT+IGqiWZljJEfrVeMbAOZnvZsawW0Q3J0m1dtHO9YP1IzAhHs6F8m7xskLVWmZlABAOsw2tHZ7m+Ztx5i2BxeMpo= X-Received: by 2002:a5d:47c3:0:b0:38d:d59c:c9d6 with SMTP id ffacd0b85a97d-38f61611400mr7400816f8f.21.1740157309851; Fri, 21 Feb 2025 09:01:49 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 21 Feb 2025 17:01:48 +0000 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <jwv5xl3xw5v.fsf-monnier+emacs@HIDDEN> References: <jwv5xl3xw5v.fsf-monnier+emacs@HIDDEN> MIME-Version: 1.0 Date: Fri, 21 Feb 2025 17:01:48 +0000 X-Gm-Features: AWEUYZkMMEfNpyJ6ygLa33xnyDY2wpN5T-5tPPK6VseXHChZkok7Uhnyt_m7laE Message-ID: <CADwFkmkMNeTBfVKfAkR0B+OHJ4mNF9i76hSWL7WVvnXfq97pfQ@HIDDEN> Subject: Re: bug#76470: 31.0.50; `setq-local` makes the var buffer-local too soon To: 76470 <at> debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76470 Cc: monnier@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN> writes: > Po Lu has just pointed me to a bug in `setq-local` which shows up when > you do something like: > > (setq-local my-foo (progn (defvar my-foo 1000) my-foo)) > > Commit afd088bd608 added a workaround for exactly this problem in one of > the uses of `setq-local`. > > The problem is that `setq-local` does, fundamentally > > (make-local-variable 'my-foo) > (let ((val (progn (defvar my-foo 1000) my-foo))) > (setq my-foo val) > > so that during the computation of `val`, the variable has already been > made buffer-local but has not yet been assigned. So the `defvar` will > correctly define the default value of `my-foo` but `my-foo` will still > be unbound in the current-buffer. > > I suggest we change the ordering to: > > (let ((val (progn (defvar my-foo 1000) my-foo))) > (make-local-variable 'my-foo) > (setq my-foo val) > > As for how to implement that fix. The simplest way is to just change > the macro, of course. But maybe a better way is to do it by introducing > a `set-local` function (sibling to `set` and `set-default`) and then > make the macro expand to a call to this function. What are the benefits of adding a new function instead of just changing the macro? > When I discussed this with Po Lu he felt this was a risky subtle change > which would interfere with a lot of code. I was quite surprised at this > reaction because my own gut feeling is that, while it is undoubtedly > a subtle change, it's just a very straightforward bug-fix, highly > unlikely to introduce problems. > > WDYT? I agree that we should fix the bug.
bug-gnu-emacs@HIDDEN
:bug#76470
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 21 Feb 2025 13:45:24 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 21 08:45:24 2025 Received: from localhost ([127.0.0.1]:57272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tlTLH-000651-Kq for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 08:45:24 -0500 Received: from lists.gnu.org ([2001:470:142::17]:59858) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1tlTLE-00060M-O3 for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 08:45:21 -0500 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 <monnier@HIDDEN>) id 1tlTL5-0008PQ-KC for bug-gnu-emacs@HIDDEN; Fri, 21 Feb 2025 08:45:11 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <monnier@HIDDEN>) id 1tlTL3-0005AX-HI for bug-gnu-emacs@HIDDEN; Fri, 21 Feb 2025 08:45:11 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 7DBA3441855; Fri, 21 Feb 2025 08:45:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1740145505; bh=/3ppvkVWm6REuQen+KrDqr+BKH8POaDf5SrhhSlFQGU=; h=From:To:Subject:Date:From; b=TuWnAEFegdr4WjlErheGR/HEUbk950d7IenImT2M93VYH3HI2w9whXR0OZrROY42X yCuKZKIw9wZIkxmpk1w54+PMco4cJ937sa2dJvKjJSnIG84RYhw5kIwi3qhFM/6KJK h/HxgVVfFRg8N1pcDA1xSYsHnOUDY4l9gc3Vo7Ann/Xouh3ZvngNmfw506hI4RALy8 lLoGGZSE9U27H2bWoxnjP2o+Qvn1WLR2XRHrFsGCTTKnYhHqnNR7gxvfoKjB3ilq5g 24XOqt8TUXpEWVPQiaCTskAq9pplK9xZPBU0HB2gZxq0WhwoXEv3XWqB7+rV9CpYPL lNUS7IW9qF+yg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 28344441812; Fri, 21 Feb 2025 08:45:05 -0500 (EST) Received: from pastel (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0A8FC12055D; Fri, 21 Feb 2025 08:45:05 -0500 (EST) From: Stefan Monnier <monnier@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 31.0.50; `setq-local` makes the var buffer-local too soon Message-ID: <jwv5xl3xw5v.fsf-monnier+emacs@HIDDEN> X-Debbugs-Cc: monnier@HIDDEN Date: Fri, 21 Feb 2025 08:45:03 -0500 MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.518 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@HIDDEN; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Package: Emacs Version: 31.0.50 Po Lu has just pointed me to a bug in `setq-local` which shows up when you do something like: (setq-local my-foo (progn (defvar my-foo 1000) my-foo)) Commit afd088bd608 added a workaround for exactly this problem in one of the uses of `setq-local`. The problem is that `setq-local` does, fundamentally (make-local-variable 'my-foo) (let ((val (progn (defvar my-foo 1000) my-foo))) (setq my-foo val) so that during the computation of `val`, the variable has already been made buffer-local but has not yet been assigned. So the `defvar` will correctly define the default value of `my-foo` but `my-foo` will still be unbound in the current-buffer. I suggest we change the ordering to: (let ((val (progn (defvar my-foo 1000) my-foo))) (make-local-variable 'my-foo) (setq my-foo val) As for how to implement that fix. The simplest way is to just change the macro, of course. But maybe a better way is to do it by introducing a `set-local` function (sibling to `set` and `set-default`) and then make the macro expand to a call to this function. When I discussed this with Po Lu he felt this was a risky subtle change which would interfere with a lot of code. I was quite surprised at this reaction because my own gut feeling is that, while it is undoubtedly a subtle change, it's just a very straightforward bug-fix, highly unlikely to introduce problems. WDYT? Stefan
Stefan Monnier <monnier@HIDDEN>
:monnier@HIDDEN, bug-gnu-emacs@HIDDEN
.
Full text available.monnier@HIDDEN, bug-gnu-emacs@HIDDEN
:bug#76470
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.