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