diff options
| -rw-r--r-- | lisp/emacs-lisp/easy-mmode.el | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 8f89d92a057..abd045a6532 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el | |||
| @@ -90,11 +90,12 @@ BODY contains code that will be executed each time the mode is (dis)activated. | |||
| 90 | It will be executed after any toggling but before running the hooks. | 90 | It will be executed after any toggling but before running the hooks. |
| 91 | BODY can start with a list of CL-style keys specifying additional arguments. | 91 | BODY can start with a list of CL-style keys specifying additional arguments. |
| 92 | The following keyword arguments are supported: | 92 | The following keyword arguments are supported: |
| 93 | :group Followed by the group name to use for any generated `defcustom'. | 93 | :group GROUP Group name to use for any generated `defcustom'. |
| 94 | :global If non-nil specifies that the minor mode is not meant to be | 94 | :global GLOBAL If non-nil specifies that the minor mode is not meant to be |
| 95 | buffer-local. By default, the variable is made buffer-local. | 95 | buffer-local. By default, the variable is made buffer-local. |
| 96 | :init-value Same as the INIT-VALUE argument. | 96 | :init-value VAL Same as the INIT-VALUE argument. |
| 97 | :lighter Same as the LIGHTER argument." | 97 | :lighter SPEC Same as the LIGHTER argument. |
| 98 | :require SYM Same as defcustom's :require argument." | ||
| 98 | ;; Allow skipping the first three args. | 99 | ;; Allow skipping the first three args. |
| 99 | (cond | 100 | (cond |
| 100 | ((keywordp init-value) | 101 | ((keywordp init-value) |
| @@ -109,6 +110,7 @@ BODY contains code that will be executed each time the mode is (dis)activated. | |||
| 109 | (globalp nil) | 110 | (globalp nil) |
| 110 | (group nil) | 111 | (group nil) |
| 111 | (extra-args nil) | 112 | (extra-args nil) |
| 113 | (require t) | ||
| 112 | (keymap-sym (if (and keymap (symbolp keymap)) keymap | 114 | (keymap-sym (if (and keymap (symbolp keymap)) keymap |
| 113 | (intern (concat mode-name "-map")))) | 115 | (intern (concat mode-name "-map")))) |
| 114 | (hook (intern (concat mode-name "-hook"))) | 116 | (hook (intern (concat mode-name "-hook"))) |
| @@ -123,6 +125,7 @@ BODY contains code that will be executed each time the mode is (dis)activated. | |||
| 123 | (:global (setq globalp (pop body))) | 125 | (:global (setq globalp (pop body))) |
| 124 | (:extra-args (setq extra-args (pop body))) | 126 | (:extra-args (setq extra-args (pop body))) |
| 125 | (:group (setq group (nconc group (list :group (pop body))))) | 127 | (:group (setq group (nconc group (list :group (pop body))))) |
| 128 | (:require (setq require (pop body))) | ||
| 126 | (t (pop body)))) | 129 | (t (pop body)))) |
| 127 | 130 | ||
| 128 | (unless group | 131 | (unless group |
| @@ -159,12 +162,12 @@ use either \\[customize] or the function `%s'." | |||
| 159 | :initialize 'custom-initialize-default | 162 | :initialize 'custom-initialize-default |
| 160 | ,@group | 163 | ,@group |
| 161 | :type 'boolean | 164 | :type 'boolean |
| 162 | ,@(when curfile | 165 | ,@(cond |
| 163 | (list | 166 | ((not (and curfile require)) nil) |
| 164 | :require | 167 | ((not (eq require t)) `(:require ,require)) |
| 165 | (list 'quote | 168 | (t `(:require |
| 166 | (intern (file-name-nondirectory | 169 | ',(intern (file-name-nondirectory |
| 167 | (file-name-sans-extension curfile))))))))) | 170 | (file-name-sans-extension curfile))))))))) |
| 168 | 171 | ||
| 169 | ;; The actual function. | 172 | ;; The actual function. |
| 170 | (defun ,mode (&optional arg ,@extra-args) | 173 | (defun ,mode (&optional arg ,@extra-args) |
| @@ -224,7 +227,7 @@ With zero or negative ARG turn mode off. | |||
| 224 | (symbol-value ',keymap-sym)))) | 227 | (symbol-value ',keymap-sym)))) |
| 225 | 228 | ||
| 226 | ;; If the mode is global, call the function according to the default. | 229 | ;; If the mode is global, call the function according to the default. |
| 227 | ,(if globalp | 230 | ,(if (and globalp (null init-value)) |
| 228 | `(if (and load-file-name ,mode) | 231 | `(if (and load-file-name ,mode) |
| 229 | (eval-after-load load-file-name '(,mode 1))))))) | 232 | (eval-after-load load-file-name '(,mode 1))))))) |
| 230 | 233 | ||