[Top][All Lists]

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

Re: occur-mode-hook run too early to be useful

From: Stefan Monnier
Subject: Re: occur-mode-hook run too early to be useful
Date: Wed, 28 Aug 2002 10:30:05 -0400

> The patch to fix that is trivial: just move the call to (run-hooks
> 'occur-mode-hook) from `occur-mode' to the end of `occur-1', and voilà.
> As always, though, I have a philosophical question: should be
> `occur-mode-hook' be run from any other place than `occur-mode'?


> For normal major modes the answer is no, I suppose, but `occur-mode' is
> a special mode, only called from inside `occur-1'. After `occur-mode'
> runs, the buffer either has the old contents (that will be obliterated
> immediately afterwards) or it is empty, so in fact running
> `occur-mode-hook' at that moment is only useful for non-contents-related
> hook functions. I want, for example, to resize the occur window after
> doing M-x occur, and as it stands now it's not posible to do that through
> `occur-mode-hook' (I'd have to revert to using defadvice, etc.).
> So, it is OK to move the call to run-hooks to occur-1?

That would be wrong.  The hook should be run at the end of the major mode's
function.  Another way would be to call `occur-mode' later (which would
require the occur-revert-arguments variable to be made permanent-local)
or to provide another hook (like `occur-hook').

See edit-log-mode for an example where there is edit-log-mode-hook
and edit-log-hook.


reply via email to

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