aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLute Kamstra2005-05-12 13:23:31 +0000
committerLute Kamstra2005-05-12 13:23:31 +0000
commit7e8035019d4729795d9c2536f6d33ffd631e49eb (patch)
tree8c2e50ae1fdfa5352d8b12ccb7df88d0d0580d4c
parent28e7aba4fd2bc5e3178ce4a4358722a327808538 (diff)
downloademacs-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.el74
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
124MODE is the name of the command for the generic mode; don't quote 123MODE is the name of the command for the generic mode; don't quote it.
125it. The optional DOCSTRING is the documentation for the mode 124The optional DOCSTRING is the documentation for the mode command. If
126command. If you do not supply it, `define-generic-mode' uses a 125you do not supply it, `define-generic-mode' uses a default
127default documentation string instead. 126documentation string instead.
128 127
129COMMENT-LIST is a list in which each element is either a 128COMMENT-LIST is a list in which each element is either a character, a
130character, a string of one or two characters, or a cons cell. A 129string of one or two characters, or a cons cell. A character or a
131character or a string is set up in the mode's syntax table as a 130string 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 131If the entry is a cons cell, the `car' is set up as a \"comment
133set up as a \"comment starter\" and the `cdr' as a \"comment 132starter\" and the `cdr' as a \"comment ender\". (Use nil for the
134ender\". (Use nil for the latter if you want comments to end at 133latter if you want comments to end at the end of the line.) Note that
135the end of the line.) Note that the syntax table has limitations 134the syntax table has limitations about what comment starters and
136about what comment starters and enders are actually possible. 135enders are actually possible.
137 136
138KEYWORD-LIST is a list of keywords to highlight with 137KEYWORD-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
141FONT-LOCK-LIST is a list of additional expressions to highlight. 140FONT-LOCK-LIST is a list of additional expressions to highlight. Each
142Each element of this list should have the same form as an element 141element of this list should have the same form as an element of
143of `font-lock-keywords'. 142`font-lock-keywords'.
144 143
145AUTO-MODE-LIST is a list of regular expressions to add to 144AUTO-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
147Emacs runs the macro expansion. 146runs the macro expansion.
148 147
149FUNCTION-LIST is a list of functions to call to do some 148FUNCTION-LIST is a list of functions to call to do some additional
150additional setup. The mode command calls these functions just 149setup. The mode command calls these functions just before it runs the
151before it runs the mode hook. 150mode hook `MODE-hook'.
152
153The optional CUSTOM-KEYWORD-ARGS are pairs of keywords and values
154to include in the generated `defcustom' form for the mode hook
155variable `MODE-hook'. The default value for the `:group' keyword
156is MODE with the final \"-mode\" (if any) removed. (Don't use
157this default group name unless you have written a `defgroup' to
158define that group properly.) You can specify keyword arguments
159without specifying a docstring.
160 151
161See the file generic-x.el for some examples of `define-generic-mode'." 152See 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)))))