annotate lisp/viper/viper-keym.el @ 175:2d532a89d707 r20-3b14

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