user2879704
user2879704

Reputation:

symbol-plist returns a list for an elisp symbol with value

 (symbol-plist 'default-directory)

returns

(permanent-local t safe-local-variable stringp variable-documentation 341707)

How to understand the plist of default-directory symbol in elisp? (or) what does the six list elements in symbol plist represent?

Note: default-directory is a symbol with the current elisp script dir as its value.

Upvotes: 2

Views: 389

Answers (2)

Lindydancer
Lindydancer

Reputation: 26134

A property list conceptually maps keys to values. The representation is a plain list on the form (KEY1 VALUE1 KEY2 VAULE2 KEY3 VALUE3 ...).

In other words, you should read the property list so that permanent-local has the value t, safe-local-variable has the value stringp and variable-documentation the value 341707.

You can use plist-get to get a value of a key. Unfortunately, with this function you can't tell apart a property with the value nil and the case where the key is missing. Fortunately, you can use plist-member for this, it returns the rest of the list starting with the key, or nil if the key is missing.

Upvotes: 2

abo-abo
abo-abo

Reputation: 20362

See Standard Symbol Properties in the manual. Any others any package can randomly add with put.

Upvotes: 0

Related Questions