From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#19363: Acknowledgement (24.4.1; Notifications can make ERC unusable) Date: Sun, 04 Jan 2015 14:52:07 -0500 Message-ID: References: <87r3w4njp1.fsf@secretsauce.net> <87egrgmd29.fsf@secretsauce.net> <87bnmkmbx8.fsf@secretsauce.net> <878uhnn3ub.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1420401198 30987 80.91.229.3 (4 Jan 2015 19:53:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 4 Jan 2015 19:53:18 +0000 (UTC) Cc: 19363@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 04 20:53:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y7rEc-0007Ez-AW for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Jan 2015 20:53:10 +0100 Original-Received: from localhost ([::1]:57906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7rEb-0003fK-FJ for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Jan 2015 14:53:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7rEX-0003fF-Kk for bug-gnu-emacs@gnu.org; Sun, 04 Jan 2015 14:53:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y7rEU-0006zK-E0 for bug-gnu-emacs@gnu.org; Sun, 04 Jan 2015 14:53:05 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7rEU-0006zF-AQ for bug-gnu-emacs@gnu.org; Sun, 04 Jan 2015 14:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y7rET-0006ft-SL for bug-gnu-emacs@gnu.org; Sun, 04 Jan 2015 14:53: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: Sun, 04 Jan 2015 19:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19363 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19363-submit@debbugs.gnu.org id=B19363.142040113325601 (code B ref 19363); Sun, 04 Jan 2015 19:53:01 +0000 Original-Received: (at 19363) by debbugs.gnu.org; 4 Jan 2015 19:52:13 +0000 Original-Received: from localhost ([127.0.0.1]:36605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y7rDg-0006eq-G3 for submit@debbugs.gnu.org; Sun, 04 Jan 2015 14:52:12 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:20809) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y7rDc-0006eh-RB for 19363@debbugs.gnu.org; Sun, 04 Jan 2015 14:52:10 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnEPAOwQflRFpY0B/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAgEBAQECAVYhAgULCxEDAQIdEhQYDRYOE4g3CdZZAQEBAQEBBAEBAQEBARyQbweESAWLAaQugXiEGSEwgkcBAQE X-IPAS-Result: AnEPAOwQflRFpY0B/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAgEBAQECAVYhAgULCxEDAQIdEhQYDRYOE4g3CdZZAQEBAQEBBAEBAQEBARyQbweESAWLAaQugXiEGSEwgkcBAQE X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="106531964" Original-Received: from 69-165-141-1.dsl.teksavvy.com (HELO ceviche.home) ([69.165.141.1]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Jan 2015 14:52:07 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 7CFF266100; Sun, 4 Jan 2015 14:52:07 -0500 (EST) In-Reply-To: <878uhnn3ub.fsf@secretsauce.net> (Dima Kogan's message of "Wed, 31 Dec 2014 07:47:24 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97996 Archived-At: > If we have some (eval-after-load 'erc ...) stuff then by the time this > (defvar) is evaluated, the list may already have a value, so the defvar > then does NOT add its value to the list. The patch explicitly changes > the (defvar list default) idiom to > (defvar list nil) (add-to-list 'list default) and thus the default value > always appears in the list. Thanks. That's a good change. The general rule is that a hook's initial/default value should be nil (that's fairly strong "should", with relatively few exceptions. This bug-report is a good example of why it should be that way). It's also generally better if the hook's "normal" value is nil, tho I think in this case it'd be probably inconvenient. But I do wonder: if the function *has* to be on that hook for ERC to work correctly, then maybe that function's place is not in the hook but right at those places where the hook is run (i.e. hard-coded). Could you (or someone who understands the code better than I do) take a look to see if such a change would be even better? Stefan >> From 28bc9430ce6342d210e986586af7b6f12e103043 Mon Sep 17 00:00:00 2001 > From: Dima Kogan > Date: Wed, 31 Dec 2014 08:13:57 -0800 > Subject: [PATCH] ERC no longer gets confused by (eval-after-load 'erc ...) > ERC was initializing one of its lists with (defvar list default). If > the list already had a value due to (eval-after-load 'erc ...) for > instance, then (defvar) would see an initialized variable, and would NOT > add the default value to the list. This was breaking things. This > patch changes the above defvar idiom to > (defvar list nil) > (add-to-list 'list default) > This way the default value is added to the list unconditionally > Closes: #19363 > --- > lisp/erc/erc-backend.el | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el > index fa95d7e..43e56c0 100644 > --- a/lisp/erc/erc-backend.el > +++ b/lisp/erc/erc-backend.el > @@ -1179,8 +1179,11 @@ add things to `%s' instead." > (cl-loop for alias in aliases > collect (intern (format "erc-server-%s-functions" alias))))) > `(prog2 > - ;; Normal hook variable. > - (defvar ,hook-name ',fn-name ,(format hook-doc name)) > + ;; Normal hook variable. The variable may already have a > + ;; value at this point, so I default to nil, and (add-hook) > + ;; unconditionally > + (defvar ,hook-name nil ,(format hook-doc name)) > + (add-to-list ',hook-name ',fn-name) > ;; Handler function > (defun ,fn-name (proc parsed) > ,fn-doc > -- > 2.1.3