annotate lisp/emacs-lisp/easy-mmode.el @ 19860:c17fd465ea95 libc-970911 libc-970912 libc-970913 libc-970914 libc-970915 libc-970916 libc-970917 libc-970918 libc-970919 libc-970920 libc-970921 libc-970922 libc-970923 libc-970924 libc-970925 libc-970926 libc-970927 libc-970928 libc-970929 libc-970930 libc-971001 libc-971018 libc-971019 libc-971020 libc-971021 libc-971022 libc-971023 libc-971024 libc-971025 libc-971026 libc-971027 libc-971028 libc-971029 libc-971030 libc-971031 libc-971101 libc-971102 libc-971103 libc-971104 libc-971105 libc-971106 libc-971107 libc-971108 libc-971109 libc-971110 libc-971111 libc-971112 libc-971113 libc-971114 libc-971115 libc-971116 libc-971117 libc-971118 libc-971120 libc-971121 libc-971122 libc-971123 libc-971124 libc-971125 libc-971126 libc-971127 libc-971128 libc-971129 libc-971130 libc-971201 libc-971203 libc-971204 libc-971205 libc-971206 libc-971207 libc-971208 libc-971209 libc-971210 libc-971211 libc-971212 libc-971213 libc-971214 libc-971217 libc-971218 libc-971219 libc-971220 libc-971221 libc-971222 libc-971223 libc-971224 libc-971225 libc-971226 libc-971227 libc-971228 libc-971229 libc-971230 libc-971231 libc-980103 libc-980104 libc-980105 libc-980106 libc-980107 libc-980108 libc-980109 libc-980110 libc-980111 libc-980112 libc-980114 libc-980115 libc-980116 libc-980117 libc-980118 libc-980119 libc-980120 libc-980121 libc-980122 libc-980123 libc-980124 libc-980125 libc-980126 libc-980127 libc-980128

