Function: define-abbrev-table
define-abbrev-table is a byte-compiled function defined in
abbrev.el.gz.
Signature
(define-abbrev-table TABLENAME DEFINITIONS &optional DOCSTRING &rest PROPS)
Documentation
Define TABLENAME (a symbol) as an abbrev table name.
Define abbrevs in it according to DEFINITIONS, which is a list of elements
of the form (ABBREVNAME EXPANSION ...) that are passed to define-abbrev.
PROPS is a property list to apply to the table.
Properties with special meaning:
- :parents contains a list of abbrev tables from which this table inherits
abbreviations.
- :case-fixed non-nil means that abbreviations are looked up without
case-folding, and the expansion is not capitalized/upcased.
- :regexp is a regular expression that specifies how to extract the
name of the abbrev before point. The submatch 1 is treated
as the potential name of an abbrev. If :regexp is nil, the default
behavior uses backward-word and forward-word to extract the name
of the abbrev, which can therefore by default only be a single word.
- :enable-function can be set to a function of no arguments which returns
non-nil if and only if the abbrevs in this table should be used for this
instance of expand-abbrev.
Probably introduced at or before Emacs version 23.1.
Source Code
;; Defined in /usr/src/emacs/lisp/abbrev.el.gz
(defun define-abbrev-table (tablename definitions
&optional docstring &rest props)
"Define TABLENAME (a symbol) as an abbrev table name.
Define abbrevs in it according to DEFINITIONS, which is a list of elements
of the form (ABBREVNAME EXPANSION ...) that are passed to `define-abbrev'.
PROPS is a property list to apply to the table.
Properties with special meaning:
- `:parents' contains a list of abbrev tables from which this table inherits
abbreviations.
- `:case-fixed' non-nil means that abbreviations are looked up without
case-folding, and the expansion is not capitalized/upcased.
- `:regexp' is a regular expression that specifies how to extract the
name of the abbrev before point. The submatch 1 is treated
as the potential name of an abbrev. If `:regexp' is nil, the default
behavior uses `backward-word' and `forward-word' to extract the name
of the abbrev, which can therefore by default only be a single word.
- `:enable-function' can be set to a function of no arguments which returns
non-nil if and only if the abbrevs in this table should be used for this
instance of `expand-abbrev'."
(declare (doc-string 3) (indent defun))
;; We used to manually add the docstring, but we also want to record this
;; location as the definition of the variable (in load-history), so we may
;; as well just use `defvar'.
(when (and docstring props (symbolp docstring))
;; There is really no docstring, instead the docstring arg
;; is a property name.
(push docstring props) (setq docstring nil))
(defvar-1 tablename nil docstring)
(let ((table (if (boundp tablename) (symbol-value tablename))))
(unless table
(setq table (make-abbrev-table))
(set tablename table)
(unless (memq tablename abbrev-table-name-list)
(push tablename abbrev-table-name-list)))
;; We used to just pass them to `make-abbrev-table', but that fails
;; if the table was pre-existing as is the case if it was created by
;; loading the user's abbrev file.
(while (consp props)
(unless (cdr props) (error "Missing value for property %S" (car props)))
(abbrev-table-put table (pop props) (pop props)))
(dolist (elt definitions)
(apply #'define-abbrev table elt))))