Elisp: Abbrev Hook
Abbrev's Hook
The last step of abbrev expansion is a hook function for the abbrev.
The hook can be added for each abbrev using
define-abbrev-table
or
define-abbrev
If this hook function returns true, and has
Symbol Property
no-self-insert
true, then the char that triggered the abbrev will not be inserted.
;; example of abbrev hook ;; attaching a hook when defining an abbrev (define-abbrev xx-abbrev-table "fn" "function" xx--abhook) (defun xx--abhook () "Abbrev hook function, used for `define-abbrev'. Move cursor back to ▮. Also, has property `no-self-insert'." (when (search-backward "▮" (max (point-min) (- (point) 200)) t) (delete-char 1)) t) ;; prevent inserting the char that triggered expansion (put 'xx--abhook 'no-self-insert t)