[gnu.emacs] kill-emacs-hooks

jv@mhres.mh.nl (Johan Vromans) (06/11/89)

Wouldn't it be nice to have a "(run-hooks 'kill-emacs-hooks)" upon
exit?

It is not in the documentation, but the following appears to work
fine:

  (defvar kill-emacs-hooks nil
    "Hook functions to be executed upon kill-emacs.")
  (setq kill-emacs-hook '(lambda nil (run-hooks 'kill-emacs-hooks)))

I cannot be sure someone is using (or going to use) kill-emacs-hook 
for other purposes, though.

	Johan

-- 
Johan Vromans			 jv@mh.nl via european backbone (mcvax)
Multihouse Automatisering bv		uucp: ..!{mcvax,hp4nl}!mh.nl!jv
Doesburgweg 7					  phone: +31 1820 62944
2803 PL Gouda - The Netherlands			    fax: +31 1820 62500

jr@bbn.com (John Robinson) (06/12/89)

In article <3247@mhres.mh.nl>, jv@mhres (Johan Vromans) writes:
>Wouldn't it be nice to have a "(run-hooks 'kill-emacs-hooks)" upon
>exit?
>
>It is not in the documentation, but the following appears to work
>fine:
>
>  (defvar kill-emacs-hooks nil
>    "Hook functions to be executed upon kill-emacs.")
>  (setq kill-emacs-hook '(lambda nil (run-hooks 'kill-emacs-hooks)))
>
>I cannot be sure someone is using (or going to use) kill-emacs-hook 
>for other purposes, though.

There are a number of hooks defined in the C code that have this
problem.  Their semantics are those of:

  (funcall <C-definied-hook>)

as opposed to:

  (run-hooks <Elisp-defined-hook>)

run-hooks looks at its argument(s), an &rest-list.  It eventually runs
funcall on each list element that is a lambda or isn't a list, and
mapcar's funcall over the lists.  I think this functionality was added
early on, but after the C-coded hooks were already in place; the
latter skipped the elisp iteration on the list because of history.

Up with symettry.  Another vote for generalizing the C side of things.
The only conceivable downside I can see is that the auto-fill hook
(the thing that fills your long lines when you type a space) may slow
down noticeably, but I tend to doubt it.  Could always put run-hooks
into C (it's in subr.el now).
--
/jr, nee John Robinson   What a waste it is to lose one's mind--or not
jr@bbn.com or bbn!jr      to have a mind.  How true that is. -Dan Quayle