39.1 缩写表

本节介绍如何创建与操作缩写表。

Function: make-abbrev-table &optional props

该函数创建并返回一个新的空缩写表— 一个不包含任何符号的对象数组。 props 为应用于新表的属性列表 (see 缩写表属性)。

Function: abbrev-table-p object

object 为缩写表, 该函数返回非 nil 值。

Function: clear-abbrev-table abbrev-table

该函数取消定义 abbrev-table 中的所有缩写, 使其变为空表。

Function: copy-abbrev-table abbrev-table

该函数返回 abbrev-table 的副本— 一个包含相同缩写定义的新缩写表。 它 不会 复制任何属性列表;仅复制名称、值与函数。

Function: define-abbrev-table tabname definitions &optional docstring &rest props

该函数将 tabname(一个符号)定义为缩写表名, 即作为一个值为缩写表的变量。 它根据 definitions 在表中定义缩写, 该参数是一个列表,元素格式为 (abbrevname expansion [hook] [props...])。 这些元素会作为参数传递给 define-abbrev

可选字符串 docstring 为变量 tabname 的文档字符串。 属性列表 props 应用于该缩写表 (see 缩写表属性)。

若对同一 tabname 多次调用该函数, 后续调用会将 definitions 中的定义追加到 tabname,而非覆盖原有全部内容。 (后续调用仅覆盖在 definitions 中显式重定义或取消定义的缩写。)

Variable: abbrev-table-name-list

该列表中的符号,其值均为缩写表。 define-abbrev-table 会将新的缩写表名加入此列表。

Function: insert-abbrev-table-description name &optional human

该函数在光标前插入名为 name 的缩写表的描述。 参数 name 是一个值为缩写表的符号。

human 为非 nil,描述面向人类阅读, 系统缩写会被列出并标识。 否则描述为一个 Lisp 表达式— 一个对 define-abbrev-table 的调用, 可按当前定义重建 name,但不包含系统缩写。 (使用 name 的模式或包应单独将这些系统缩写加入 name。)