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