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