[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: add-list local value
From: |
Stefan Monnier |
Subject: |
Re: add-list local value |
Date: |
Wed, 12 Mar 2008 09:51:11 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
>>> Wouldn't it be practical to allow add-list to add to the buffer local value,
>>> like add-hook allows? At least I need it ...
>>
>> It makes sense for add-hook because buffer-local values of hook include
>> a special entry t which means "run the global value of this hook".
>>
>> For lists, it doesn't make much sense I believe. Either the list is
>> global or it's local. If it's local, just make it local with
>> make-local-variable.
> And if I have a local value and want to add to the global value with
> add-to-list?
A good reason why add-to-list is a bad function.
You can use
(require 'cl)
(pushnew <val> (default-value '<sym>))
or
(setq-default <sym> (cons <var> (default-value '<sym>)))
or
(unless (member <val> (default-value '<sym>))
(setq-default <sym> (cons <var> (default-value '<sym>))))
-- Stefan