From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Chong Yidong <cyd@gnu.org>, emacs-devel@gnu.org
Subject: Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch]
Date: Tue, 15 Jan 2013 14:08:55 +0000 [thread overview]
Message-ID: <20130115140855.GA3430@acm.acm> (raw)
In-Reply-To: <jwvhamjp5k6.fsf-monnier+emacs@gnu.org>
Hi, Stefan.
On Mon, Jan 14, 2013 at 09:12:15PM -0500, Stefan Monnier wrote:
> > ! (add-hook 'after-change-major-mode-hook
> > ! ',MODE-enable-in-buffers)
> > ! (add-hook 'change-major-mode-after-body-hook
> > ',MODE-enable-in-buffers)
> > (add-hook 'find-file-hook ',MODE-check-buffers)
> > (add-hook 'change-major-mode-hook ',MODE-cmhh))
> > --- 399,407 ----
> > ;; Setup hook to handle future mode changes and new buffers.
> > (if ,global-mode
> > (progn
> > ! (add-hook ',(if call-before-hook
> > ! 'change-major-mode-after-body-hook
> > ! 'after-change-major-mode-hook)
> I think we first need to understand why we currently use both.
This is difficult. The change was in revision 106202. Previously,
MODE-enable-in-buffers was simply add-hooked into
after-change-major-mode-hook. The relevant ChangeLog entry runs:
+ 2011-10-27 Chong Yidong <cyd@gnu.org>
+
+ * subr.el (change-major-mode-after-body-hook): New hook.
+ (run-mode-hooks): Run it.
+
+ * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Use
+ change-major-mode-before-body-hook.
+
+ * simple.el (fundamental-mode):
+ * emacs-lisp/derived.el (define-derived-mode): Revert 2010-04-28
+ change introducing fundamental-mode-hook.
+
The new hook change-major-mode-after-body-hook came into existence after
a naming competition in the thread starting at:
From: Christoph Scholtes <cschol2112@googlemail.com>
To: emacs-devel@gnu.org
Subject: Fundamental mode vs. special mode
Date: Sat, 22 Oct 2011 14:13:03 -0600
Message-ID: <86sjmkvl80.fsf@googlemail.com>
That thread mainly discussed the propriety of fundamental-mode-hook, and
prompted Yidong to remove it, putting change-major-mode-after-body-hook
in its place. Here is his email proposing this:
> I propose to remove the fundamental-mode-hook variable introduced in
> that change, and introduce `run-mode-hooks-hook'[*], which
> `run-mode-hooks' runs before all the other hooks. Then minor modes
> can use `run-mode-hooks-hook', and the "turning off global modes"
> feature will be available to non-derived modes.
[*] renamed to `change-major-mode-after-body-hook' before
implementation.
> Also, the MODE-enable-in-buffers function should enable the mode only
> once, normally, even if called via both hooks.
I think that's true. My problem is that font-lock-mode is being called
too soon, before the mode has been fully set up by the major mode hook.
That first call of f-l-m sets up font-lock-keywords to include entries
for fontifying "doc comments". A buffer local variable specifies what
sort of doc comments.
It has to be admitted that the CC Mode code here isn't totally correct;
a complete solution to this bug probably involves making
font-lock-keywords buffer local when doc comments are specified. I
don't want to make this change (which would be somewhat involved) before
Emacs 24.3. ;-( Postponing `font-lock-mode' until after the mode hook
seems a safer bet at the moment.
> So if you see a problem, maybe it's because (eq ,MODE-major-mode
> major-mode) is not true the second time around, i.e. because
> `major-mode' has changed between the two hooks. Is that the case?
> If so, why?
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2013-01-15 14:08 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 [this message]
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
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=20130115140855.GA3430@acm.acm \
--to=acm@muc.de \
--cc=cyd@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.