24.3.1 编写次要模式的规范

与主模式一样,编写次要模式也有相应规范(see 主模式)。这些规范将在下面说明。遵循它们最简单的方式是使用宏 define-minor-mode。See 定义次要模式

此外,部分主模式规范(see 主模式编码规范)同样适用于次要模式:包括全局符号命名规范、初始化函数末尾使用钩子,以及按键映射和各类表的使用规范。

次要模式应尽可能支持通过自定义系统启用和关闭(see 自定义设置)。为此,模式变量应使用 defcustom 定义,通常指定 :type 'boolean。如果仅设置变量不足以启用模式,还应指定 :set 方法,通过调用模式命令来启用模式。在变量的文档字符串中说明:若非通过自定义系统设置该变量,可能不会生效。同时,使用自动加载标记标记该定义(see autoload cookie),并指定 :require,以便自定义该变量时会加载定义该模式的库。示例:

;;;###autoload
(defcustom msb-mode nil
  "Toggle msb-mode.
Setting this variable directly does not take effect;
use either \\[customize] or the function `msb-mode'."
  :set 'custom-set-minor-mode
  :initialize 'custom-initialize-default
  :version "20.4"
  :type    'boolean
  :group   'msb
  :require 'msb)

emacs

Emacs

org-mode

Orgmode

Donations

打赏

Copyright

© Jasper Hsu

Creative Commons

Creative Commons

Attribute

Attribute

Noncommercial

Noncommercial

Share Alike

Share Alike