bug-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Alan Mackenzie
Subject: An idea: controlling the order of execution of elisp hook functions
Date: 6 Dec 2001 22:49:52 +0100
Date: Thu, 6 Dec 2001 18:44:44 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

Sometimes it is desirable to be able to control the order of execution of
elisp hook functions.

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.

A way to do this would be to give each hook function an optional property
called, say, "priority", with expected values 'first 'normal and 'last.
When add-hook is called, it inserts the new hook function into the hook's
function list at the front if its PRIORITY is 'first, after all the
"first" functions if its PRIORITY is 'normal or nil, and at the end of
the list if its PRIORITY is 'last. 

Implementing this proposal would have a minimal impact on existing elisp
programs or on new programs run on older versions of Emacs.

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").




reply via email to

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