Add "Package:" file headers to denote built-in packages.
[emacs.git] / lisp / emacs-lisp / easy-mmode.el
blobe11572dfc627521c26f3bd2230b39acdbee2ca65
1 ;;; easy-mmode.el --- easy definition for major and minor modes
3 ;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Georges Brun-Cottan <Georges.Brun-Cottan@inria.fr>
7 ;; Maintainer: Stefan Monnier <monnier@gnu.org>
8 ;; Package: emacs
10 ;; Keywords: extensions lisp
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;;; Commentary:
29 ;; Minor modes are useful and common. This package makes defining a
30 ;; minor mode easy, by focusing on the writing of the minor mode
31 ;; functionalities themselves. Moreover, this package enforces a
32 ;; conventional naming of user interface primitives, making things
33 ;; natural for the minor-mode end-users.
35 ;; For each mode, easy-mmode defines the following:
36 ;; <mode> : The minor mode predicate. A buffer-local variable.
37 ;; <mode>-map : The keymap possibly associated to <mode>.
38 ;; see `define-minor-mode' documentation
40 ;; eval
41 ;; (pp (macroexpand '(define-minor-mode <your-mode> <doc>)))
42 ;; to check the result before using it.
44 ;; The order in which minor modes are installed is important. Keymap
45 ;; lookup proceeds down minor-mode-map-alist, and the order there
46 ;; tends to be the reverse of the order in which the modes were
47 ;; installed. Perhaps there should be a feature to let you specify
48 ;; orderings.
50 ;; Additionally to `define-minor-mode', the package provides convenient
51 ;; ways to define keymaps, and other helper functions for major and minor modes.
53 ;;; Code:
55 (eval-when-compile (require 'cl))
57 (defun easy-mmode-pretty-mode-name (mode &optional lighter)
58 "Turn the symbol MODE into a string intended for the user.
59 If provided, LIGHTER will be used to help choose capitalization by,
60 replacing its case-insensitive matches with the literal string in LIGHTER."
61 (let* ((case-fold-search t)
62 ;; Produce "Foo-Bar minor mode" from foo-bar-minor-mode.
63 (name (concat (replace-regexp-in-string
64 ;; If the original mode name included "-minor" (some
65 ;; of them don't, e.g. auto-revert-mode), then
66 ;; replace it with " minor".
67 "-Minor" " minor"
68 ;; "foo-bar-minor" -> "Foo-Bar-Minor"
69 (capitalize (replace-regexp-in-string
70 ;; "foo-bar-minor-mode" -> "foo-bar-minor"
71 "-mode\\'" "" (symbol-name mode))))
72 " mode")))
73 (if (not (stringp lighter)) name
74 ;; Strip leading and trailing whitespace from LIGHTER.
75 (setq lighter (replace-regexp-in-string "\\`\\s-+\\|\\s-+\\'" ""
76 lighter))
77 ;; Replace any (case-insensitive) matches for LIGHTER in NAME
78 ;; with a literal LIGHTER. E.g., if NAME is "Iimage mode" and
79 ;; LIGHTER is " iImag", then this will produce "iImage mode".
80 ;; (LIGHTER normally comes from the mode-line string passed to
81 ;; define-minor-mode, and normally includes at least one leading
82 ;; space.)
83 (replace-regexp-in-string (regexp-quote lighter) lighter name t t))))
85 ;;;###autoload
86 (defalias 'easy-mmode-define-minor-mode 'define-minor-mode)
87 ;;;###autoload
88 (defmacro define-minor-mode (mode doc &optional init-value lighter keymap &rest body)
89 "Define a new minor mode MODE.
90 This defines the control variable MODE and the toggle command MODE.
91 DOC is the documentation for the mode toggle command.
93 Optional INIT-VALUE is the initial value of the mode's variable.
94 Optional LIGHTER is displayed in the modeline when the mode is on.
95 Optional KEYMAP is the default keymap bound to the mode keymap.
96 If non-nil, it should be a variable name (whose value is a keymap),
97 a keymap, or a list of arguments for `easy-mmode-define-keymap'.
98 If KEYMAP is a keymap or list, this also defines the variable MODE-map.
100 BODY contains code to execute each time the mode is enabled or disabled.
101 It is executed after toggling the mode, and before running MODE-hook.
102 Before the actual body code, you can write keyword arguments, i.e.
103 alternating keywords and values. These following special keywords
104 are supported (other keywords are passed to `defcustom' if the minor
105 mode is global):
107 :group GROUP Custom group name to use in all generated `defcustom' forms.
108 Defaults to MODE without the possible trailing \"-mode\".
109 Don't use this default group name unless you have written a
110 `defgroup' to define that group properly.
111 :global GLOBAL If non-nil specifies that the minor mode is not meant to be
112 buffer-local, so don't make the variable MODE buffer-local.
113 By default, the mode is buffer-local.
114 :init-value VAL Same as the INIT-VALUE argument.
115 :lighter SPEC Same as the LIGHTER argument.
116 :keymap MAP Same as the KEYMAP argument.
117 :require SYM Same as in `defcustom'.
118 :variable PLACE The location (as can be used with `setf') to use instead
119 of the variable MODE to store the state of the mode. PLACE
120 can also be of the form (GET . SET) where GET is an expression
121 that returns the current state and SET is a function that takes
122 a new state and sets it.
124 For example, you could write
125 (define-minor-mode foo-mode \"If enabled, foo on you!\"
126 :lighter \" Foo\" :require 'foo :global t :group 'hassle :version \"27.5\"
127 ...BODY CODE...)"
128 (declare (debug (&define name stringp
129 [&optional [&not keywordp] sexp
130 &optional [&not keywordp] sexp
131 &optional [&not keywordp] sexp]
132 [&rest [keywordp sexp]]
133 def-body)))
135 ;; Allow skipping the first three args.
136 (cond
137 ((keywordp init-value)
138 (setq body (list* init-value lighter keymap body)
139 init-value nil lighter nil keymap nil))
140 ((keywordp lighter)
141 (setq body (list* lighter keymap body) lighter nil keymap nil))
142 ((keywordp keymap) (push keymap body) (setq keymap nil)))
144 (let* ((last-message (make-symbol "last-message"))
145 (mode-name (symbol-name mode))
146 (pretty-name (easy-mmode-pretty-mode-name mode lighter))
147 (globalp nil)
148 (set nil)
149 (initialize nil)
150 (group nil)
151 (type nil)
152 (extra-args nil)
153 (extra-keywords nil)
154 (variable nil) ;The PLACE where the state is stored.
155 (setter nil) ;The function (if any) to set the mode var.
156 (modefun mode) ;The minor mode function name we're defining.
157 (require t)
158 (hook (intern (concat mode-name "-hook")))
159 (hook-on (intern (concat mode-name "-on-hook")))
160 (hook-off (intern (concat mode-name "-off-hook")))
161 keyw keymap-sym)
163 ;; Check keys.
164 (while (keywordp (setq keyw (car body)))
165 (setq body (cdr body))
166 (case keyw
167 (:init-value (setq init-value (pop body)))
168 (:lighter (setq lighter (purecopy (pop body))))
169 (:global (setq globalp (pop body)))
170 (:extra-args (setq extra-args (pop body)))
171 (:set (setq set (list :set (pop body))))
172 (:initialize (setq initialize (list :initialize (pop body))))
173 (:group (setq group (nconc group (list :group (pop body)))))
174 (:type (setq type (list :type (pop body))))
175 (:require (setq require (pop body)))
176 (:keymap (setq keymap (pop body)))
177 (:variable (setq variable (pop body))
178 (if (not (functionp (cdr-safe variable)))
179 ;; PLACE is not of the form (GET . SET).
180 (setq mode variable)
181 (setq mode (car variable))
182 (setq setter (cdr variable))))
183 (t (push keyw extra-keywords) (push (pop body) extra-keywords))))
185 (setq keymap-sym (if (and keymap (symbolp keymap)) keymap
186 (intern (concat mode-name "-map"))))
188 (unless set (setq set '(:set 'custom-set-minor-mode)))
190 (unless initialize
191 (setq initialize '(:initialize 'custom-initialize-default)))
193 (unless group
194 ;; We might as well provide a best-guess default group.
195 (setq group
196 `(:group ',(intern (replace-regexp-in-string
197 "-mode\\'" "" mode-name)))))
199 (unless type (setq type '(:type 'boolean)))
201 `(progn
202 ;; Define the variable to enable or disable the mode.
203 ,(cond
204 ;; If :variable is specified, then the var will be
205 ;; declared elsewhere.
206 (variable nil)
207 ((not globalp)
208 `(progn
209 (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled.
210 Use the command `%s' to change this variable." pretty-name mode))
211 (make-variable-buffer-local ',mode)))
213 (let ((base-doc-string
214 (concat "Non-nil if %s is enabled.
215 See the command `%s' for a description of this minor mode."
216 (if body "
217 Setting this variable directly does not take effect;
218 either customize it (see the info node `Easy Customization')
219 or call the function `%s'."))))
220 `(defcustom ,mode ,init-value
221 ,(format base-doc-string pretty-name mode mode)
222 ,@set
223 ,@initialize
224 ,@group
225 ,@type
226 ,@(unless (eq require t) `(:require ,require))
227 ,@(nreverse extra-keywords)))))
229 ;; The actual function.
230 (defun ,modefun (&optional arg ,@extra-args)
231 ,(or doc
232 (format (concat "Toggle %s on or off.
233 Interactively, with no prefix argument, toggle the mode.
234 With universal prefix ARG turn mode on.
235 With zero or negative ARG turn mode off.
236 \\{%s}") pretty-name keymap-sym))
237 ;; Use `toggle' rather than (if ,mode 0 1) so that using
238 ;; repeat-command still does the toggling correctly.
239 (interactive (list (or current-prefix-arg 'toggle)))
240 (let ((,last-message (current-message)))
241 (,@(if setter (list setter)
242 (list (if (symbolp mode) 'setq 'setf) mode))
243 (if (eq arg 'toggle)
244 (not ,mode)
245 ;; A nil argument also means ON now.
246 (> (prefix-numeric-value arg) 0)))
247 ,@body
248 ;; The on/off hooks are here for backward compatibility only.
249 (run-hooks ',hook (if ,mode ',hook-on ',hook-off))
250 (if (called-interactively-p 'any)
251 (progn
252 ,(if (and globalp (symbolp mode))
253 `(customize-mark-as-set ',mode))
254 ;; Avoid overwriting a message shown by the body,
255 ;; but do overwrite previous messages.
256 (unless (and (current-message)
257 (not (equal ,last-message
258 (current-message))))
259 (message ,(format "%s %%sabled" pretty-name)
260 (if ,mode "en" "dis"))))))
261 (force-mode-line-update)
262 ;; Return the new setting.
263 ,mode)
265 ;; Autoloading a define-minor-mode autoloads everything
266 ;; up-to-here.
267 :autoload-end
269 ;; Define the minor-mode keymap.
270 ,(unless (symbolp keymap) ;nil is also a symbol.
271 `(defvar ,keymap-sym
272 (let ((m ,keymap))
273 (cond ((keymapp m) m)
274 ((listp m) (easy-mmode-define-keymap m))
275 (t (error "Invalid keymap %S" ,keymap))))
276 ,(format "Keymap for `%s'." mode-name)))
278 ,(if (not (symbolp mode))
279 (if (or lighter keymap)
280 (error ":lighter and :keymap unsupported with mode expression %s" mode))
281 `(with-no-warnings
282 (add-minor-mode ',mode ',lighter
283 ,(if keymap keymap-sym
284 `(if (boundp ',keymap-sym) ,keymap-sym))
286 ,(unless (eq mode modefun) 'modefun)))))))
289 ;;; make global minor mode
292 ;;;###autoload
293 (defalias 'easy-mmode-define-global-mode 'define-globalized-minor-mode)
294 ;;;###autoload
295 (defalias 'define-global-minor-mode 'define-globalized-minor-mode)
296 ;;;###autoload
297 (defmacro define-globalized-minor-mode (global-mode mode turn-on &rest keys)
298 "Make a global mode GLOBAL-MODE corresponding to buffer-local minor MODE.
299 TURN-ON is a function that will be called with no args in every buffer
300 and that should try to turn MODE on if applicable for that buffer.
301 KEYS is a list of CL-style keyword arguments. As the minor mode
302 defined by this function is always global, any :global keyword is
303 ignored. Other keywords have the same meaning as in `define-minor-mode',
304 which see. In particular, :group specifies the custom group.
305 The most useful keywords are those that are passed on to the
306 `defcustom'. It normally makes no sense to pass the :lighter
307 or :keymap keywords to `define-globalized-minor-mode', since these
308 are usually passed to the buffer-local version of the minor mode.
310 If MODE's set-up depends on the major mode in effect when it was
311 enabled, then disabling and reenabling MODE should make MODE work
312 correctly with the current major mode. This is important to
313 prevent problems with derived modes, that is, major modes that
314 call another major mode in their body."
316 (let* ((global-mode-name (symbol-name global-mode))
317 (pretty-name (easy-mmode-pretty-mode-name mode))
318 (pretty-global-name (easy-mmode-pretty-mode-name global-mode))
319 (group nil)
320 (extra-keywords nil)
321 (MODE-buffers (intern (concat global-mode-name "-buffers")))
322 (MODE-enable-in-buffers
323 (intern (concat global-mode-name "-enable-in-buffers")))
324 (MODE-check-buffers
325 (intern (concat global-mode-name "-check-buffers")))
326 (MODE-cmhh (intern (concat global-mode-name "-cmhh")))
327 (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
328 keyw)
330 ;; Check keys.
331 (while (keywordp (setq keyw (car keys)))
332 (setq keys (cdr keys))
333 (case keyw
334 (:group (setq group (nconc group (list :group (pop keys)))))
335 (:global (setq keys (cdr keys)))
336 (t (push keyw extra-keywords) (push (pop keys) extra-keywords))))
338 (unless group
339 ;; We might as well provide a best-guess default group.
340 (setq group
341 `(:group ',(intern (replace-regexp-in-string
342 "-mode\\'" "" (symbol-name mode))))))
344 `(progn
345 (defvar ,MODE-major-mode nil)
346 (make-variable-buffer-local ',MODE-major-mode)
347 ;; The actual global minor-mode
348 (define-minor-mode ,global-mode
349 ;; Very short lines to avoid too long lines in the generated
350 ;; doc string.
351 ,(format "Toggle %s in every possible buffer.
352 With prefix ARG, turn %s on if and only if
353 ARG is positive.
354 %s is enabled in all buffers where
355 \`%s' would do it.
356 See `%s' for more information on %s."
357 pretty-name pretty-global-name pretty-name turn-on
358 mode pretty-name)
359 :global t ,@group ,@(nreverse extra-keywords)
361 ;; Setup hook to handle future mode changes and new buffers.
362 (if ,global-mode
363 (progn
364 (add-hook 'after-change-major-mode-hook
365 ',MODE-enable-in-buffers)
366 (add-hook 'fundamental-mode-hook ',MODE-enable-in-buffers)
367 (add-hook 'find-file-hook ',MODE-check-buffers)
368 (add-hook 'change-major-mode-hook ',MODE-cmhh))
369 (remove-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers)
370 (remove-hook 'fundamental-mode-hook ',MODE-enable-in-buffers)
371 (remove-hook 'find-file-hook ',MODE-check-buffers)
372 (remove-hook 'change-major-mode-hook ',MODE-cmhh))
374 ;; Go through existing buffers.
375 (dolist (buf (buffer-list))
376 (with-current-buffer buf
377 (if ,global-mode (,turn-on) (when ,mode (,mode -1))))))
379 ;; Autoloading define-globalized-minor-mode autoloads everything
380 ;; up-to-here.
381 :autoload-end
383 ;; List of buffers left to process.
384 (defvar ,MODE-buffers nil)
386 ;; The function that calls TURN-ON in each buffer.
387 (defun ,MODE-enable-in-buffers ()
388 (dolist (buf ,MODE-buffers)
389 (when (buffer-live-p buf)
390 (with-current-buffer buf
391 (unless (eq ,MODE-major-mode major-mode)
392 (if ,mode
393 (progn
394 (,mode -1)
395 (,turn-on)
396 (setq ,MODE-major-mode major-mode))
397 (,turn-on)
398 (setq ,MODE-major-mode major-mode)))))))
399 (put ',MODE-enable-in-buffers 'definition-name ',global-mode)
401 (defun ,MODE-check-buffers ()
402 (,MODE-enable-in-buffers)
403 (setq ,MODE-buffers nil)
404 (remove-hook 'post-command-hook ',MODE-check-buffers))
405 (put ',MODE-check-buffers 'definition-name ',global-mode)
407 ;; The function that catches kill-all-local-variables.
408 (defun ,MODE-cmhh ()
409 (add-to-list ',MODE-buffers (current-buffer))
410 (add-hook 'post-command-hook ',MODE-check-buffers))
411 (put ',MODE-cmhh 'definition-name ',global-mode))))
414 ;;; easy-mmode-defmap
417 (eval-and-compile
418 (if (fboundp 'set-keymap-parents)
419 (defalias 'easy-mmode-set-keymap-parents 'set-keymap-parents)
420 (defun easy-mmode-set-keymap-parents (m parents)
421 (set-keymap-parent
423 (cond
424 ((not (consp parents)) parents)
425 ((not (cdr parents)) (car parents))
426 (t (let ((m (copy-keymap (pop parents))))
427 (easy-mmode-set-keymap-parents m parents)
428 m)))))))
430 ;;;###autoload
431 (defun easy-mmode-define-keymap (bs &optional name m args)
432 "Return a keymap built from bindings BS.
433 BS must be a list of (KEY . BINDING) where
434 KEY and BINDINGS are suitable for `define-key'.
435 Optional NAME is passed to `make-sparse-keymap'.
436 Optional map M can be used to modify an existing map.
437 ARGS is a list of additional keyword arguments.
439 Valid keywords and arguments are:
441 :name Name of the keymap; overrides NAME argument.
442 :dense Non-nil for a dense keymap.
443 :inherit Parent keymap.
444 :group Ignored.
445 :suppress Non-nil to call `suppress-keymap' on keymap,
446 'nodigits to suppress digits as prefix arguments."
447 (let (inherit dense suppress)
448 (while args
449 (let ((key (pop args))
450 (val (pop args)))
451 (case key
452 (:name (setq name val))
453 (:dense (setq dense val))
454 (:inherit (setq inherit val))
455 (:suppress (setq suppress val))
456 (:group)
457 (t (message "Unknown argument %s in defmap" key)))))
458 (unless (keymapp m)
459 (setq bs (append m bs))
460 (setq m (if dense (make-keymap name) (make-sparse-keymap name))))
461 (when suppress
462 (suppress-keymap m (eq suppress 'nodigits)))
463 (dolist (b bs)
464 (let ((keys (car b))
465 (binding (cdr b)))
466 (dolist (key (if (consp keys) keys (list keys)))
467 (cond
468 ((symbolp key)
469 (substitute-key-definition key binding m global-map))
470 ((null binding)
471 (unless (keymapp (lookup-key m key)) (define-key m key binding)))
472 ((let ((o (lookup-key m key)))
473 (or (null o) (numberp o) (eq o 'undefined)))
474 (define-key m key binding))))))
475 (cond
476 ((keymapp inherit) (set-keymap-parent m inherit))
477 ((consp inherit) (easy-mmode-set-keymap-parents m inherit)))
480 ;;;###autoload
481 (defmacro easy-mmode-defmap (m bs doc &rest args)
482 "Define a constant M whose value is the result of `easy-mmode-define-keymap'.
483 The M, BS, and ARGS arguments are as per that function. DOC is
484 the constant's documentation."
485 `(defconst ,m
486 (easy-mmode-define-keymap ,bs nil (if (boundp ',m) ,m) ,(cons 'list args))
487 ,doc))
491 ;;; easy-mmode-defsyntax
494 (defun easy-mmode-define-syntax (css args)
495 (let ((st (make-syntax-table (plist-get args :copy)))
496 (parent (plist-get args :inherit)))
497 (dolist (cs css)
498 (let ((char (car cs))
499 (syntax (cdr cs)))
500 (if (sequencep char)
501 (mapc (lambda (c) (modify-syntax-entry c syntax st)) char)
502 (modify-syntax-entry char syntax st))))
503 (if parent (set-char-table-parent
504 st (if (symbolp parent) (symbol-value parent) parent)))
505 st))
507 ;;;###autoload
508 (defmacro easy-mmode-defsyntax (st css doc &rest args)
509 "Define variable ST as a syntax-table.
510 CSS contains a list of syntax specifications of the form (CHAR . SYNTAX)."
511 `(progn
512 (autoload 'easy-mmode-define-syntax "easy-mmode")
513 (defconst ,st (easy-mmode-define-syntax ,css ,(cons 'list args)) ,doc)))
518 ;;; easy-mmode-define-navigation
521 (defmacro easy-mmode-define-navigation (base re &optional name endfun narrowfun
522 &rest body)
523 "Define BASE-next and BASE-prev to navigate in the buffer.
524 RE determines the places the commands should move point to.
525 NAME should describe the entities matched by RE. It is used to build
526 the docstrings of the two functions.
527 BASE-next also tries to make sure that the whole entry is visible by
528 searching for its end (by calling ENDFUN if provided or by looking for
529 the next entry) and recentering if necessary.
530 ENDFUN should return the end position (with or without moving point).
531 NARROWFUN non-nil means to check for narrowing before moving, and if
532 found, do `widen' first and then call NARROWFUN with no args after moving.
533 BODY is executed after moving to the destination location."
534 (declare (indent 5) (debug (exp exp exp def-form def-form &rest def-body)))
535 (let* ((base-name (symbol-name base))
536 (prev-sym (intern (concat base-name "-prev")))
537 (next-sym (intern (concat base-name "-next")))
538 (when-narrowed
539 (lambda (body)
540 (if (null narrowfun) body
541 `(let ((was-narrowed
542 (prog1 (or (< (- (point-max) (point-min)) (buffer-size)))
543 (widen))))
544 ,body
545 (when was-narrowed (,narrowfun)))))))
546 (unless name (setq name base-name))
547 `(progn
548 (add-to-list 'debug-ignored-errors
549 ,(concat "^No \\(previous\\|next\\) " (regexp-quote name)))
550 (defun ,next-sym (&optional count)
551 ,(format "Go to the next COUNT'th %s." name)
552 (interactive "p")
553 (unless count (setq count 1))
554 (if (< count 0) (,prev-sym (- count))
555 (if (looking-at ,re) (setq count (1+ count)))
556 ,(funcall when-narrowed
557 `(if (not (re-search-forward ,re nil t count))
558 (if (looking-at ,re)
559 (goto-char (or ,(if endfun `(,endfun)) (point-max)))
560 (error "No next %s" ,name))
561 (goto-char (match-beginning 0))
562 (when (and (eq (current-buffer) (window-buffer (selected-window)))
563 (called-interactively-p 'interactive))
564 (let ((endpt (or (save-excursion
565 ,(if endfun `(,endfun)
566 `(re-search-forward ,re nil t 2)))
567 (point-max))))
568 (unless (pos-visible-in-window-p endpt nil t)
569 (recenter '(0)))))))
570 ,@body))
571 (put ',next-sym 'definition-name ',base)
572 (defun ,prev-sym (&optional count)
573 ,(format "Go to the previous COUNT'th %s" (or name base-name))
574 (interactive "p")
575 (unless count (setq count 1))
576 (if (< count 0) (,next-sym (- count))
577 ,(funcall when-narrowed
578 `(unless (re-search-backward ,re nil t count)
579 (error "No previous %s" ,name)))
580 ,@body))
581 (put ',prev-sym 'definition-name ',base))))
584 (provide 'easy-mmode)
586 ;; arch-tag: d48a5250-6961-4528-9cb0-3c9ea042a66a
587 ;;; easy-mmode.el ends here