From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch-2] Date: Sun, 3 Feb 2013 22:14:27 +0000 Message-ID: <20130203221427.GA22586@acm.acm> References: <20130115140855.GA3430@acm.acm> <20130117175159.GA3114@acm.acm> <20130131110404.GA3459@acm.acm> <20130201154453.GA23075@acm.acm> <20130201195352.GB23075@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1359929718 5061 80.91.229.3 (3 Feb 2013 22:15:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Feb 2013 22:15:18 +0000 (UTC) Cc: =?iso-8859-1?Q?Jo=E3o_T=E1vora?= , Chong Yidong , Leo Liu , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 03 23:15:38 2013 Return-path: Envelope-to: ged-emacs-devel@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 1U27qZ-0002EE-K6 for ged-emacs-devel@m.gmane.org; Sun, 03 Feb 2013 23:15:35 +0100 Original-Received: from localhost ([::1]:43396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U27qH-0000Ss-4w for ged-emacs-devel@m.gmane.org; Sun, 03 Feb 2013 17:15:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:50987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U27qE-0000Sm-Op for emacs-devel@gnu.org; Sun, 03 Feb 2013 17:15:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U27qC-0008Ct-1u for emacs-devel@gnu.org; Sun, 03 Feb 2013 17:15:14 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:33371 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U27qB-0008Cg-On for emacs-devel@gnu.org; Sun, 03 Feb 2013 17:15:11 -0500 Original-Received: (qmail 16987 invoked by uid 3782); 3 Feb 2013 22:15:10 -0000 Original-Received: from acm.muc.de (pD951B211.dip.t-dialin.net [217.81.178.17]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 03 Feb 2013 23:15:06 +0100 Original-Received: (qmail 22729 invoked by uid 1000); 3 Feb 2013 22:14:27 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:156811 Archived-At: Hi, Stefan. On Fri, Feb 01, 2013 at 06:16:37PM -0500, Stefan Monnier wrote: > > Is it OK to commit this change to emacs-24 now, and close bug#11152? > No, I think this is good for trunk but not for emacs-24. > I think that for emacs-24 we need a less invasive change. Any less invasive change would surely be a better change, if we could come up with one, so would also be better for the trunk. Maybe we just leave this bug to 24.4/25.1 to fix. > For that we should probably go back and try and figure out why the hook > is run both times. As mentioned, the code tries to avoid running it > twice by checking the value of `major-mode', so it appears that in the > problem case, `major-mode' changes between the two hooks. Can you try > and figure out if that's indeed the case and why? The MODE-major-mode check was in place long before the current issues arose in 2010-04-25 in the emacs-devel thread "globalized minor modes - priority over mode hook?". I've bzr blame'd it back to before revision 49780.1.32 from 2006. MODE-major-mode's original purpose seems to be to prevent the needless disabling and re-enabling of the minor mode. It doesn't appear to be there to detect a mode changing between two run-hook calls. I haven't found any evidence of any such "problem case". The first revision where MODE-enable-in-buffers gets invoked twice is 100071, this one: revno: 100071 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2010-04-28 11:18:37 -0400 message: Make it possible to locally disable a globally enabled mode. * simple.el (fundamental-mode): Run fundamental-mode-hook. * emacs-lisp/derived.el (define-derived-mode): Use fundamental-mode rather than kill-all-local-variables so it runs fundamental-mode-hook. * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Use fundamental-mode-hook to run MODE-enable-in-buffers earlier, so that subsequent hooks get a chance to disable it. , with this change: *** lisp/emacs-lisp/easy-mmode.el 2010-04-27 18:14:16 +0000 --- lisp/emacs-lisp/easy-mmode.el 2010-04-28 15:18:37 +0000 *************** *** 338,346 **** --- 338,348 ---- (progn (add-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers) + (add-hook 'fundamental-mode-hook ',MODE-enable-in-buffers) (add-hook 'find-file-hook ',MODE-check-buffers) (add-hook 'change-major-mode-hook ',MODE-cmhh)) (remove-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers) + (remove-hook 'fundamental-mode-hook ',MODE-enable-in-buffers) (remove-hook 'find-file-hook ',MODE-check-buffers) (remove-hook 'change-major-mode-hook ',MODE-cmhh)) . fundamental-mode-hook was later suppressed and replaced by change-major-mode-after-body-hook. Stefan, have you any recollection at all of why you left MODE-enable-in-buffers also in after-change-major-mode-hook? > Stefan -- Alan Mackenzie (Nuremberg, Germany).