all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "João Távora" <joaotavora@gmail.com>,
	"Chong Yidong" <cyd@gnu.org>, "Leo Liu" <sdl.web@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch-2]
Date: Sun, 3 Feb 2013 22:14:27 +0000	[thread overview]
Message-ID: <20130203221427.GA22586@acm.acm> (raw)
In-Reply-To: <jwvr4kzocdt.fsf-monnier+emacs@gnu.org>

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 <monnier@iro.umontreal.ca>
    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).



      reply	other threads:[~2013-02-03 22:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-13 19:28 Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode Alan Mackenzie
2013-01-13 20:48 ` Dmitry Gutov
2013-01-14 16:30 ` Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch] Alan Mackenzie
2013-01-14 16:52   ` emacs24/auctex bug Camm Maguire
2013-01-14 23:58     ` Xue Fuqiao
2013-01-15  2:12   ` Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch] Stefan Monnier
2013-01-15 14:08     ` Alan Mackenzie
2013-01-17 13:17       ` João Távora
2013-01-17 17:51         ` Alan Mackenzie
2013-01-17 18:31           ` Stefan Monnier
2013-01-18 12:07             ` João Távora
2013-01-18 17:09             ` Alan Mackenzie
2013-01-31 11:04             ` Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch-2] Alan Mackenzie
2013-01-31 14:38               ` Stefan Monnier
2013-02-01 15:44                 ` Alan Mackenzie
2013-02-01 16:28                   ` Stefan Monnier
2013-02-01 19:53                     ` Alan Mackenzie
2013-02-01 20:09                       ` Achim Gratz
2013-02-01 20:15                         ` Alan Mackenzie
2013-02-01 23:17                         ` Stefan Monnier
2013-02-01 23:16                       ` Stefan Monnier
2013-02-03 22:14                         ` Alan Mackenzie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130203221427.GA22586@acm.acm \
    --to=acm@muc.de \
    --cc=cyd@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.