[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Customize and autoloaded libraries
From: |
Stefan Monnier |
Subject: |
Re: Customize and autoloaded libraries |
Date: |
Wed, 05 Dec 2001 09:17:30 -0500 |
> (defun custom-initialize-hook (symbol value)
> "Initialize SYMBOL with VALUE.
>
> If symbol has a `saved-value' property, it will evaluate the car of
> that. The result should be a list of hook functions, which will be
> added to SYMBOL using `add-hook'. If there is no `saved-value'
> property, VALUE will be evaluated instead to get the list of hook
> functions to add to the symbol.
>
> This is for initialization hook variables. It is different from the
> other initialize functions in that the saved or initial value is
> merged into the existing value, allowing the user to use `add-hook'
> before the declaration of the hook variable."
> (let ((hooks (if (get symbol 'saved-value)
> (eval (car (get symbol 'saved-value)))
> (eval value))))
> (mapc (lambda (fun) (add-hook symbol fun)) hooks)))
One thing bothers me here: it makes the defhook behave more
like defconst than defvar. More specifically, if you do
(defhook foo-hook '(bar))
(remove-hook 'foo-hook 'bar)
(defhook foo-hook '(bar))
foo-hook will contain bar even though you clearly wanted to remove it.
So I think we need to remember that initialization took place.
Something like:
(defun custom-initialize-hook (symbol value)
(if (get symbol 'custom-initialized) nil
(dolist (fun (reverse (eval (if (get symbol 'saved-value)
(car (get symbol 'saved-value))
value))))
;; Use `append' to pretend that `fun' was there long ago.
(add-hook symbol fun t))
(put symbol 'custom-initialized t)))
-- Stefan
- Re: Customize and autoloaded libraries, (continued)
- Re: Customize and autoloaded libraries, Richard Stallman, 2001/12/04
- Re: Customize and autoloaded libraries, Per Abrahamsen, 2001/12/04
- Re: Customize and autoloaded libraries, Stefan Monnier, 2001/12/04
- Re: Customize and autoloaded libraries, Per Abrahamsen, 2001/12/04
- Re: Customize and autoloaded libraries, Per Abrahamsen, 2001/12/05
- Re: Customize and autoloaded libraries, Richard Stallman, 2001/12/05
- Re: Customize and autoloaded libraries, Per Abrahamsen, 2001/12/05
- Re: Customize and autoloaded libraries,
Stefan Monnier <=
- Re: Customize and autoloaded libraries, Per Abrahamsen, 2001/12/05
- Re: Customize and autoloaded libraries, Stefan Monnier, 2001/12/05
- Re: Customize and autoloaded libraries, Richard Stallman, 2001/12/06
- Re: Customize and autoloaded libraries, Per Abrahamsen, 2001/12/07
- Re: Customize and autoloaded libraries, Richard Stallman, 2001/12/08
- Re: Customize and autoloaded libraries, Stefan Monnier, 2001/12/04
- Re: Customize and autoloaded libraries, Richard Stallman, 2001/12/05