Elisp: Symbol Property List
Each lisp symbol is associated with a “property list”.
[see Elisp: Property List]
This property list is stored in the symbol's property list cell. [see Elisp: Lisp Symbol]
Emacs lisp property list is used extensively in emacs. It is also very useful if you want to write a function with state. You can store the state info with the symbol itself, instead of using a global variable.
Set Whole Plist
setplist SYMBOL NEWPLIST)
Set SYMBOL's property list to NEWPLIST, and return NEWPLIST.
;; set the value of symbol ff's property list (setplist 'ff '(a 1 b 2))
Get Whole Plist
Return SYMBOL's property list.
;; get the value of symbol ff's property list (symbol-plist 'ff )
Add/Set a Key's Value
put SYMBOL PROPNAME VALUE)
Store SYMBOL's PROPNAME property with value VALUE.
;; set the value of key xx, of symbol ff's property list (put 'ff 'xx 5)
Get a Key's Value
get SYMBOL PROPNAME)
Return the value of SYMBOL's PROPNAME property.
;; get the value of key xx, of symbol ff's property list (get 'ff 'xx)
(info "(elisp) Symbol Properties")
Example of Using Symbol Properties
Elisp: How to Write a Toggle Command