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: First fontification of a buffer happens before font lock is fully initialised. Date: Wed, 8 Feb 2012 21:43:18 +0000 Message-ID: <20120208214318.GC31761@acm.acm> References: <20120125124804.GB3638@acm.acm> <20120125182651.GA3624@acm.acm> <20120204120319.GC3347@acm.acm> <20120207101008.GB3314@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1328737426 30566 80.91.229.3 (8 Feb 2012 21:43:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Feb 2012 21:43:46 +0000 (UTC) Cc: Hannu Koivisto , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 08 22:43:45 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RvFIk-0006Om-Uv for ged-emacs-devel@m.gmane.org; Wed, 08 Feb 2012 22:43:43 +0100 Original-Received: from localhost ([::1]:44944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvFIk-0005Ze-3g for ged-emacs-devel@m.gmane.org; Wed, 08 Feb 2012 16:43:42 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:57515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvFIg-0005ZI-3F for emacs-devel@gnu.org; Wed, 08 Feb 2012 16:43:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvFIe-0007hA-JU for emacs-devel@gnu.org; Wed, 08 Feb 2012 16:43:38 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:45936 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvFIe-0007gy-8i for emacs-devel@gnu.org; Wed, 08 Feb 2012 16:43:36 -0500 Original-Received: (qmail 87440 invoked by uid 3782); 8 Feb 2012 21:43:33 -0000 Original-Received: from acm.muc.de (pD9557B64.dip.t-dialin.net [217.85.123.100]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 08 Feb 2012 22:43:30 +0100 Original-Received: (qmail 383 invoked by uid 1000); 8 Feb 2012 21:43:18 -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: Genre and OS details not recognized. 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:148378 Archived-At: 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).