[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: add-hook
From: |
Stefan Monnier |
Subject: |
Re: add-hook |
Date: |
10 Nov 2003 10:41:28 -0500 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
> Richard Stallman <address@hidden> writes:
>> ;; Detect the case where make-local-variable was used on a hook
>> ;; and do what we used to do.
>> (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook)))
>> (setq local t)))
>>
>> That is very confusing, and contradicts what the comment says.
>> This needs to be cleaned up somehow.
> Call me insane, but wouldn't `local-variable-p' be a nice way to detect
> this case...?
Well, that's what RMS thought and so he added it and it breaks things:
Setting `local' to t ensures that the var will be modified with `set'
whereas a setting of nil implies that the hook will be modified with
`set-default', so the safe setting is t. The only case where we
want to use the unsafe setting of nil is when we indeed want to change
the global part of the hook and there is both a local and a global part
(i.e when local == nil and when there's a t in the hook's content).
You can add an unnecessary test for local-variable-if-set-p, or you can
change the comment to make things more clear, but you can't use
local-variable-p: we tried that already.
Stefan