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

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

Re: writing an own version of setq?


From: Dave Pearson
Subject: Re: writing an own version of setq?
Date: 10 Oct 2002 11:53:04 GMT
User-agent: slrn/0.9.7.4 (Linux)

* Klaus Berndl <Klaus.Berndl@sdm.de>:

> ,----
> | (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?

How about this:

-- cut here ----------------------------------------------------------------
(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))
        (setq ,option ,value)))
-- cut here ----------------------------------------------------------------

It might not be important to you but you might want to note that your `setq'
doesn't quite work the same as `setq' itself. `setq' takes multiple sym/val
pairs.

-- 
Dave Pearson:                   |     lbdb.el - LBDB interface.
http://www.davep.org/           |  sawfish.el - Sawfish mode.
Emacs:                          |  uptimes.el - Record emacs uptimes.
http://www.davep.org/emacs/     | quickurl.el - Recall lists of URLs.


reply via email to

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