Function: plist-put
plist-put is a function defined in fns.c.
Signature
(plist-put PLIST PROP VAL &optional PREDICATE)
Documentation
Change value in PLIST of PROP to VAL.
PLIST is a property list, which is a list of the form
(PROP1 VALUE1 PROP2 VALUE2 ...).
The comparison with PROP is done using PREDICATE, which defaults to eq.
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.
Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 19.29.
Shortdoc
;; list
(setq plist (plist-put plist 'd 4))
e.g. => (a 1 b 2 c 3 d 4)
Aliases
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
if (NILP (predicate))
return plist_put (plist, prop, val);
Lisp_Object prev = Qnil, tail = plist;
FOR_EACH_TAIL (tail)
{
if (! CONSP (XCDR (tail)))
break;
if (!NILP (call2 (predicate, XCAR (tail), prop)))
{
Fsetcar (XCDR (tail), val);
return plist;
}
prev = tail;
tail = XCDR (tail);
}
CHECK_TYPE (NILP (tail), Qplistp, plist);
Lisp_Object newcell
= Fcons (prop, Fcons (val, NILP (prev) ? plist : XCDR (XCDR (prev))));
if (NILP (prev))
return newcell;
Fsetcdr (XCDR (prev), newcell);
return plist;
}