unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Lennart Borgman \(gmail\)" <lennart.borgman@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: add-list local value
Date: Wed, 12 Mar 2008 09:51:11 -0400	[thread overview]
Message-ID: <jwv3aqwulnp.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <47D73D5B.4070502@gmail.com> (Lennart Borgman's message of "Wed,  12 Mar 2008 03:18:03 +0100")

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




  parent reply	other threads:[~2008-03-12 13:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12  0:54 add-list local value Lennart Borgman (gmail)
2008-03-12  1:51 ` Stefan Monnier
2008-03-12  2:18   ` Lennart Borgman (gmail)
2008-03-12  8:41     ` Juanma Barranquero
2008-03-12  8:49       ` Lennart Borgman (gmail)
2008-03-12 13:51     ` Stefan Monnier [this message]
2008-03-12 17:51     ` Richard Stallman

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=jwv3aqwulnp.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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