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