diff options
| author | Lute Kamstra | 2005-05-12 13:23:31 +0000 |
|---|---|---|
| committer | Lute Kamstra | 2005-05-12 13:23:31 +0000 |
| commit | 7e8035019d4729795d9c2536f6d33ffd631e49eb (patch) | |
| tree | 8c2e50ae1fdfa5352d8b12ccb7df88d0d0580d4c | |
| parent | 28e7aba4fd2bc5e3178ce4a4358722a327808538 (diff) | |
| download | emacs-7e8035019d4729795d9c2536f6d33ffd631e49eb.tar.gz emacs-7e8035019d4729795d9c2536f6d33ffd631e49eb.zip | |
(define-generic-mode): Don't generate a defcustom for the mode hook
variable. Delete the last argument.
| -rw-r--r-- | lisp/emacs-lisp/generic.el | 74 |
1 files changed, 24 insertions, 50 deletions
diff --git a/lisp/emacs-lisp/generic.el b/lisp/emacs-lisp/generic.el index 03f389aa4d1..4d778bf35c6 100644 --- a/lisp/emacs-lisp/generic.el +++ b/lisp/emacs-lisp/generic.el | |||
| @@ -117,46 +117,37 @@ instead (which see).") | |||
| 117 | ;;;###autoload | 117 | ;;;###autoload |
| 118 | (defmacro define-generic-mode (mode comment-list keyword-list | 118 | (defmacro define-generic-mode (mode comment-list keyword-list |
| 119 | font-lock-list auto-mode-list | 119 | font-lock-list auto-mode-list |
| 120 | function-list &optional docstring | 120 | function-list &optional docstring) |
| 121 | &rest custom-keyword-args) | ||
| 122 | "Create a new generic mode MODE. | 121 | "Create a new generic mode MODE. |
| 123 | 122 | ||
| 124 | MODE is the name of the command for the generic mode; don't quote | 123 | MODE is the name of the command for the generic mode; don't quote it. |
| 125 | it. The optional DOCSTRING is the documentation for the mode | 124 | The optional DOCSTRING is the documentation for the mode command. If |
| 126 | command. If you do not supply it, `define-generic-mode' uses a | 125 | you do not supply it, `define-generic-mode' uses a default |
| 127 | default documentation string instead. | 126 | documentation string instead. |
| 128 | 127 | ||
| 129 | COMMENT-LIST is a list in which each element is either a | 128 | COMMENT-LIST is a list in which each element is either a character, a |
| 130 | character, a string of one or two characters, or a cons cell. A | 129 | string of one or two characters, or a cons cell. A character or a |
| 131 | character or a string is set up in the mode's syntax table as a | 130 | string is set up in the mode's syntax table as a \"comment starter\". |
| 132 | \"comment starter\". If the entry is a cons cell, the `car' is | 131 | If the entry is a cons cell, the `car' is set up as a \"comment |
| 133 | set up as a \"comment starter\" and the `cdr' as a \"comment | 132 | starter\" and the `cdr' as a \"comment ender\". (Use nil for the |
| 134 | ender\". (Use nil for the latter if you want comments to end at | 133 | latter if you want comments to end at the end of the line.) Note that |
| 135 | the end of the line.) Note that the syntax table has limitations | 134 | the syntax table has limitations about what comment starters and |
| 136 | about what comment starters and enders are actually possible. | 135 | enders are actually possible. |
| 137 | 136 | ||
| 138 | KEYWORD-LIST is a list of keywords to highlight with | 137 | KEYWORD-LIST is a list of keywords to highlight with |
| 139 | `font-lock-keyword-face'. Each keyword should be a string. | 138 | `font-lock-keyword-face'. Each keyword should be a string. |
| 140 | 139 | ||
| 141 | FONT-LOCK-LIST is a list of additional expressions to highlight. | 140 | FONT-LOCK-LIST is a list of additional expressions to highlight. Each |
| 142 | Each element of this list should have the same form as an element | 141 | element of this list should have the same form as an element of |
| 143 | of `font-lock-keywords'. | 142 | `font-lock-keywords'. |
| 144 | 143 | ||
| 145 | AUTO-MODE-LIST is a list of regular expressions to add to | 144 | AUTO-MODE-LIST is a list of regular expressions to add to |
| 146 | `auto-mode-alist'. These regular expressions are added when | 145 | `auto-mode-alist'. These regular expressions are added when Emacs |
| 147 | Emacs runs the macro expansion. | 146 | runs the macro expansion. |
| 148 | 147 | ||
| 149 | FUNCTION-LIST is a list of functions to call to do some | 148 | FUNCTION-LIST is a list of functions to call to do some additional |
| 150 | additional setup. The mode command calls these functions just | 149 | setup. The mode command calls these functions just before it runs the |
| 151 | before it runs the mode hook. | 150 | mode hook `MODE-hook'. |
| 152 | |||
| 153 | The optional CUSTOM-KEYWORD-ARGS are pairs of keywords and values | ||
| 154 | to include in the generated `defcustom' form for the mode hook | ||
| 155 | variable `MODE-hook'. The default value for the `:group' keyword | ||
| 156 | is MODE with the final \"-mode\" (if any) removed. (Don't use | ||
| 157 | this default group name unless you have written a `defgroup' to | ||
| 158 | define that group properly.) You can specify keyword arguments | ||
| 159 | without specifying a docstring. | ||
| 160 | 151 | ||
| 161 | See the file generic-x.el for some examples of `define-generic-mode'." | 152 | See the file generic-x.el for some examples of `define-generic-mode'." |
| 162 | (declare (debug (sexp def-form def-form def-form form def-form | 153 | (declare (debug (sexp def-form def-form def-form form def-form |
| @@ -167,22 +158,9 @@ See the file generic-x.el for some examples of `define-generic-mode'." | |||
| 167 | (when (eq (car-safe mode) 'quote) | 158 | (when (eq (car-safe mode) 'quote) |
| 168 | (setq mode (eval mode))) | 159 | (setq mode (eval mode))) |
| 169 | 160 | ||
| 170 | (when (and docstring (not (stringp docstring))) | ||
| 171 | ;; DOCSTRING is not a string so we assume that it's actually the | ||
| 172 | ;; first keyword of CUSTOM-KEYWORD-ARGS. | ||
| 173 | (push docstring custom-keyword-args) | ||
| 174 | (setq docstring nil)) | ||
| 175 | |||
| 176 | (let* ((name (symbol-name mode)) | 161 | (let* ((name (symbol-name mode)) |
| 177 | (pretty-name (capitalize (replace-regexp-in-string | 162 | (pretty-name (capitalize (replace-regexp-in-string |
| 178 | "-mode\\'" "" name))) | 163 | "-mode\\'" "" name)))) |
| 179 | (mode-hook (intern (concat name "-hook")))) | ||
| 180 | |||
| 181 | (unless (plist-get custom-keyword-args :group) | ||
| 182 | (setq custom-keyword-args | ||
| 183 | (plist-put custom-keyword-args | ||
| 184 | :group `',(intern (replace-regexp-in-string | ||
| 185 | "-mode\\'" "" name))))) | ||
| 186 | 164 | ||
| 187 | `(progn | 165 | `(progn |
| 188 | ;; Add a new entry. | 166 | ;; Add a new entry. |
| @@ -192,15 +170,11 @@ See the file generic-x.el for some examples of `define-generic-mode'." | |||
| 192 | (dolist (re ,auto-mode-list) | 170 | (dolist (re ,auto-mode-list) |
| 193 | (add-to-list 'auto-mode-alist (cons re ',mode))) | 171 | (add-to-list 'auto-mode-alist (cons re ',mode))) |
| 194 | 172 | ||
| 195 | (defcustom ,mode-hook nil | ||
| 196 | ,(concat "Hook run when entering " pretty-name " mode.") | ||
| 197 | :type 'hook | ||
| 198 | ,@custom-keyword-args) | ||
| 199 | |||
| 200 | (defun ,mode () | 173 | (defun ,mode () |
| 201 | ,(or docstring | 174 | ,(or docstring |
| 202 | (concat pretty-name " mode.\n" | 175 | (concat pretty-name " mode.\n" |
| 203 | "This a generic mode defined with `define-generic-mode'.")) | 176 | "This a generic mode defined with `define-generic-mode'.\n" |
| 177 | "It runs `" name "-hook' as the last thing it does.")) | ||
| 204 | (interactive) | 178 | (interactive) |
| 205 | (generic-mode-internal ',mode ,comment-list ,keyword-list | 179 | (generic-mode-internal ',mode ,comment-list ,keyword-list |
| 206 | ,font-lock-list ,function-list))))) | 180 | ,font-lock-list ,function-list))))) |