unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Dave Pearson <davep.news@davep.org>
Subject: Re: writing an own version of setq?
Date: 10 Oct 2002 11:53:04 GMT	[thread overview]
Message-ID: <slrnaqaqh0.i0f.davep.news@hagbard.davep.org> (raw)
In-Reply-To: uofa3c34r.fsf@sdm.de

* 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.

      parent reply	other threads:[~2002-10-10 11:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-09 10:34 writing an own version of setq? Klaus Berndl
2002-10-09 13:09 ` Thomas Link
2002-10-09 13:48   ` Klaus Berndl
2002-10-09 14:20     ` Thomas Link
2002-10-09 14:44       ` Klaus Berndl
2002-10-10 11:53 ` Dave Pearson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=slrnaqaqh0.i0f.davep.news@hagbard.davep.org \
    --to=davep.news@davep.org \
    --cc=davep@davep.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).