I am looking for an example, please, to programmatically control the order of functions within a particular hook:
First in time, which is easy -- i.e., don't append using
add-hook.Last in time, which is easy -- i.e., append using
add-hook.Second to last -- not so easy?
In the context of this particular question, there are three (3) functions assigned to the post-command-hook.
An overlay removal function, which must always be first in time.
A
flyspell-post-command-hookfunction that must always be last in time -- ifflyspell-modeis active.A overlay placement function that must be last in time when
flyspell-modeis not active, or second to last whenflyspell-modeis active.
Essentially, I would like to control the overlay placement function to programmatically check to see whether flyspell-mode is active, and if so, then place it second to last. If flyspell-mode is not active, then just append so that the overlay placement function becomes the last in the hook.
(defun append-butlast (elt list) (append (butlast list) (list elt) (last list))). – Dan Dec 22 '14 at 21:57tthat sometimes appears inside the hook when I inspect thepost-command-hook? I thinkadd-hookmay place thattsomewhere specifically, but I'm not sure how that is determined or under what circumstance atis added. Here is a specific example:(vr-remove-vertical-ruler t pch-hr-function parens flyspell-post-command-hook)– lawlist Dec 22 '14 at 22:05tcomes from. I imagine you could inspectpost-command-hookfor thattin deciding where to assign your function (last, second-to-last, etc., either countingtor not). – Dan Dec 22 '14 at 22:12t(if applicable) somewhere when adding the second to the last. – lawlist Dec 22 '14 at 22:14tstands for the global part of the hook (i.e. the list of functions kept on(default-value <hook>). – Stefan Dec 23 '14 at 13:58