From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: jakanakaevangeli Newsgroups: gmane.emacs.bugs Subject: bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lambdas Date: Tue, 09 Feb 2021 20:29:48 +0100 Message-ID: <87im7182fn.fsf@miha-pc> 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="30630"; mail-complaints-to="usenet@ciao.gmane.io" To: 46407@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 09 21:25:48 2021 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 1l9ZZy-0007u5-Tj for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Feb 2021 21:25:46 +0100 Original-Received: from localhost ([::1]:44626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9ZZx-00055n-PN for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Feb 2021 15:25:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9ZC2-0005tU-2L for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 15:01:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9ZC1-00068J-Qt for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 15:01:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l9ZC1-0005tC-QL for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 15:01:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: jakanakaevangeli Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Feb 2021 20:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46407 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161290081522568 (code B ref -1); Tue, 09 Feb 2021 20:01:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Feb 2021 20:00:15 +0000 Original-Received: from localhost ([127.0.0.1]:54713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9ZBD-0005rr-SS for submit@debbugs.gnu.org; Tue, 09 Feb 2021 15:00:15 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:35162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9Ye8-0002wo-IB for submit@debbugs.gnu.org; Tue, 09 Feb 2021 14:26:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Ye8-0005aY-Ag for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 14:26:00 -0500 Original-Received: from chiru.no ([142.4.209.132]:58904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1l9Ye6-0008Mc-LB for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 14:26:00 -0500 Original-Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by chiru.no (Postfix) with ESMTPSA id 733D4128001C for ; Tue, 9 Feb 2021 19:25:56 +0000 (UTC) Received-SPF: none client-ip=142.4.209.132; envelope-from=jakanakaevangeli@chiru.no; helo=chiru.no X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 09 Feb 2021 15:00:10 -0500 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" Xref: news.gmane.io gmane.emacs.bugs:199725 Archived-At: When kill-all-local-variables encounters a hook variable with its 'permanent-local property set to 'permanent-local-hook, it removes from its value every element except for t, functions with 'permanent-local-hook property and anything that isn't a symbol (see the comment at src/buffer.c:1072). This means that, for the following code (defvar 'some-hook nil) (add-hook 'some-hook #'some-fun nil t) (add-hook 'some-hook (lambda () (test)) nil t) whether some-fun is removed depends on some-fun's permanent-local-hook property, which is expected. As for the anonymous lambda function, it is not predictable, whether it will be kept or removed. In fact, it depends on some-fun's permanent-local-hook property. Perhaps it would make things more predictable to also remove non-symbol functions such as lambda expressions. See also info node (elisp) Creating Buffer-Local: > -- Function: kill-all-local-variables > This function eliminates all the buffer-local variable bindings > except for [...] and local hook functions that have a non-=E2=80=98n= il=E2=80=99 > =E2=80=98permanent-local-hook=E2=80=99 property. Which suggests that functions with a permanent-local-hook property should be the only exception.