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