Mercurial > emacs
annotate lisp/emulation/viper-keym.el @ 64094:e960506e0661
Add support for Darwin (with much debugging help from Samuel Lauber
<sam124@operamail.com>).
(battery-status-function, battery-echo-area-format)
(battery-mode-line-format): Add support for pmset on Darwin.
(battery-load-low, battery-load-critical): New user options.
(battery-pmset): New function.
author | Lute Kamstra <lute@gnu.org> |
---|---|
date | Tue, 05 Jul 2005 08:13:41 +0000 |
parents | 18a818a2ee7c |
children | a4c59075cac8 f9a65d7ebd29 |
rev | line source |
---|---|
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1 ;;; viper-keym.el --- Viper keymaps |
13337 | 2 |
62440
cac7024af280
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60168
diff
changeset
|
3 ;; Copyright (C) 1994, 95, 96, 97, 2000, 01, 02, 2005 Free Software Foundation, Inc. |
11288 | 4 |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
5 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> |
39215
8dccf2552307
2001-09-09 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38514
diff
changeset
|
6 |
10789 | 7 ;; This file is part of GNU Emacs. |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 ;; Boston, MA 02110-1301, USA. | |
10789 | 23 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
26263
diff
changeset
|
24 ;;; Commentary: |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
26263
diff
changeset
|
25 |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
26263
diff
changeset
|
26 ;;; Code: |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14581
diff
changeset
|
27 |
18047 | 28 (provide 'viper-keym) |
29 | |
30 ;; compiler pacifier | |
18289 | 31 (defvar viper-always) |
19079 | 32 (defvar viper-current-state) |
33 (defvar viper-mode-string) | |
18839 | 34 (defvar viper-expert-level) |
19462 | 35 (defvar viper-ex-style-editing) |
19079 | 36 (defvar viper-ex-style-motion) |
18047 | 37 |
18172 | 38 ;; loading happens only in non-interactive compilation |
39 ;; in order to spare non-viperized emacs from being viperized | |
40 (if noninteractive | |
41 (eval-when-compile | |
42 (let ((load-path (cons (expand-file-name ".") load-path))) | |
43 (or (featurep 'viper-util) | |
44 (load "viper-util.el" nil nil 'nosuffix)) | |
45 ))) | |
18047 | 46 ;; end pacifier |
47 | |
10789 | 48 (require 'viper-util) |
49 | |
18047 | 50 |
10789 | 51 ;;; Variables |
52 | |
62963
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
53 (defcustom viper-toggle-key "\C-z" |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
54 "The key used to change states from emacs to Vi and back. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
55 In insert mode, this key also functions as Meta. |
19079 | 56 Must be set in .viper file or prior to loading Viper. |
62963
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
57 This setting cannot be changed interactively." |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
58 :type 'string |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
59 :group 'viper) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
60 |
62963
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
61 (defcustom viper-quoted-insert-key "\C-v" |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
62 "The key used to quote special characters when inserting them in Insert state." |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
63 :type 'string |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
64 :group 'viper) |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
65 |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
66 (defcustom viper-ESC-key "\e" |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
67 "Key used to ESC. |
19079 | 68 Must be set in .viper file or prior to loading Viper. |
62963
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
69 This setting cannot be changed interactively." |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
70 :type 'string |
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
71 :group 'viper) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
72 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
73 ;;; Emacs keys in other states. |
18047 | 74 |
19079 | 75 (defcustom viper-want-emacs-keys-in-insert t |
18047 | 76 "*Set to nil if you want complete Vi compatibility in insert mode. |
18839 | 77 Complete compatibility with Vi is not recommended for power use of Viper." |
78 :type 'boolean | |
79 :group 'viper) | |
18047 | 80 |
19079 | 81 (defcustom viper-want-emacs-keys-in-vi t |
18047 | 82 "*Set to nil if you want complete Vi compatibility in Vi mode. |
18839 | 83 Full Vi compatibility is not recommended for power use of Viper." |
84 :type 'boolean | |
85 :group 'viper) | |
18047 | 86 |
19079 | 87 (defcustom viper-no-multiple-ESC t |
18047 | 88 "*If true, multiple ESC in Vi mode will cause bell to ring. |
89 This is set to t on a windowing terminal and to 'twice on a dumb | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
90 terminal (unless the user level is 1, 2, or 5). On a dumb terminal, this |
18047 | 91 enables cursor keys and is generally more convenient, as terminals usually |
92 don't have a convenient Meta key. | |
19079 | 93 Setting viper-no-multiple-ESC to nil will allow as many multiple ESC, |
18839 | 94 as is allowed by the major mode in effect." |
95 :type 'boolean | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
96 :group 'viper) |
18047 | 97 |
19079 | 98 (defcustom viper-want-ctl-h-help nil |
19891 | 99 "*If non-nil, C-h gets bound to help-command; otherwise, C-h gets the usual Vi bindings." |
18839 | 100 :type 'boolean |
101 :group 'viper) | |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
102 |
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
103 |
10789 | 104 ;;; Keymaps |
105 | |
106 ;; Keymaps for vital things like \e and C-z. | |
107 ;; Not for users | |
19079 | 108 (defvar viper-vi-intercept-map (make-sparse-keymap)) |
109 (defvar viper-insert-intercept-map (make-sparse-keymap)) | |
110 (defvar viper-emacs-intercept-map (make-sparse-keymap)) | |
12696
dbbeba770da4
(vip-overriding-map): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12140
diff
changeset
|
111 |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
112 ;; keymap used to zap all keymaps other than function-key-map, |
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
113 ;; device-function-key-map, etc. |
19079 | 114 (defvar viper-overriding-map (make-sparse-keymap)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
115 |
19079 | 116 (viper-deflocalvar viper-vi-local-user-map (make-sparse-keymap) |
10789 | 117 "Keymap for user-defined local bindings. |
118 Useful for changing bindings such as ZZ in certain major modes. | |
119 For instance, in letter-mode, one may want to bind ZZ to | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
120 mh-send-letter. In a newsreader such as gnus, tin, or rn, ZZ could be bound |
10789 | 121 to save-buffers-kill-emacs then post article, etc.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
122 (put 'viper-vi-local-user-map 'permanent-local t) |
10789 | 123 |
19079 | 124 (defvar viper-vi-global-user-map (make-sparse-keymap) |
10789 | 125 "Keymap for user-defined global bindings. |
126 These bindings are seen in all Viper buffers.") | |
127 | |
19079 | 128 (defvar viper-vi-basic-map (make-keymap) |
10789 | 129 "This is the main keymap in effect in Viper's Vi state. |
130 This map is global, shared by all buffers.") | |
131 | |
19079 | 132 (defvar viper-vi-kbd-map (make-sparse-keymap) |
10789 | 133 "This keymap keeps keyboard macros defined via the :map command.") |
134 | |
19079 | 135 (defvar viper-vi-diehard-map (make-sparse-keymap) |
10789 | 136 "This keymap is in use when the user asks Viper to simulate Vi very closely. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
137 This happens when viper-expert-level is 1 or 2. See viper-set-expert-level.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
138 |
10789 | 139 |
19079 | 140 (viper-deflocalvar viper-insert-local-user-map (make-sparse-keymap) |
10789 | 141 "Auxiliary map for per-buffer user-defined keybindings in Insert state.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
142 (put 'viper-insert-local-user-map 'permanent-local t) |
10789 | 143 |
19079 | 144 (defvar viper-insert-global-user-map (make-sparse-keymap) |
10789 | 145 "Auxiliary map for global user-defined bindings in Insert state.") |
146 | |
19079 | 147 (defvar viper-insert-basic-map (make-sparse-keymap) |
10789 | 148 "The basic insert-mode keymap.") |
149 | |
19079 | 150 (defvar viper-insert-diehard-map (make-keymap) |
10789 | 151 "Map used when user wants vi-style keys in insert mode. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
152 Most of the Emacs keys are suppressed. This map overshadows |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
153 viper-insert-basic-map. Not recommended, except for novice users.") |
10789 | 154 |
19079 | 155 (defvar viper-insert-kbd-map (make-sparse-keymap) |
10789 | 156 "This keymap keeps VI-style kbd macros for insert mode.") |
157 | |
19079 | 158 (defvar viper-replace-map (make-sparse-keymap) |
10789 | 159 "Map used in Viper's replace state.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
160 |
19079 | 161 (defvar viper-emacs-global-user-map (make-sparse-keymap) |
10789 | 162 "Auxiliary map for global user-defined bindings in Emacs state.") |
163 | |
19079 | 164 (defvar viper-emacs-kbd-map (make-sparse-keymap) |
10789 | 165 "This keymap keeps Vi-style kbd macros for emacs mode.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
166 |
19079 | 167 (viper-deflocalvar viper-emacs-local-user-map (make-sparse-keymap) |
10789 | 168 "Auxiliary map for local user-defined bindings in Emacs state.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
169 (put 'viper-emacs-local-user-map 'permanent-local t) |
10789 | 170 |
171 ;; This keymap should stay empty | |
19079 | 172 (defvar viper-empty-keymap (make-sparse-keymap)) |
10789 | 173 |
12140
75379a19c5d5
Changed vip-*-frame-* to *-frame-*, incorporated overlay strings,
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
174 ;; This was the main Vi mode in old versions of VIP which may have been |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
175 ;; extensively used by VIP users. We declare it as a global var |
19079 | 176 ;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map. |
177 (defvar viper-mode-map (make-sparse-keymap)) | |
12140
75379a19c5d5
Changed vip-*-frame-* to *-frame-*, incorporated overlay strings,
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
178 |
10789 | 179 |
180 ;;; Variables used by minor modes | |
181 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
182 ;; Association list of the form |
10789 | 183 ;; ((major-mode . keymap) (major-mode . keymap) ...) |
184 ;; Viper uses these keymaps to make user-requested adjustments | |
185 ;; to its Vi state in various major modes.") | |
19079 | 186 (defvar viper-vi-state-modifier-alist nil) |
10789 | 187 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
188 ;; Association list of the form |
10789 | 189 ;; ((major-mode . keymap) (major-mode . keymap) ...) |
190 ;; Viper uses these keymaps to make user-requested adjustments | |
191 ;; to its Insert state in various major modes.") | |
19079 | 192 (defvar viper-insert-state-modifier-alist nil) |
10789 | 193 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
194 ;; Association list of the form |
10789 | 195 ;; ((major-mode . keymap) (major-mode . keymap) ...) |
196 ;; Viper uses these keymaps to make user-requested adjustments | |
197 ;; to its Emacs state in various major modes. | |
19079 | 198 (defvar viper-emacs-state-modifier-alist nil) |
10789 | 199 |
19079 | 200 ;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
201 ;; buffers. Not a user option. |
19079 | 202 (viper-deflocalvar viper-need-new-vi-local-map t "") |
203 (put 'viper-need-new-vi-local-map 'permanent-local t) | |
10789 | 204 |
19079 | 205 ;; Tells viper-add-local-keys to create a new viper-insert-local-user-map for |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
206 ;; new buffers. Not a user option. |
19079 | 207 (viper-deflocalvar viper-need-new-insert-local-map t "") |
208 (put 'viper-need-new-insert-local-map 'permanent-local t) | |
10789 | 209 |
19079 | 210 ;; Tells viper-add-local-keys to create a new viper-emacs-local-user-map for |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
211 ;; new buffers. Not a user option. |
19079 | 212 (viper-deflocalvar viper-need-new-emacs-local-map t "") |
213 (put 'viper-need-new-emacs-local-map 'permanent-local t) | |
10789 | 214 |
215 | |
216 | |
217 ;; Insert mode keymap | |
218 | |
219 ;; for novice users, pretend you are the real vi. | |
19079 | 220 (define-key viper-insert-diehard-map "\t" 'viper-insert-tab) |
221 (define-key viper-insert-diehard-map "\C-a" 'self-insert-command) | |
222 (define-key viper-insert-diehard-map "\C-b" 'self-insert-command) | |
223 (define-key viper-insert-diehard-map "\C-c" 'viper-change-state-to-vi) | |
224 (define-key viper-insert-diehard-map "\C-e" 'self-insert-command) | |
225 (define-key viper-insert-diehard-map "\C-f" 'self-insert-command) | |
226 (define-key viper-insert-diehard-map "\C-g" 'self-insert-command) | |
227 (define-key viper-insert-diehard-map "\C-i" 'self-insert-command) | |
228 (define-key viper-insert-diehard-map "\C-k" 'self-insert-command) | |
229 (define-key viper-insert-diehard-map "\C-l" 'self-insert-command) | |
230 (define-key viper-insert-diehard-map "\C-n" 'self-insert-command) | |
231 (define-key viper-insert-diehard-map "\C-o" 'self-insert-command) | |
232 (define-key viper-insert-diehard-map "\C-p" 'self-insert-command) | |
233 (define-key viper-insert-diehard-map "\C-q" 'self-insert-command) | |
234 (define-key viper-insert-diehard-map "\C-r" 'self-insert-command) | |
235 (define-key viper-insert-diehard-map "\C-s" 'self-insert-command) | |
236 (define-key viper-insert-diehard-map "\C-u" 'viper-erase-line) | |
237 (define-key viper-insert-diehard-map "\C-x" 'self-insert-command) | |
238 (define-key viper-insert-diehard-map "\C-y" 'self-insert-command) | |
239 (define-key viper-insert-diehard-map "\C-z" 'self-insert-command) | |
240 (define-key viper-insert-diehard-map "\C-]" 'self-insert-command) | |
241 (define-key viper-insert-diehard-map "\C-_" 'self-insert-command) | |
10789 | 242 |
243 (let ((i ?\ )) | |
244 (while (<= i ?~) | |
19079 | 245 (define-key viper-insert-diehard-map (make-string 1 i) 'self-insert-command) |
10789 | 246 (setq i (1+ i)))) |
247 | |
248 ;; Insert mode map when user wants emacs style | |
19079 | 249 (define-key viper-insert-basic-map "\C-d" 'viper-backward-indent) |
250 (define-key viper-insert-basic-map "\C-w" 'viper-delete-backward-word) | |
251 (define-key viper-insert-basic-map "\C-t" 'viper-forward-indent) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
252 (define-key viper-insert-basic-map |
19079 | 253 (if viper-xemacs-p [(shift tab)] [S-tab]) 'viper-insert-tab) |
62963
fcacef2ed810
2005-06-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
62440
diff
changeset
|
254 (define-key viper-insert-basic-map viper-quoted-insert-key 'quoted-insert) |
19079 | 255 (define-key viper-insert-basic-map "\C-?" 'viper-del-backward-char-in-insert) |
19891 | 256 (define-key viper-insert-basic-map [backspace] 'viper-del-backward-char-in-insert) |
19079 | 257 (define-key viper-insert-basic-map "\C-\\" 'viper-alternate-Meta-key) |
258 (define-key viper-insert-basic-map viper-toggle-key 'viper-escape-to-vi) | |
259 (define-key viper-insert-basic-map "\C-c\M-p" | |
260 'viper-insert-prev-from-insertion-ring) | |
261 (define-key viper-insert-basic-map "\C-c\M-n" | |
262 'viper-insert-next-from-insertion-ring) | |
10789 | 263 |
264 | |
265 ;; Replace keymap | |
19079 | 266 (define-key viper-replace-map "\C-t" 'viper-forward-indent) |
267 (define-key viper-replace-map "\C-j" 'viper-replace-state-carriage-return) | |
268 (define-key viper-replace-map "\C-m" 'viper-replace-state-carriage-return) | |
269 (define-key viper-replace-map "\C-?" 'viper-del-backward-char-in-replace) | |
19891 | 270 (define-key viper-replace-map [backspace] 'viper-del-backward-char-in-replace) |
10789 | 271 |
272 | |
273 | |
274 ;; Vi keymaps | |
275 | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
276 (define-key viper-vi-basic-map "\C-^" (lambda () |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
277 (interactive) (viper-ex nil "e#"))) |
19079 | 278 (define-key viper-vi-basic-map "\C-b" 'viper-scroll-screen-back) |
279 (define-key viper-vi-basic-map "\C-d" 'viper-scroll-up) | |
280 (define-key viper-vi-basic-map "\C-e" 'viper-scroll-up-one) | |
281 (define-key viper-vi-basic-map "\C-f" 'viper-scroll-screen) | |
282 (define-key viper-vi-basic-map "\C-m" 'viper-next-line-at-bol) | |
283 (define-key viper-vi-basic-map "\C-u" 'viper-scroll-down) | |
284 (define-key viper-vi-basic-map "\C-y" 'viper-scroll-down-one) | |
285 (define-key viper-vi-basic-map "\C-s" 'viper-isearch-forward) | |
286 (define-key viper-vi-basic-map "\C-r" 'viper-isearch-backward) | |
287 (define-key viper-vi-basic-map "\C-c/" 'viper-toggle-search-style) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
288 (define-key viper-vi-basic-map "\C-c\C-g" 'viper-info-on-file) |
10789 | 289 |
19079 | 290 (define-key viper-vi-basic-map "\C-c\M-p" 'viper-prev-destructive-command) |
291 (define-key viper-vi-basic-map "\C-c\M-n" 'viper-next-destructive-command) | |
10789 | 292 |
293 | |
19079 | 294 (define-key viper-vi-basic-map " " 'viper-forward-char) |
295 (define-key viper-vi-basic-map "!" 'viper-command-argument) | |
296 (define-key viper-vi-basic-map "\"" 'viper-command-argument) | |
297 (define-key viper-vi-basic-map "#" 'viper-command-argument) | |
298 (define-key viper-vi-basic-map "$" 'viper-goto-eol) | |
299 (define-key viper-vi-basic-map "%" 'viper-paren-match) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
300 (define-key viper-vi-basic-map "&" (lambda () |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
301 (interactive) (viper-ex nil "&"))) |
19079 | 302 (define-key viper-vi-basic-map "'" 'viper-goto-mark-and-skip-white) |
303 (define-key viper-vi-basic-map "(" 'viper-backward-sentence) | |
304 (define-key viper-vi-basic-map ")" 'viper-forward-sentence) | |
305 (define-key viper-vi-basic-map "*" 'call-last-kbd-macro) | |
306 (define-key viper-vi-basic-map "+" 'viper-next-line-at-bol) | |
307 (define-key viper-vi-basic-map "," 'viper-repeat-find-opposite) | |
308 (define-key viper-vi-basic-map "-" 'viper-previous-line-at-bol) | |
309 (define-key viper-vi-basic-map "." 'viper-repeat) | |
310 (define-key viper-vi-basic-map "/" 'viper-search-forward) | |
10789 | 311 |
19079 | 312 (define-key viper-vi-basic-map "0" 'viper-beginning-of-line) |
313 (define-key viper-vi-basic-map "1" 'viper-digit-argument) | |
314 (define-key viper-vi-basic-map "2" 'viper-digit-argument) | |
315 (define-key viper-vi-basic-map "3" 'viper-digit-argument) | |
316 (define-key viper-vi-basic-map "4" 'viper-digit-argument) | |
317 (define-key viper-vi-basic-map "5" 'viper-digit-argument) | |
318 (define-key viper-vi-basic-map "6" 'viper-digit-argument) | |
319 (define-key viper-vi-basic-map "7" 'viper-digit-argument) | |
320 (define-key viper-vi-basic-map "8" 'viper-digit-argument) | |
321 (define-key viper-vi-basic-map "9" 'viper-digit-argument) | |
10789 | 322 |
19079 | 323 (define-key viper-vi-basic-map ":" 'viper-ex) |
324 (define-key viper-vi-basic-map ";" 'viper-repeat-find) | |
325 (define-key viper-vi-basic-map "<" 'viper-command-argument) | |
326 (define-key viper-vi-basic-map "=" 'viper-command-argument) | |
327 (define-key viper-vi-basic-map ">" 'viper-command-argument) | |
328 (define-key viper-vi-basic-map "?" 'viper-search-backward) | |
329 (define-key viper-vi-basic-map "@" 'viper-register-macro) | |
10789 | 330 |
19079 | 331 (define-key viper-vi-basic-map "A" 'viper-Append) |
332 (define-key viper-vi-basic-map "B" 'viper-backward-Word) | |
333 (define-key viper-vi-basic-map "C" 'viper-change-to-eol) | |
334 (define-key viper-vi-basic-map "D" 'viper-kill-line) | |
335 (define-key viper-vi-basic-map "E" 'viper-end-of-Word) | |
336 (define-key viper-vi-basic-map "F" 'viper-find-char-backward) | |
337 (define-key viper-vi-basic-map "G" 'viper-goto-line) | |
338 (define-key viper-vi-basic-map "H" 'viper-window-top) | |
339 (define-key viper-vi-basic-map "I" 'viper-Insert) | |
340 (define-key viper-vi-basic-map "J" 'viper-join-lines) | |
341 (define-key viper-vi-basic-map "K" 'viper-nil) | |
342 (define-key viper-vi-basic-map "L" 'viper-window-bottom) | |
343 (define-key viper-vi-basic-map "M" 'viper-window-middle) | |
344 (define-key viper-vi-basic-map "N" 'viper-search-Next) | |
345 (define-key viper-vi-basic-map "O" 'viper-Open-line) | |
346 (define-key viper-vi-basic-map "P" 'viper-Put-back) | |
347 (define-key viper-vi-basic-map "Q" 'viper-query-replace) | |
348 (define-key viper-vi-basic-map "R" 'viper-overwrite) | |
349 (define-key viper-vi-basic-map "S" 'viper-substitute-line) | |
350 (define-key viper-vi-basic-map "T" 'viper-goto-char-backward) | |
351 (define-key viper-vi-basic-map "U" 'viper-undo) | |
352 (define-key viper-vi-basic-map "V" 'find-file-other-window) | |
353 (define-key viper-vi-basic-map "W" 'viper-forward-Word) | |
354 (define-key viper-vi-basic-map "X" 'viper-delete-backward-char) | |
355 (define-key viper-vi-basic-map "Y" 'viper-yank-line) | |
356 (define-key viper-vi-basic-map "ZZ" 'viper-save-kill-buffer) | |
10789 | 357 |
19079 | 358 (define-key viper-vi-basic-map "\\" 'viper-escape-to-emacs) |
359 (define-key viper-vi-basic-map "[" 'viper-brac-function) | |
360 (define-key viper-vi-basic-map "]" 'viper-ket-function) | |
361 (define-key viper-vi-basic-map "\C-\\" 'viper-alternate-Meta-key) | |
362 (define-key viper-vi-basic-map "^" 'viper-bol-and-skip-white) | |
363 (define-key viper-vi-basic-map "`" 'viper-goto-mark) | |
10789 | 364 |
19079 | 365 (define-key viper-vi-basic-map "a" 'viper-append) |
366 (define-key viper-vi-basic-map "b" 'viper-backward-word) | |
367 (define-key viper-vi-basic-map "c" 'viper-command-argument) | |
368 (define-key viper-vi-basic-map "d" 'viper-command-argument) | |
369 (define-key viper-vi-basic-map "e" 'viper-end-of-word) | |
370 (define-key viper-vi-basic-map "f" 'viper-find-char-forward) | |
371 (define-key viper-vi-basic-map "g" 'viper-nil) | |
372 (define-key viper-vi-basic-map "h" 'viper-backward-char) | |
19891 | 373 (define-key viper-vi-basic-map [backspace] 'viper-backward-char) |
19079 | 374 (define-key viper-vi-basic-map "i" 'viper-insert) |
375 (define-key viper-vi-basic-map "j" 'viper-next-line) | |
376 (define-key viper-vi-basic-map "k" 'viper-previous-line) | |
377 (define-key viper-vi-basic-map "l" 'viper-forward-char) | |
378 (define-key viper-vi-basic-map "m" 'viper-mark-point) | |
379 (define-key viper-vi-basic-map "n" 'viper-search-next) | |
380 (define-key viper-vi-basic-map "o" 'viper-open-line) | |
381 (define-key viper-vi-basic-map "p" 'viper-put-back) | |
382 (define-key viper-vi-basic-map "q" 'viper-nil) | |
383 (define-key viper-vi-basic-map "r" 'viper-replace-char) | |
384 (define-key viper-vi-basic-map "s" 'viper-substitute) | |
385 (define-key viper-vi-basic-map "t" 'viper-goto-char-forward) | |
386 (define-key viper-vi-basic-map "u" 'viper-undo) | |
387 (define-key viper-vi-basic-map "v" 'find-file) | |
388 (define-key viper-vi-basic-map "\C-v" 'find-file-other-frame) | |
389 (define-key viper-vi-basic-map "w" 'viper-forward-word) | |
390 (define-key viper-vi-basic-map "x" 'viper-delete-char) | |
391 (define-key viper-vi-basic-map "y" 'viper-command-argument) | |
392 (define-key viper-vi-basic-map "zH" 'viper-line-to-top) | |
393 (define-key viper-vi-basic-map "zM" 'viper-line-to-middle) | |
394 (define-key viper-vi-basic-map "zL" 'viper-line-to-bottom) | |
395 (define-key viper-vi-basic-map "z\C-m" 'viper-line-to-top) | |
396 (define-key viper-vi-basic-map "z." 'viper-line-to-middle) | |
397 (define-key viper-vi-basic-map "z-" 'viper-line-to-bottom) | |
10789 | 398 |
19079 | 399 (define-key viper-vi-basic-map "{" 'viper-backward-paragraph) |
400 (define-key viper-vi-basic-map "|" 'viper-goto-col) | |
401 (define-key viper-vi-basic-map "}" 'viper-forward-paragraph) | |
402 (define-key viper-vi-basic-map "~" 'viper-toggle-case) | |
403 (define-key viper-vi-basic-map "\C-?" 'viper-backward-char) | |
404 (define-key viper-vi-basic-map "_" 'viper-nil) | |
10789 | 405 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
406 ;;; This is viper-vi-diehard-map. Used when viper-vi-diehard-minor-mode is on. |
10789 | 407 |
19079 | 408 (define-key viper-vi-diehard-map "\C-a" 'viper-nil) |
409 (define-key viper-vi-diehard-map "\C-c" 'viper-nil) | |
410 (define-key viper-vi-diehard-map "\C-g" 'viper-info-on-file) | |
411 (define-key viper-vi-diehard-map "\C-i" 'viper-nil) | |
412 (define-key viper-vi-diehard-map "\C-k" 'viper-nil) | |
413 (define-key viper-vi-diehard-map "\C-l" 'redraw-display) | |
414 (define-key viper-vi-diehard-map "\C-n" 'viper-next-line) | |
415 (define-key viper-vi-diehard-map "\C-o" 'viper-nil) | |
416 (define-key viper-vi-diehard-map "\C-p" 'viper-previous-line) | |
417 (define-key viper-vi-diehard-map "\C-q" 'viper-nil) | |
418 (define-key viper-vi-diehard-map "\C-r" 'redraw-display) | |
419 (define-key viper-vi-diehard-map "\C-s" 'viper-nil) | |
420 (define-key viper-vi-diehard-map "\C-t" 'viper-nil) | |
421 (define-key viper-vi-diehard-map "\C-v" 'viper-nil) | |
422 (define-key viper-vi-diehard-map "\C-w" 'viper-nil) | |
423 (define-key viper-vi-diehard-map "@" 'viper-nil) | |
424 (define-key viper-vi-diehard-map "_" 'viper-nil) | |
425 (define-key viper-vi-diehard-map "*" 'viper-nil) | |
426 (define-key viper-vi-diehard-map "#" 'viper-nil) | |
427 (define-key viper-vi-diehard-map "\C-_" 'viper-nil) | |
428 (define-key viper-vi-diehard-map "\C-]" 'viper-nil) ; This is actually tags. | |
10789 | 429 |
430 | |
431 ;;; Minibuffer keymap | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
432 |
10789 | 433 |
19079 | 434 (defvar viper-minibuffer-map (make-sparse-keymap) |
10789 | 435 "Keymap used to modify keys when Minibuffer is in Insert state.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
436 |
19079 | 437 (define-key viper-minibuffer-map "\C-m" 'viper-exit-minibuffer) |
438 (define-key viper-minibuffer-map "\C-j" 'viper-exit-minibuffer) | |
10789 | 439 |
440 ;; Map used to read Ex-style commands. | |
19079 | 441 (defvar viper-ex-cmd-map (make-sparse-keymap)) |
442 (define-key viper-ex-cmd-map " " 'ex-cmd-read-exit) | |
443 (define-key viper-ex-cmd-map "\t" 'ex-cmd-complete) | |
10789 | 444 |
445 ;; Keymap for reading file names in Ex-style commands. | |
446 (defvar ex-read-filename-map (make-sparse-keymap)) | |
19079 | 447 (define-key ex-read-filename-map " " 'viper-complete-filename-or-exit) |
448 (define-key ex-read-filename-map "!" 'viper-handle-!) | |
10789 | 449 |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
450 ;; Some other maps |
19079 | 451 (defvar viper-slash-and-colon-map (make-sparse-keymap) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
452 "This map redefines `/' and `:' to behave as in Vi. |
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
453 Useful in some modes, such as Gnus, MH, etc.") |
19079 | 454 (define-key viper-slash-and-colon-map ":" 'viper-ex) |
455 (define-key viper-slash-and-colon-map "/" 'viper-search-forward) | |
10789 | 456 |
19079 | 457 (defvar viper-comint-mode-modifier-map (make-sparse-keymap) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
458 "This map modifies comint mode.") |
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
459 (define-key viper-comint-mode-modifier-map "\C-m" 'viper-exec-key-in-emacs) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
460 (define-key viper-comint-mode-modifier-map "\C-d" 'viper-exec-key-in-emacs) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
461 |
19079 | 462 (defvar viper-dired-modifier-map (make-sparse-keymap) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
463 "This map modifies Dired behavior.") |
19079 | 464 (define-key viper-dired-modifier-map ":" 'viper-ex) |
465 (define-key viper-dired-modifier-map "/" 'viper-search-forward) | |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
466 |
60168
d96e54250eea
* viper-cmd.el (viper-prefix-commands): make into a defconst.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
52401
diff
changeset
|
467 (defvar viper-gnus-modifier-map (make-sparse-keymap) |
d96e54250eea
* viper-cmd.el (viper-prefix-commands): make into a defconst.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
52401
diff
changeset
|
468 "This map modifies Gnus behavior.") |
d96e54250eea
* viper-cmd.el (viper-prefix-commands): make into a defconst.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
52401
diff
changeset
|
469 (define-key viper-gnus-modifier-map ":" 'viper-ex) |
d96e54250eea
* viper-cmd.el (viper-prefix-commands): make into a defconst.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
52401
diff
changeset
|
470 |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
471 |
10789 | 472 |
473 ;;; Code | |
474 | |
19079 | 475 (defun viper-add-local-keys (state alist) |
10789 | 476 "Override some vi-state or insert-state bindings in the current buffer. |
477 The effect is seen in the current buffer only. | |
478 Useful for customizing mailer buffers, gnus, etc. | |
479 STATE is 'vi-state, 'insert-state, or 'emacs-state | |
480 ALIST is of the form ((key . func) (key . func) ...) | |
481 Normally, this would be called from a hook to a major mode or | |
482 on a per buffer basis. | |
483 Usage: | |
19079 | 484 (viper-add-local-keys state '((key-str . func) (key-str . func)...)) " |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
485 |
10789 | 486 (let (map) |
487 (cond ((eq state 'vi-state) | |
19079 | 488 (if viper-need-new-vi-local-map |
489 (setq viper-vi-local-user-map (make-sparse-keymap))) | |
490 (setq viper-need-new-vi-local-map nil | |
491 map viper-vi-local-user-map)) | |
10789 | 492 ((eq state 'insert-state) |
19079 | 493 (if viper-need-new-insert-local-map |
494 (setq viper-insert-local-user-map (make-sparse-keymap))) | |
495 (setq viper-need-new-insert-local-map nil | |
496 map viper-insert-local-user-map)) | |
10789 | 497 ((eq state 'emacs-state) |
19079 | 498 (if viper-need-new-emacs-local-map |
499 (setq viper-emacs-local-user-map (make-sparse-keymap))) | |
500 (setq viper-need-new-emacs-local-map nil | |
501 map viper-emacs-local-user-map)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
502 (t |
10789 | 503 (error |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
504 "Invalid state in viper-add-local-keys: %S. Valid states: vi-state, insert-state or emacs-state" state))) |
10789 | 505 |
19079 | 506 (viper-modify-keymap map alist) |
507 (viper-normalize-minor-mode-map-alist) | |
508 (viper-set-mode-vars-for viper-current-state))) | |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
509 |
19079 | 510 (defun viper-zap-local-keys () |
511 "Unconditionally reset Viper viper-*-local-user-map's. | |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
512 Rarely useful, but if u made a mistake by switching to a mode that adds |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
513 undesirable local keys, e.g., comint-mode, then this function can restore |
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
514 sanity." |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
515 (interactive) |
19079 | 516 (setq viper-vi-local-user-map (make-sparse-keymap) |
517 viper-need-new-vi-local-map nil | |
518 viper-insert-local-user-map (make-sparse-keymap) | |
519 viper-need-new-insert-local-map nil | |
520 viper-emacs-local-user-map (make-sparse-keymap) | |
521 viper-need-new-emacs-local-map nil) | |
522 (viper-normalize-minor-mode-map-alist)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
523 |
10789 | 524 |
19079 | 525 (defun viper-modify-major-mode (mode state keymap) |
10789 | 526 "Modify key bindings in a major-mode in a Viper state using a keymap. |
527 | |
528 If the default for a major mode is emacs-state, then modifications to this | |
529 major mode may not take effect until the buffer switches state to Vi, | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
530 Insert or Emacs. If this happens, add viper-change-state-to-emacs to this |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
531 major mode's hook. If no such hook exists, you may have to put an advice on |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
532 the function that invokes the major mode. See viper-set-hooks for hints. |
10789 | 533 |
534 The above needs not to be done for major modes that come up in Vi or Insert | |
535 state by default. | |
536 | |
19079 | 537 Arguments: (major-mode viper-state keymap)" |
10789 | 538 (let ((alist |
19079 | 539 (cond ((eq state 'vi-state) 'viper-vi-state-modifier-alist) |
540 ((eq state 'insert-state) 'viper-insert-state-modifier-alist) | |
541 ((eq state 'emacs-state) 'viper-emacs-state-modifier-alist))) | |
10789 | 542 elt) |
543 (if (setq elt (assoc mode (eval alist))) | |
544 (set alist (delq elt (eval alist)))) | |
545 (set alist (cons (cons mode keymap) (eval alist))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
546 |
10789 | 547 ;; Normalization usually doesn't help here, since one needs to |
548 ;; normalize in the actual buffer where changes to the keymap are | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
549 ;; to take place. However, it doesn't hurt, and it helps whenever this |
21940 | 550 ;; function is actually called from within the affected buffer. |
19079 | 551 (viper-normalize-minor-mode-map-alist) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
552 |
19079 | 553 (viper-set-mode-vars-for viper-current-state))) |
10789 | 554 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
555 |
12140
75379a19c5d5
Changed vip-*-frame-* to *-frame-*, incorporated overlay strings,
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
556 ;; Displays variables that control Viper's keymaps |
19079 | 557 (defun viper-debug-keymaps () |
10789 | 558 (interactive) |
19079 | 559 (with-output-to-temp-buffer " *viper-debug*" |
10789 | 560 (princ (format "Buffer name: %s\n\n" (buffer-name))) |
561 (princ "Variables: \n") | |
562 (princ (format "major-mode: %S\n" major-mode)) | |
19079 | 563 (princ (format "viper-current-state: %S\n" viper-current-state)) |
564 (princ (format "viper-mode-string: %S\n\n" viper-mode-string)) | |
565 (princ (format "viper-vi-intercept-minor-mode: %S\n" | |
566 viper-vi-intercept-minor-mode)) | |
567 (princ (format "viper-insert-intercept-minor-mode: %S\n" | |
568 viper-insert-intercept-minor-mode)) | |
569 (princ (format "viper-emacs-intercept-minor-mode: %S\n" | |
570 viper-emacs-intercept-minor-mode)) | |
571 (princ (format "viper-vi-minibuffer-minor-mode: %S\n" | |
572 viper-vi-minibuffer-minor-mode)) | |
573 (princ (format "viper-insert-minibuffer-minor-mode: %S\n\n" | |
574 viper-insert-minibuffer-minor-mode)) | |
575 (princ (format "viper-vi-local-user-minor-mode: %S\n" | |
576 viper-vi-local-user-minor-mode)) | |
577 (princ (format "viper-vi-global-user-minor-mode: %S\n" | |
578 viper-vi-global-user-minor-mode)) | |
579 (princ (format "viper-vi-kbd-minor-mode: %S\n" viper-vi-kbd-minor-mode)) | |
580 (princ (format "viper-vi-state-modifier-minor-mode: %S\n" | |
581 viper-vi-state-modifier-minor-mode)) | |
582 (princ (format "viper-vi-diehard-minor-mode: %S\n" | |
583 viper-vi-diehard-minor-mode)) | |
584 (princ (format "viper-vi-basic-minor-mode: %S\n" viper-vi-basic-minor-mode)) | |
585 (princ (format "viper-replace-minor-mode: %S\n" viper-replace-minor-mode)) | |
586 (princ (format "viper-insert-local-user-minor-mode: %S\n" | |
587 viper-insert-local-user-minor-mode)) | |
588 (princ (format "viper-insert-global-user-minor-mode: %S\n" | |
589 viper-insert-global-user-minor-mode)) | |
590 (princ (format "viper-insert-kbd-minor-mode: %S\n" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
591 viper-insert-kbd-minor-mode)) |
19079 | 592 (princ (format "viper-insert-state-modifier-minor-mode: %S\n" |
593 viper-insert-state-modifier-minor-mode)) | |
594 (princ (format "viper-insert-diehard-minor-mode: %S\n" | |
595 viper-insert-diehard-minor-mode)) | |
596 (princ (format "viper-insert-basic-minor-mode: %S\n" | |
597 viper-insert-basic-minor-mode)) | |
598 (princ (format "viper-emacs-local-user-minor-mode: %S\n" | |
599 viper-emacs-local-user-minor-mode)) | |
600 (princ (format "viper-emacs-kbd-minor-mode: %S\n" | |
601 viper-emacs-kbd-minor-mode)) | |
602 (princ (format "viper-emacs-global-user-minor-mode: %S\n" | |
603 viper-emacs-global-user-minor-mode)) | |
604 (princ (format "viper-emacs-state-modifier-minor-mode: %S\n" | |
605 viper-emacs-state-modifier-minor-mode)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
606 |
18839 | 607 (princ (format "\nviper-expert-level %S\n" viper-expert-level)) |
19079 | 608 (princ (format "viper-no-multiple-ESC %S\n" viper-no-multiple-ESC)) |
18289 | 609 (princ (format "viper-always %S\n" viper-always)) |
19079 | 610 (princ (format "viper-ex-style-motion %S\n" |
611 viper-ex-style-motion)) | |
19462 | 612 (princ (format "viper-ex-style-editing %S\n" |
613 viper-ex-style-editing)) | |
19079 | 614 (princ (format "viper-want-emacs-keys-in-vi %S\n" |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
615 viper-want-emacs-keys-in-vi)) |
19079 | 616 (princ (format "viper-want-emacs-keys-in-insert %S\n" |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
617 viper-want-emacs-keys-in-insert)) |
19079 | 618 (princ (format "viper-want-ctl-h-help %S\n" viper-want-ctl-h-help)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
619 |
10789 | 620 (princ "\n\n\n") |
621 (princ (format "Default value for minor-mode-map-alist: \n%S\n\n" | |
622 (default-value 'minor-mode-map-alist))) | |
623 (princ (format "Actual value for minor-mode-map-alist: \n%S\n" | |
624 minor-mode-map-alist)) | |
625 )) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
626 |
10789 | 627 |
628 ;;; Keymap utils | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
629 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
630 (defun viper-add-keymap (mapsrc mapdst) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
631 "Add contents of mapsrc to mapdst. It is assumed that mapsrc is sparse." |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
632 (viper-cond-compile-for-xemacs-or-emacs |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
633 ;; xemacs |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
634 (map-keymap (lambda (key binding) (define-key mapdst key binding)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
635 mapsrc) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
636 ;; emacs |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
637 (mapcar (lambda (p) (define-key mapdst (vector (car p)) (cdr p))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
638 (cdr mapsrc)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
639 )) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
640 |
19079 | 641 (defun viper-modify-keymap (map alist) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
642 "Modifies MAP with bindings specified in the ALIST. The alist has the |
10789 | 643 form ((key . function) (key . function) ... )." |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42602
diff
changeset
|
644 (mapcar (lambda (p) (define-key map (eval (car p)) (cdr p))) |
10789 | 645 alist)) |
646 | |
647 | |
18839 | 648 ;;; Local Variables: |
19079 | 649 ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) |
18839 | 650 ;;; End: |
651 | |
652 | |
52401 | 653 ;;; arch-tag: 43af4b2f-0bea-400b-889e-221ebc00acb1 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
26263
diff
changeset
|
654 ;;; viper-keym.el ends here |