From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding Date: Sat, 01 Feb 2020 15:15:08 -0500 Message-ID: References: <495920D0-A298-43BF-99E6-B5ADA06113CB@acm.org> <83lfpnjuiz.fsf@gnu.org> <928DB820-6899-4653-8872-82CE3CF567CD@acm.org> <83imkrjrvh.fsf@gnu.org> <8EF7D3C6-041D-493F-859B-55D8D35AF588@acm.org> <83eevekat8.fsf@gnu.org> <3FB58E0B-E1DB-4709-98AB-92A45508486A@acm.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="61964"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 39373@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 01 21:16:14 2020 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 1ixzBd-000Fuk-Tc for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Feb 2020 21:16:14 +0100 Original-Received: from localhost ([::1]:50334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixzBc-0000tT-G6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Feb 2020 15:16:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43725) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixzBT-0000pP-6B for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 15:16:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixzBS-0007SO-7K for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 15:16:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixzBS-0007SD-4O for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 15:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ixzBS-0007Ty-0A for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 15:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Feb 2020 20:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39373 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 39373-submit@debbugs.gnu.org id=B39373.158058812028703 (code B ref 39373); Sat, 01 Feb 2020 20:16:01 +0000 Original-Received: (at 39373) by debbugs.gnu.org; 1 Feb 2020 20:15:20 +0000 Original-Received: from localhost ([127.0.0.1]:39371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ixzAm-0007St-Ip for submit@debbugs.gnu.org; Sat, 01 Feb 2020 15:15:20 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11117) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ixzAk-0007Sg-96 for 39373@debbugs.gnu.org; Sat, 01 Feb 2020 15:15:18 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C7A968083B; Sat, 1 Feb 2020 15:15:12 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9FAF480EC2; Sat, 1 Feb 2020 15:15:10 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1580588110; bh=k31t9PraXCGIgqHo8Px/y/DU2d67EzBF/AGyYxgfIy8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=bCkNpTfyWm6VBXKMDsw+eFN2i5kvpYCAzlKihjbVcuIuiAcHU0Przswji4soziSlV pEk5f+Ab+gzUFzXrVGG/vei2j8zl/ObdaGvWUKrBXri68tfel+yYd9vhJ8FPw30pK0 lusUkuDsGq5g6qt69Ra8qGxLR91ytgEaTlTRcZ7poPV4UAbUx0MXw0VsjnbNXg6Qch AQI8WmkhFFtukmyQINQ8MVVs6rDeIdbF84XQtqT8JbtS2EiC6fFzl37lySDV2pdJ48 xJ8GlNeFyiNVDydlLJhiKR2U2WdhIdh3WtmvLKIyswCS2dvizhbfoNmMn60gcrw5Hg b61cpSMKgr9LQ== Original-Received: from pastel (unknown [216.154.34.88]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 893C91204E7; Sat, 1 Feb 2020 15:15:09 -0500 (EST) In-Reply-To: <3FB58E0B-E1DB-4709-98AB-92A45508486A@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Sat, 1 Feb 2020 20:24:56 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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" Xref: news.gmane.io gmane.emacs.bugs:175569 Archived-At: >> If that's the case, then why don't we say that loud and clear in the ELisp manual? >> (The doc string of add-to-list has some vague >> recommendation, not sure if it really talks about this aspect, but >> that's definitely not enough for such a serious issue.) Good idea. >> And doesn't it mean we should audit all the gazillion uses of >> add-to-list in our sources, and do that urgently? In dynamically-scoped files, it's OK. But yes, we should audit them and change those that need changing for lexical scoping. I added a compiler macro as a crutch to handle the most command problems, but it's just an ugly hack which can make things worse by hiding the problem. > The compiler-macro (which apparently works in non-compiled code as well) Compiler macros work when the code passes through `macroexpand-all`, so it works when the code is compiled as well as when it's `load`ed (thanks to "eager" macroexpansion), but not when it's passed directly to `eval`. > attempts to warn about lexical variables but somehow this warning > doesn't always trigger. I haven't researched this further. The message is supposed not to trigger when it's applied to dynamically scoped var, but it's probably not 100% reliable. > It all seems rather fragile to me, and I'd rather add a note about not using > add-to-list for lexical variables to its doc string and the manual, and fix > all the calls listed above. Yes, this compiler-macro isn't supposed to replace educating the programmers (in the manual) and fixing the actual problems. BTW, this problem doesn't affect only `add-to-list`. Other culprits include `add-hook`, `run-hooks`, `set`, and `symbol-value`. > Two patches attached: a doc update, and a replacement of add-to-list in the cases listed above. LGTM, Stefan