Elisp: Abbrev Properties

By Anonymous. Date: . Last updated: .

Each Abbrev Has Properties

Each abbrev can have several properties that control its behavior. (e.g. Case-Sensitivity)

Abbrev Properties

Here is a complete list of abbrev properties.

:system

Stands for “system abbrev”. If t, don't save to user's abbrev file. Major mode's abbrev should be system abbrev.

:enable-function

a function that determines whether it should be expanded at the time. Value should be a function.

:case-fixed

t or nil (Letter Case Sensitivity)

:count

the number of time the abbrev has been expanded.

Add Abbrev Property

Add Abbrev Property to All Abbrevs

Get Abbrev Property

(abbrev-get 'd :case-fixed)

💡 TIP: if you attached abbrev properties to the abbrev table, you won't get it from abbrev-get

Properties for Abbrev Table

Abbrev table has a few of its own specific properties. (e.g. specifying a parent table)

Abbrev table functions e.g. define-abbrev-table, also accept properties that are for abbrev. e.g. if :case-fixed is given to a abbrev table, the expansion of all abbrevs in the table will be considered to have that property as if the abbrev itself has that property. (but the abbrev does not actually have that property)

Properties for Abbrev Table

:regexp
  • regex to determine how far back to grab as the abbrev symbol.
  • the first captured group is used to consider for abbrev.

By default, it only get characters that have word syntax (by default, word syntax means letters and 0 to 9, but not dash - or lowline _.). [see Elisp: Syntax Table]

💡 TIP: usually you need to have a boundary marker in front, else backward regex search won't go far back.

;; example of regexp property for abbrev table
;; this grabs letters and hyphen before point
:regexp "\\(\\_<[-a-z]+\\)"
:parents

A list of parent abbrev tables. Value should be a list, each element should be a variable, not quoted symbol, e.g. (list lisp-mode-abbrev-table)

:abbrev-table-modiff

total number of abbrev.

Add Property to Abbrev Table

(abbrev-table-put xx-abbrev-table :case-fixed t)
(abbrev-table-put xx-abbrev-table :system t)

or when you define the table:

Get property of Abbrev Table

(abbrev-table-get xx-mode-abbrev-table :regexp)

Abbrev Properties Are Not Normal Symbol Property List

Note: abbrev properties and abbrev table properties are not the normal Symbol Property List.

For example, if you use symbol-plist to get whole list of properties, it doesn't work.

Elisp, creating abbrev