From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lambdas Date: Mon, 24 May 2021 23:55:28 +0200 Message-ID: <87eedvajan.fsf@gnus.org> References: <87im7182fn.fsf@miha-pc> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39516"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 46407@debbugs.gnu.org To: jakanakaevangeli Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 24 23:56:12 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 1llIYV-000A54-Vi for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 May 2021 23:56:11 +0200 Original-Received: from localhost ([::1]:58800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llIYU-0004Bs-HD for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 May 2021 17:56:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llIYM-00049p-QF for bug-gnu-emacs@gnu.org; Mon, 24 May 2021 17:56:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llIYM-0001eJ-IM for bug-gnu-emacs@gnu.org; Mon, 24 May 2021 17:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1llIYM-0003mQ-GI for bug-gnu-emacs@gnu.org; Mon, 24 May 2021 17:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 May 2021 21:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46407 X-GNU-PR-Package: emacs Original-Received: via spool by 46407-submit@debbugs.gnu.org id=B46407.162189334314506 (code B ref 46407); Mon, 24 May 2021 21:56:02 +0000 Original-Received: (at 46407) by debbugs.gnu.org; 24 May 2021 21:55:43 +0000 Original-Received: from localhost ([127.0.0.1]:44078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llIY2-0003lu-Sp for submit@debbugs.gnu.org; Mon, 24 May 2021 17:55:43 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:36704) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llIXx-0003lc-99 for 46407@debbugs.gnu.org; Mon, 24 May 2021 17:55:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zG0RINSYxJcbDAjGJ8NYtfRLKgzkjj/SpM1hRKi4HTc=; b=ON6AdgM3oD2oRheLNIYUuULULx DBQ3x8OsMYXeXKtxQmZp0WoKidMDKXUrYIfN6x5sRkcsI6v3evwMDZaKQYeNnq0wFHaiZ5PiWquWM xBQGCS1/II+CcVAqRXSHyH1f3e8hRBRCjJxlJYwRu78vT7alL9ZG+MEssAi2lqJ3Q1SY=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1llIXo-0006Z9-Hf; Mon, 24 May 2021 23:55:30 +0200 X-Now-Playing: 'O'rang's _Herd of Instinct_: "Nahoojek-Fogou" In-Reply-To: <87im7182fn.fsf@miha-pc> (jakanakaevangeli@chiru.no's message of "Tue, 09 Feb 2021 20:29:48 +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" Xref: news.gmane.io gmane.emacs.bugs:207146 Archived-At: jakanakaevangeli writes: > 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. Well, it depends on the hook's permanent-local-hook property, but it's true that add-hook will automatically set that for you if you pass in a symbol with that property set. So, yes, that's a strange side effect of this interface, but I'm not sure anything could be done about it at this stage (it was introduced in this form almost two decades ago). jakanakaevangeli writes: > Also one more thing: > > (defvar some-hook nil) > (add-hook 'some-hook #'some-fun nil t) > (put 'some-fun 'permanent-local-hook t) > > If we mark a function as permanent-local-hook only after adding it to a > hook, the hook symbol will not have its permanent-local property set to > 'permanent-local-hook, so some-fun will not be kept on removal of local > variables. > > This can be a real non-theoretical problem when adding an autoloaded > function to a hook. You mean if the property isn't part of the autoloaded signature? Yes, that's true. As far as I can tell, this permanent-local-hook stuff isn't used anywhere in the Emacs tree, and it seems like a pretty odd and (as this bug report shows) inconsistent interface. I'm not sure whether it's worth trying to fix, or we should just document that it's iffy. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no