typos.
author Jeff Law <law@redhat.com>
date Wed, 10 Sep 1997 21:16:20 +0000
parents 7e14277c51f3
children 51fc8872fa32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18388
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; easy-mmode.el --- easy definition of minor modes.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Georges Brun-Cottan <Georges.Brun-Cottan@inria.fr>
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; any later version.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; Minor modes are useful and common. This package makes defining a
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; minor mode easy, by focusing on the writing of the minor mode
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; functionalities themselves. Moreover, this package enforces a
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; conventional naming of user interface primitives, making things
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; natural for the minor-mode end-users.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; For each mode, easy-mmode defines the following:
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; <mode> : The minor mode predicate. A buffer-local variable.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; <mode>-map : The keymap possibly associated to <mode>.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; <mode>-hook,<mode>-on-hook,<mode>-off-hook and <mode>-mode:
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; see `easy-mmode-define-minor-mode' documentation
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; eval
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; (pp (macroexpand '(easy-mmode-define-minor-mode <your-mode> <doc>)))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; to check the result before using it.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; The order in which minor modes are installed is important. Keymap
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; lookup proceeds down minor-mode-map-alist, and the order there
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; tends to be the reverse of the order in which the modes were
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; installed. Perhaps there should be a feature to let you specify
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; orderings.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;; Code:
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (defun easy-mmode-define-keymap (keymap-alist &optional menu-name)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "Return a keymap builded from KEYMAP-ALIST.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 KEYMAP-ALIST must be a list of (KEYBINDING . BINDING) where
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 KEYBINDING and BINDINGS are suited as for define-key.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 optional MENU-NAME is passed to `make-sparse-keymap'."
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (let ((keymap (make-sparse-keymap menu-name)))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (mapcar
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (function (lambda (bind)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (define-key keymap
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (car bind) (cdr bind))))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 keymap-alist)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 keymap))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (defmacro easy-mmode-define-toggle (mode &optional doc)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 "Define a one arg toggle mode MODE function and associated hooks.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 MODE-mode is the so defined function that toggle the mode.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 optional DOC is its associated documentation.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 Hooks are checked for run, each time MODE-mode is called.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 They run under the followings conditions:
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 MODE-hook: if the mode is toggled.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 MODE-on-hook: if the mode is on.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 MODE-off-hook: if the mode is off.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 When the mode is effectively toggled, two hooks may run.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 If so MODE-hook is guaranteed to be the first.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 \(defmacro easy-mmode-define-toggle (MODE &optional DOC)"
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (let* ((mode-name
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (if (string-match "-mode\\'" (symbol-name mode))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (symbol-name mode)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (concat (symbol-name mode) "-mode")))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (hook (intern (concat mode-name "-hook")))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (hook-on (intern (concat mode-name "-on-hook")))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (hook-off (intern (concat mode-name "-off-hook")))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (toggle (intern mode-name))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (mode toggle)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (toggle-doc (or doc
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (format "With no argument, toggle %s mode.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 With arg turn mode on.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 With zero or negative arg turn mode off"
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 mode-name))))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 `(progn
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (defvar ,hook nil
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ,(format "Hook called when %s mode is toggled" mode-name))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (defvar ,hook-on nil
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ,(format "Hook called when %s mode is turned on" mode-name))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (defvar ,hook-off nil
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ,(format "Hook called when %s mode is turned off" mode-name))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (defun ,toggle (&optional arg)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ,toggle-doc
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (interactive "P")
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (let ((old-mode ,mode))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (setq ,mode
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (if arg
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (or (listp arg);; C-u alone
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (> (prefix-numeric-value arg) 0))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (not ,mode)))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (and ,hook
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (not (equal old-mode ,mode))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (run-hooks ',hook))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (and ,hook-on
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ,mode
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (run-hooks ',hook-on))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (and ,hook-off
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (not ,mode)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (run-hooks ',hook-off)))))))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;;;###autoload
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (defmacro easy-mmode-define-minor-mode
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (mode doc &optional init-value &optional lighter &optional keymap)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 "Define a new minor mode MODE.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 This function defines the associated control variable, keymap,
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 toggle command, and hooks (see `easy-mmode-define-toggle').
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 DOC is the documentation for the mode toggle command.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 Optional LIGHTER is displayed in the mode-bar when the mode is on.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 Optional KEYMAP is the default (defvar) keymap bound to the mode keymap.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 If it is a list, it is passed to `easy-mmode-define-keymap'
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 in order to build a valid keymap.
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 \(defmacro easy-mmode-define-minor-mode
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (MODE DOC &optional INIT-VALUE &optional LIGHTER &optional KEYMAP)...\)"
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (let* ((mode-name (symbol-name mode))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (mode-doc (format "%s mode control switch." mode-name))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (keymap-name (concat mode-name "-map"))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (keymap-doc (format "Keymap activated when %s mode is on." mode-name)))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 `(progn
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; define the switch
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (defvar ,mode ,init-value ,mode-doc)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (make-variable-buffer-local ',mode)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; define the minor-mode keymap
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defvar ,(intern keymap-name)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (cond ((and ,keymap (keymapp ,keymap))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ,keymap)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ((listp ,keymap)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (easy-mmode-define-keymap ,keymap))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (t (error "Invalid keymap %S" ,keymap)))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ,keymap-doc)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;; define the toggle and the hooks
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ,(macroexpand `(easy-mmode-define-toggle ,mode ,doc)) ; toggle and hooks
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; update the mode-bar
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (or (assq ',mode minor-mode-alist)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (setq minor-mode-alist
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (cons (list ',mode ,lighter) minor-mode-alist)))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; update the minor-mode-map
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (or (assq ',mode minor-mode-map-alist)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (setq minor-mode-map-alist
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (cons (cons ',mode ,(intern keymap-name)) minor-mode-map-alist)))) ))
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (provide 'easy-mmode)
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
7e14277c51f3 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;;; easy-mmode.el ends here