all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (setq x (plist-put x :new 'value))
@ 2009-08-21 22:08 Mario Lang
  2009-08-21 22:49 ` Harald Hanche-Olsen
  0 siblings, 1 reply; 2+ messages in thread
From: Mario Lang @ 2009-08-21 22:08 UTC (permalink / raw)
  To: emacs-devel

Hi.

The docstring of plist-put reads:

---<snip>---
(plist-put PLIST PROP VAL)

Change value in PLIST of PROP to VAL.
PLIST is a property list, which is a list of the form
(PROP1 VALUE1 PROP2 VALUE2 ...).  PROP is a symbol and VAL is any object.
If PROP is already a property on the list, its value is set to VAL,
otherwise the new PROP VAL pair is added.  The new plist is returned;
use `(setq x (plist-put x prop val))' to be sure to use the new value.
The PLIST is modified by side effects.
---<snip>---

The last two lines seem like they are contradicting each other.
In fact, what plist-put really does if it has to add a new item is
setcdr on the last cons in the list.  I kind of feel the second last line
in the docstring should be removed, since (setq x (plist-put x prop val))
is not necessary.  Or am I missing something?

--- a/src/fns.c
+++ b/src/fns.c
@@ -2005,8 +2005,7 @@ DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0,
 PLIST is a property list, which is a list of the form
 \(PROP1 VALUE1 PROP2 VALUE2 ...).  PROP is a symbol and VAL is any object.
 If PROP is already a property on the list, its value is set to VAL,
-otherwise the new PROP VAL pair is added.  The new plist is returned;
-use `(setq x (plist-put x prop val))' to be sure to use the new value.
+otherwise the new PROP VAL pair is added.  The new plist is returned.
 The PLIST is modified by side effects.  */)
      (plist, prop, val)
      Lisp_Object plist;

-- 
CYa,
  ⡍⠁⠗⠊⠕




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: (setq x (plist-put x :new 'value))
  2009-08-21 22:08 (setq x (plist-put x :new 'value)) Mario Lang
@ 2009-08-21 22:49 ` Harald Hanche-Olsen
  0 siblings, 0 replies; 2+ messages in thread
From: Harald Hanche-Olsen @ 2009-08-21 22:49 UTC (permalink / raw)
  To: emacs-devel

+ Mario Lang <mlang@delysid.org>:

> The docstring of plist-put reads:
> 
> ---<snip>---
> [...]
> otherwise the new PROP VAL pair is added.  The new plist is returned;
> use `(setq x (plist-put x prop val))' to be sure to use the new value.
> The PLIST is modified by side effects.
> ---<snip>---
> 
> The last two lines seem like they are contradicting each other.
> In fact, what plist-put really does if it has to add a new item is
> setcdr on the last cons in the list.  I kind of feel the second last line
> in the docstring should be removed, since (setq x (plist-put x prop val))
> is not necessary.  Or am I missing something?

Yes: the plist could be empty in the first place.

(setq plist nil)
(plist-put plist :foo :bar) ; => (:foo :bar)
plist ; => nil

- Harald




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-21 22:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-21 22:08 (setq x (plist-put x :new 'value)) Mario Lang
2009-08-21 22:49 ` Harald Hanche-Olsen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.