help-gnu-emacs
[Top][All Lists]
Advanced

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

writing an own version of setq?


From: Klaus Berndl
Subject: writing an own version of setq?
Date: 09 Oct 2002 12:34:12 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

I have written the code below to give me a save setq which only sets the new
value if the symbol is not already saved via customize:

,----
| (defmacro custom-saved-p (option)
|   "Return only not nil if OPTION is a defcustom-option and has a saved
| value. "
|   `(and (get ,option 'custom-type)
|         (get ,option 'saved-value)))
| 
| (defmacro setq-save (option value)
|   "Sets OPTION to VALUE if and only if OPTION is not already saved by
| customize."
|   `(and (not (custom-saved-p ,option))
|         (set ,option ,value)))
`----

OK, calls like (setq-save 'klaus (+ 1 2)) work fine but I'm not really
satisfied because i want to write (setq-save klaus (+ 1 2)). Note the missing
quote! How can i achieve this?

(I know, for a complete setq-save i have to add the semantic for many
symbol-value-pairs like in the *setq* but this should not be a big problem...)

many thanks in advance!
Klaus
   

-- 
Klaus Berndl                    mailto: klaus.berndl@sdm.de
sd&m AG                         http://www.sdm.de
software design & management    
Thomas-Dehler-Str. 27, 81737 M√ľnchen, Germany
Tel +49 89 63812-392, Fax -220


reply via email to

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