Emacs Lisp: Symbol Property List

By Xah Lee. Date: .

Each lisp symbol is associated with a “property list”.

〔►see Emacs Lisp Property List

This property list is stored in the symbol's property list cell. 〔►see Emacs Lisp: What's 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.

Accessing Symbol's Property List

Here's most useful functions to access symbol's property list:

;; set the value of key xx, of symbol ff's property list
(put 'ff 'xx 5)
;; get the value of key xx, of symbol ff's property list
(get 'ff 'xx) ; nil
;; get the value of symbol ff's property list
(symbol-plist 'ff )

;; set the value of symbol ff's property list
(setplist 'ff '(a 1 b 2))

(info "(elisp) Symbol Properties")

See also Emacs Lisp Property List

Examples of Using Symbol Properties

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs