emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: An idea: controlling the order of execution of elisp hook functions


From: Alan Mackenzie
Subject: Re: An idea: controlling the order of execution of elisp hook functions
Date: Fri, 7 Dec 2001 09:34:33 +0000 (GMT)

On Fri, 7 Dec 2001, Richard Stallman wrote:

>    For example, both font-lock and major modes insert hooks into
>    after-change-functions.  Ideally, the major mode hook should be run
>    first, because the results of its syntactic analysis may well influence
>    the font-locking (for example by setting the syntax-table text property).
>    This is currently difficult to arrange.

>The idea is a coherent one, but do we actually need it today?

Hmm.  What exactly does "need" mean?

In awk, the character '/' is sometimes a regexp delimiter, sometimes a
division sign.  A regular expression (or possibly an explicit finite
state machine) will distinguish between the two meanings of '/', and set
the syntax-table property appropriately.  Call this functionality "S".

The question is, from where is S to be called?  font-lock requires it,
the syntax analysis (in cc-mode) will require it.  If S is called from
within font-lock, it will be called only when font-lock is enabled.  If
it is called from cc-mode, chances are that the font-locking will be done
_before_ S is called, making the font-locking erratic.  S could be called
from both places, but this is wasteful.  Or there are various kludges
which can ensure that S is called exactly once for each buffer change.

But it strikes me that the root of the problem is an invalid assumption
behind hook functionality, namely that the order of calling of hook
functions is immaterial.  Surely it is better to correct the problem
rather than kludge around it.

The idea came to me after some email with Stephan Monnier, who has
enhanced the font-locking withing awk-mode.el (CVS version).  He told me
that the same problem also occurs in other contexts, for example in sh
mode.

-- 
Alan Mackenzie (Munich, Germany)
address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]