From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Hannu Koivisto <azure@iki.fi>, emacs-devel@gnu.org
Subject: Re: First fontification of a buffer happens before font lock is fully initialised.
Date: Wed, 8 Feb 2012 21:43:18 +0000 [thread overview]
Message-ID: <20120208214318.GC31761@acm.acm> (raw)
In-Reply-To: <jwvvcniy1il.fsf-monnier+emacs@gnu.org>
Hello, Stefan.
On Tue, Feb 07, 2012 at 01:02:07PM -0500, Stefan Monnier wrote:
> > Can we not trust the good taste and sense of hackers generally?
> Have you ever looked at the Elisp code out there ;-)?
_Looked_ at it? ;-)
> > We can certainly trust the Emacs developers.
> I certainly wouldn't. Especially not the maintainers.
Hey, thanks!! :-)
> >> But maybe we can have an :after-hook. Some major modes would also
> >> appreciate such a feature, so maybe this same arg can be added to
> >> both define-minor-mode and define-derived-mode.
> > Or, perhaps, even (defmacro run-hooks-here () ...), which would preserve
> > the order of the initialisation forms in the mode. But I'd be happy
> > enough with :after-hook. Would you like me to implement it?
> Ah, yes, some way to force "run it here rather than elsewhere" would
> be elegant. The problem, is how to implement it in a way that's not
> completely disgusting.
Having tried this this afternoon, I don't see how it can be done
elegantly this way.
> The :after-hook has the advantage of being straightforward.
> If we want to fix it for 24.1, "straightforward" is important.
> Patch welcome, either way,
OK, Here goes:
=== modified file 'lisp/emacs-lisp/easy-mmode.el'
*** lisp/emacs-lisp/easy-mmode.el 2012-02-07 08:26:54 +0000
--- lisp/emacs-lisp/easy-mmode.el 2012-02-08 21:22:45 +0000
***************
*** 135,140 ****
--- 135,142 ----
the new state, and sets it. If you specify a :variable,
this function does not define a MODE variable (nor any of
the terms used in :variable).
+ :after-hooks A single lisp form which is evaluated after the mode hooks
+ have been run. It should be quoted.
For example, you could write
(define-minor-mode foo-mode \"If enabled, foo on you!\"
***************
*** 170,175 ****
--- 172,178 ----
(setter nil) ;The function (if any) to set the mode var.
(modefun mode) ;The minor mode function name we're defining.
(require t)
+ (after-hooks nil)
(hook (intern (concat mode-name "-hook")))
(hook-on (intern (concat mode-name "-on-hook")))
(hook-off (intern (concat mode-name "-off-hook")))
***************
*** 197,202 ****
--- 200,206 ----
(setq mode variable)
(setq mode (car variable))
(setq setter (cdr variable))))
+ (:after-hooks (setq after-hooks (pop body)))
(t (push keyw extra-keywords) (push (pop body) extra-keywords))))
(setq keymap-sym (if (and keymap (symbolp keymap)) keymap
***************
*** 265,271 ****
,@body
;; The on/off hooks are here for backward compatibility only.
(run-hooks ',hook (if ,mode ',hook-on ',hook-off))
! (if (called-interactively-p 'any)
(progn
,(if (and globalp (symbolp mode))
`(customize-mark-as-set ',mode))
--- 269,276 ----
,@body
;; The on/off hooks are here for backward compatibility only.
(run-hooks ',hook (if ,mode ',hook-on ',hook-off))
! ,@(when after-hooks `(,(eval after-hooks)))
! (if (called-interactively-p 'any)
(progn
,(if (and globalp (symbolp mode))
`(customize-mark-as-set ',mode))
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2012-02-08 21:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-25 12:48 First fontification of a buffer happens before font lock is fully initialised Alan Mackenzie
2012-01-25 17:46 ` Stefan Monnier
2012-01-25 18:26 ` Alan Mackenzie
2012-01-25 19:22 ` Hannu Koivisto
2012-01-25 20:22 ` Alan Mackenzie
2012-01-26 1:43 ` Stefan Monnier
2012-01-26 10:58 ` Alan Mackenzie
2012-02-04 12:03 ` Alan Mackenzie
2012-02-06 1:39 ` Stefan Monnier
2012-02-07 10:10 ` Alan Mackenzie
2012-02-07 18:02 ` Stefan Monnier
2012-02-08 21:43 ` Alan Mackenzie [this message]
2012-02-10 14:27 ` Stefan Monnier
2012-02-23 11:39 ` Alan Mackenzie
2012-02-23 14:34 ` Stefan Monnier
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=20120208214318.GC31761@acm.acm \
--to=acm@muc.de \
--cc=azure@iki.fi \
--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.