Emacs Lisp: Symbol Property List

By Xah Lee. Date: . Last updated: .

Each lisp symbol is associated with a Property List .

This property list is stored in the Symbol's property list cell.

Symbol 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
(setplist SYMBOL NEWPLIST)
Set SYMBOL's property list to NEWPLIST, and return NEWPLIST.
(setplist 'ff '(a 1 b 2))

Get Whole Plist

symbol-plist
(symbol-plist SYMBOL)
Return SYMBOL's property list.

Add/Set a Key

put
(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
(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)

Example of Using Symbol Properties

Reference

Lisp Data Structure

List

Specialized Lists

Vector

Sequence (List, Vector)

Hash Table