aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emulation
diff options
context:
space:
mode:
authorKaroly Lorentey2005-09-04 03:48:17 +0000
committerKaroly Lorentey2005-09-04 03:48:17 +0000
commitfbf349734468d48b421c3d03074bb66dfcf3115b (patch)
tree0a7d1ee844b6c591a5a499d23e35931945106e5a /lisp/emulation
parentf0caabd962b662cccbea472995d86af718cc8d0b (diff)
parent4b5fa40e1f1ba3cafde672863a0331311d1c2695 (diff)
downloademacs-fbf349734468d48b421c3d03074bb66dfcf3115b.tar.gz
emacs-fbf349734468d48b421c3d03074bb66dfcf3115b.zip
Merged in changes from CVS trunk. Plus added lisp/term tweaks.
Patches applied: * lorentey@elte.hu--2004/emacs--cvs-trunk--0--base-0 tag of miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-474 * lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-1 Add CVS metadata files. * lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-2 Update from CVS. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-393
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/crisp.el3
-rw-r--r--lisp/emulation/cua-base.el272
-rw-r--r--lisp/emulation/cua-gmrk.el3
-rw-r--r--lisp/emulation/cua-rect.el4
-rw-r--r--lisp/emulation/edt-lk201.el3
-rw-r--r--lisp/emulation/edt-mapper.el3
-rw-r--r--lisp/emulation/edt-pc.el3
-rw-r--r--lisp/emulation/edt-vt100.el3
-rw-r--r--lisp/emulation/edt.el4
-rw-r--r--lisp/emulation/keypad.el2
-rw-r--r--lisp/emulation/pc-mode.el2
-rw-r--r--lisp/emulation/pc-select.el3
-rw-r--r--lisp/emulation/tpu-edt.el3
-rw-r--r--lisp/emulation/tpu-extras.el3
-rw-r--r--lisp/emulation/tpu-mapper.el3
-rw-r--r--lisp/emulation/vip.el4
-rw-r--r--lisp/emulation/viper-cmd.el113
-rw-r--r--lisp/emulation/viper-ex.el3
-rw-r--r--lisp/emulation/viper-init.el44
-rw-r--r--lisp/emulation/viper-keym.el100
-rw-r--r--lisp/emulation/viper-macs.el15
-rw-r--r--lisp/emulation/viper-mous.el5
-rw-r--r--lisp/emulation/viper-util.el35
-rw-r--r--lisp/emulation/viper.el81
-rw-r--r--lisp/emulation/ws-mode.el2
25 files changed, 464 insertions, 252 deletions
diff --git a/lisp/emulation/crisp.el b/lisp/emulation/crisp.el
index 4091fd5f01d..66ff29ecab1 100644
--- a/lisp/emulation/crisp.el
+++ b/lisp/emulation/crisp.el
@@ -1,6 +1,7 @@
1;;; crisp.el --- CRiSP/Brief Emacs emulator 1;;; crisp.el --- CRiSP/Brief Emacs emulator
2 2
3;; Copyright (C) 1997, 1998, 1999, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Gary D. Foster <Gary.Foster@Corp.Sun.COM> 6;; Author: Gary D. Foster <Gary.Foster@Corp.Sun.COM>
6;; Keywords: emulations brief crisp 7;; Keywords: emulations brief crisp
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index 551408cb34b..1b937da5018 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -1,7 +1,7 @@
1;;; cua-base.el --- emulate CUA key bindings 1;;; cua-base.el --- emulate CUA key bindings
2 2
3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2005 3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4;; Free Software Foundation, Inc. 4;; 2005 Free Software Foundation, Inc.
5 5
6;; Author: Kim F. Storm <storm@cua.dk> 6;; Author: Kim F. Storm <storm@cua.dk>
7;; Keywords: keyboard emulation convenience cua 7;; Keywords: keyboard emulation convenience cua
@@ -62,7 +62,7 @@
62;; If you really need to perform a command which starts with one of 62;; If you really need to perform a command which starts with one of
63;; the prefix keys even when the region is active, you have three options: 63;; the prefix keys even when the region is active, you have three options:
64;; - press the prefix key twice very quickly (within 0.2 seconds), 64;; - press the prefix key twice very quickly (within 0.2 seconds),
65;; - press the prefix key and the following key within 0.2 seconds), or 65;; - press the prefix key and the following key within 0.2 seconds, or
66;; - use the SHIFT key with the prefix key, i.e. C-X or C-C 66;; - use the SHIFT key with the prefix key, i.e. C-X or C-C
67;; 67;;
68;; This behaviour can be customized via the 68;; This behaviour can be customized via the
@@ -274,7 +274,7 @@
274(defcustom cua-enable-cua-keys t 274(defcustom cua-enable-cua-keys t
275 "*Enable using C-z, C-x, C-c, and C-v for undo, cut, copy, and paste. 275 "*Enable using C-z, C-x, C-c, and C-v for undo, cut, copy, and paste.
276If the value is t, these mappings are always enabled. If the value is 276If the value is t, these mappings are always enabled. If the value is
277'shift, these keys are only enabled if the last region was marked with 277`shift', these keys are only enabled if the last region was marked with
278a shifted movement key. If the value is nil, these keys are never 278a shifted movement key. If the value is nil, these keys are never
279enabled." 279enabled."
280 :type '(choice (const :tag "Disabled" nil) 280 :type '(choice (const :tag "Disabled" nil)
@@ -314,9 +314,9 @@ If the value is nil, use a shifted prefix key to inhibit the override."
314 "*If non-nil, registers are supported via numeric prefix arg. 314 "*If non-nil, registers are supported via numeric prefix arg.
315If the value is t, any numeric prefix arg in the range 0 to 9 will be 315If the value is t, any numeric prefix arg in the range 0 to 9 will be
316interpreted as a register number. 316interpreted as a register number.
317If the value is not-ctrl-u, using C-u to enter a numeric prefix is not 317If the value is `not-ctrl-u', using C-u to enter a numeric prefix is not
318interpreted as a register number. 318interpreted as a register number.
319If the value is ctrl-u-only, only numeric prefix entered with C-u is 319If the value is `ctrl-u-only', only numeric prefix entered with C-u is
320interpreted as a register number." 320interpreted as a register number."
321 :type '(choice (const :tag "Disabled" nil) 321 :type '(choice (const :tag "Disabled" nil)
322 (const :tag "Enabled, but C-u arg is not a register" not-ctrl-u) 322 (const :tag "Enabled, but C-u arg is not a register" not-ctrl-u)
@@ -331,7 +331,7 @@ interpreted as a register number."
331 331
332(defcustom cua-use-hyper-key nil 332(defcustom cua-use-hyper-key nil
333 "*If non-nil, bind rectangle commands to H-... instead of M-.... 333 "*If non-nil, bind rectangle commands to H-... instead of M-....
334If set to 'also, toggle region command is also on C-return. 334If set to `also', toggle region command is also on C-return.
335Must be set prior to enabling CUA." 335Must be set prior to enabling CUA."
336 :type '(choice (const :tag "Meta key and C-return" nil) 336 :type '(choice (const :tag "Meta key and C-return" nil)
337 (const :tag "Hyper key only" only) 337 (const :tag "Hyper key only" only)
@@ -362,7 +362,7 @@ managers, so try setting this to nil, if prefix override doesn't work."
362 "*If non-nil, rectangles have virtual straight edges. 362 "*If non-nil, rectangles have virtual straight edges.
363Note that although rectangles are always DISPLAYED with straight edges, the 363Note that although rectangles are always DISPLAYED with straight edges, the
364buffer is NOT modified, until you execute a command that actually modifies it. 364buffer is NOT modified, until you execute a command that actually modifies it.
365\[M-p] toggles this feature when a rectangle is active." 365M-p toggles this feature when a rectangle is active."
366 :type 'boolean 366 :type 'boolean
367 :group 'cua) 367 :group 'cua)
368 368
@@ -575,6 +575,7 @@ a cons (TYPE . COLOR), then both properties are affected."
575 575
576;; Current region was started using cua-set-mark. 576;; Current region was started using cua-set-mark.
577(defvar cua--explicit-region-start nil) 577(defvar cua--explicit-region-start nil)
578(make-variable-buffer-local 'cua--explicit-region-start)
578 579
579;; Latest region was started using shifted movement command. 580;; Latest region was started using shifted movement command.
580(defvar cua--last-region-shifted nil) 581(defvar cua--last-region-shifted nil)
@@ -585,6 +586,7 @@ a cons (TYPE . COLOR), then both properties are affected."
585 586
586;; status string for mode line indications 587;; status string for mode line indications
587(defvar cua--status-string nil) 588(defvar cua--status-string nil)
589(make-variable-buffer-local 'cua--status-string)
588 590
589(defvar cua--debug nil) 591(defvar cua--debug nil)
590 592
@@ -759,14 +761,19 @@ Save a copy in register 0 if `cua-delete-copy-to-register-0' is non-nil."
759 (cons (current-buffer) 761 (cons (current-buffer)
760 (and (consp buffer-undo-list) 762 (and (consp buffer-undo-list)
761 (car buffer-undo-list)))) 763 (car buffer-undo-list))))
762 (cua--deactivate))) 764 (cua--deactivate)
765 (/= start end)))
763 766
764(defun cua-replace-region () 767(defun cua-replace-region ()
765 "Replace the active region with the character you type." 768 "Replace the active region with the character you type."
766 (interactive) 769 (interactive)
767 (cua-delete-region) 770 (let ((not-empty (cua-delete-region)))
768 (unless (eq this-original-command this-command) 771 (unless (eq this-original-command this-command)
769 (cua--fallback))) 772 (let ((overwrite-mode
773 (and overwrite-mode
774 not-empty
775 (not (eq this-original-command 'self-insert-command)))))
776 (cua--fallback)))))
770 777
771(defun cua-copy-region (arg) 778(defun cua-copy-region (arg)
772 "Copy the region to the kill ring. 779 "Copy the region to the kill ring.
@@ -1060,118 +1067,122 @@ If ARG is the atom `-', scroll upward by nearly full screen."
1060 1067
1061;;; Pre-command hook 1068;;; Pre-command hook
1062 1069
1070(defun cua--pre-command-handler-1 ()
1071 (let ((movement (eq (get this-command 'CUA) 'move)))
1072
1073 ;; Cancel prefix key timeout if user enters another key.
1074 (when cua--prefix-override-timer
1075 (if (timerp cua--prefix-override-timer)
1076 (cancel-timer cua--prefix-override-timer))
1077 (setq cua--prefix-override-timer nil))
1078
1079 ;; Handle shifted cursor keys and other movement commands.
1080 ;; If region is not active, region is activated if key is shifted.
1081 ;; If region is active, region is cancelled if key is unshifted (and region not started with C-SPC).
1082 ;; If rectangle is active, expand rectangle in specified direction and ignore the movement.
1083 (if movement
1084 (cond
1085 ((if window-system
1086 (memq 'shift (event-modifiers
1087 (aref (this-single-command-raw-keys) 0)))
1088 (or
1089 (memq 'shift (event-modifiers
1090 (aref (this-single-command-keys) 0)))
1091 ;; See if raw escape sequence maps to a shifted event, e.g. S-up or C-S-home.
1092 (and (boundp 'local-function-key-map)
1093 (terminal-local-value 'function-key-map nil)
1094 (let ((ev (lookup-key (terminal-local-value 'function-key-map nil)
1095 (this-single-command-raw-keys))))
1096 (and (vector ev)
1097 (symbolp (setq ev (aref ev 0)))
1098 (string-match "S-" (symbol-name ev)))))))
1099 (unless mark-active
1100 (push-mark-command nil t))
1101 (setq cua--last-region-shifted t)
1102 (setq cua--explicit-region-start nil))
1103 ((or cua--explicit-region-start cua--rectangle)
1104 (unless mark-active
1105 (push-mark-command nil nil)))
1106 (t
1107 ;; If we set mark-active to nil here, the region highlight will not be
1108 ;; removed by the direct_output_ commands.
1109 (setq deactivate-mark t)))
1110
1111 ;; Handle delete-selection property on other commands
1112 (if (and mark-active (not deactivate-mark))
1113 (let* ((ds (or (get this-command 'delete-selection)
1114 (get this-command 'pending-delete)))
1115 (nc (cond
1116 ((not ds) nil)
1117 ((eq ds 'yank)
1118 'cua-paste)
1119 ((eq ds 'kill)
1120 (if cua--rectangle
1121 'cua-copy-rectangle
1122 'cua-copy-region))
1123 ((eq ds 'supersede)
1124 (if cua--rectangle
1125 'cua-delete-rectangle
1126 'cua-delete-region))
1127 (t
1128 (if cua--rectangle
1129 'cua-delete-rectangle ;; replace?
1130 'cua-replace-region)))))
1131 (if nc
1132 (setq this-original-command this-command
1133 this-command nc)))))
1134
1135 ;; Detect extension of rectangles by mouse or other movement
1136 (setq cua--buffer-and-point-before-command
1137 (if cua--rectangle (cons (current-buffer) (point))))))
1138
1063(defun cua--pre-command-handler () 1139(defun cua--pre-command-handler ()
1064 (condition-case nil 1140 (when cua-mode
1065 (let ((movement (eq (get this-command 'CUA) 'move))) 1141 (condition-case nil
1066 1142 (cua--pre-command-handler-1)
1067 ;; Cancel prefix key timeout if user enters another key. 1143 (error nil))))
1068 (when cua--prefix-override-timer
1069 (if (timerp cua--prefix-override-timer)
1070 (cancel-timer cua--prefix-override-timer))
1071 (setq cua--prefix-override-timer nil))
1072
1073 ;; Handle shifted cursor keys and other movement commands.
1074 ;; If region is not active, region is activated if key is shifted.
1075 ;; If region is active, region is cancelled if key is unshifted (and region not started with C-SPC).
1076 ;; If rectangle is active, expand rectangle in specified direction and ignore the movement.
1077 (if movement
1078 (cond
1079 ((if window-system
1080 (memq 'shift (event-modifiers
1081 (aref (this-single-command-raw-keys) 0)))
1082 (or
1083 (memq 'shift (event-modifiers
1084 (aref (this-single-command-keys) 0)))
1085 ;; See if raw escape sequence maps to a shifted event, e.g. S-up or C-S-home.
1086 (and (boundp 'local-function-key-map)
1087 (terminal-local-value 'local-function-key-map nil)
1088 (let ((ev (lookup-key (terminal-local-value 'local-function-key-map nil)
1089 (this-single-command-raw-keys))))
1090 (and (vector ev)
1091 (symbolp (setq ev (aref ev 0)))
1092 (string-match "S-" (symbol-name ev)))))))
1093 (unless mark-active
1094 (push-mark-command nil t))
1095 (setq cua--last-region-shifted t)
1096 (setq cua--explicit-region-start nil))
1097 ((or cua--explicit-region-start cua--rectangle)
1098 (unless mark-active
1099 (push-mark-command nil nil)))
1100 (t
1101 ;; If we set mark-active to nil here, the region highlight will not be
1102 ;; removed by the direct_output_ commands.
1103 (setq deactivate-mark t)))
1104
1105 ;; Handle delete-selection property on other commands
1106 (if (and mark-active (not deactivate-mark))
1107 (let* ((ds (or (get this-command 'delete-selection)
1108 (get this-command 'pending-delete)))
1109 (nc (cond
1110 ((not ds) nil)
1111 ((eq ds 'yank)
1112 'cua-paste)
1113 ((eq ds 'kill)
1114 (if cua--rectangle
1115 'cua-copy-rectangle
1116 'cua-copy-region))
1117 ((eq ds 'supersede)
1118 (if cua--rectangle
1119 'cua-delete-rectangle
1120 'cua-delete-region))
1121 (t
1122 (if cua--rectangle
1123 'cua-delete-rectangle ;; replace?
1124 'cua-replace-region)))))
1125 (if nc
1126 (setq this-original-command this-command
1127 this-command nc)))))
1128
1129 ;; Detect extension of rectangles by mouse or other movement
1130 (setq cua--buffer-and-point-before-command
1131 (if cua--rectangle (cons (current-buffer) (point))))
1132 )
1133 (error nil)))
1134 1144
1135;;; Post-command hook 1145;;; Post-command hook
1136 1146
1137(defun cua--post-command-handler () 1147(defun cua--post-command-handler-1 ()
1138 (condition-case nil 1148 (when cua--global-mark-active
1139 (progn 1149 (cua--global-mark-post-command))
1140 (when cua--global-mark-active 1150 (when (fboundp 'cua--rectangle-post-command)
1141 (cua--global-mark-post-command)) 1151 (cua--rectangle-post-command))
1142 (when (fboundp 'cua--rectangle-post-command) 1152 (setq cua--buffer-and-point-before-command nil)
1143 (cua--rectangle-post-command)) 1153 (if (or (not mark-active) deactivate-mark)
1144 (setq cua--buffer-and-point-before-command nil) 1154 (setq cua--explicit-region-start nil))
1145 (if (or (not mark-active) deactivate-mark) 1155
1146 (setq cua--explicit-region-start nil)) 1156 ;; Debugging
1147 1157 (if cua--debug
1148 ;; Debugging 1158 (cond
1149 (if cua--debug 1159 (cua--rectangle (cua--rectangle-assert))
1150 (cond 1160 (mark-active (message "Mark=%d Point=%d Expl=%s"
1151 (cua--rectangle (cua--rectangle-assert)) 1161 (mark t) (point) cua--explicit-region-start))))
1152 (mark-active (message "Mark=%d Point=%d Expl=%s" 1162
1153 (mark t) (point) cua--explicit-region-start)))) 1163 ;; Disable transient-mark-mode if rectangle active in current buffer.
1154 1164 (if (not (window-minibuffer-p (selected-window)))
1155 ;; Disable transient-mark-mode if rectangle active in current buffer. 1165 (setq transient-mark-mode (and (not cua--rectangle)
1156 (if (not (window-minibuffer-p (selected-window))) 1166 (if cua-highlight-region-shift-only
1157 (setq transient-mark-mode (and (not cua--rectangle) 1167 (not cua--explicit-region-start)
1158 (if cua-highlight-region-shift-only 1168 t))))
1159 (not cua--explicit-region-start) 1169 (if cua-enable-cursor-indications
1160 t)))) 1170 (cua--update-indications))
1161 (if cua-enable-cursor-indications
1162 (cua--update-indications))
1163 1171
1164 (cua--select-keymaps) 1172 (cua--select-keymaps))
1165 )
1166 1173
1167 (error nil))) 1174(defun cua--post-command-handler ()
1175 (when cua-mode
1176 (condition-case nil
1177 (cua--post-command-handler-1)
1178 (error nil))))
1168 1179
1169 1180
1170;;; Keymaps 1181;;; Keymaps
1171 1182
1172(defun cua--M/H-key (map key fct) 1183(defun cua--M/H-key (map key fct)
1173 ;; bind H-KEY or M-KEY to FCT in MAP 1184 ;; bind H-KEY or M-KEY to FCT in MAP
1174 (if (eq key 'space) (setq key ? )) 1185 (if (eq key 'space) (setq key ?\s))
1175 (unless (listp key) (setq key (list key))) 1186 (unless (listp key) (setq key (list key)))
1176 (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct)) 1187 (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct))
1177 1188
@@ -1240,7 +1251,7 @@ If ARG is the atom `-', scroll upward by nearly full screen."
1240 (cua--M/H-key cua-global-keymap 'space 'cua-set-rectangle-mark) 1251 (cua--M/H-key cua-global-keymap 'space 'cua-set-rectangle-mark)
1241 (define-key cua-global-keymap [(hyper mouse-1)] 'cua-mouse-set-rectangle-mark)) 1252 (define-key cua-global-keymap [(hyper mouse-1)] 'cua-mouse-set-rectangle-mark))
1242 1253
1243 (define-key cua-global-keymap [(shift control ? )] 'cua-toggle-global-mark) 1254 (define-key cua-global-keymap [(shift control ?\s)] 'cua-toggle-global-mark)
1244 1255
1245 ;; replace region with rectangle or element on kill ring 1256 ;; replace region with rectangle or element on kill ring
1246 (define-key cua-global-keymap [remap yank] 'cua-paste) 1257 (define-key cua-global-keymap [remap yank] 'cua-paste)
@@ -1328,10 +1339,26 @@ If ARG is the atom `-', scroll upward by nearly full screen."
1328;;;###autoload 1339;;;###autoload
1329(define-minor-mode cua-mode 1340(define-minor-mode cua-mode
1330 "Toggle CUA key-binding mode. 1341 "Toggle CUA key-binding mode.
1331When enabled, using shifted movement keys will activate the region (and 1342When enabled, using shifted movement keys will activate the
1332highlight the region using `transient-mark-mode'), and typed text replaces 1343region (and highlight the region using `transient-mark-mode'),
1333the active selection. C-z, C-x, C-c, and C-v will undo, cut, copy, and 1344and typed text replaces the active selection.
1334paste (in addition to the normal Emacs bindings)." 1345
1346Also when enabled, you can use C-z, C-x, C-c, and C-v to undo,
1347cut, copy, and paste in addition to the normal Emacs bindings.
1348The C-x and C-c keys only do cut and copy when the region is
1349active, so in most cases, they do not conflict with the normal
1350function of these prefix keys.
1351
1352If you really need to perform a command which starts with one of
1353the prefix keys even when the region is active, you have three
1354options:
1355- press the prefix key twice very quickly (within 0.2 seconds),
1356- press the prefix key and the following key within 0.2 seconds, or
1357- use the SHIFT key with the prefix key, i.e. C-S-x or C-S-c.
1358
1359You can customize `cua-enable-cua-keys' to completely disable the
1360CUA bindings, or `cua-prefix-override-inhibit-delay' to change
1361the prefix fallback behavior."
1335 :global t 1362 :global t
1336 :group 'cua 1363 :group 'cua
1337 :set-after '(cua-enable-modeline-indications cua-use-hyper-key) 1364 :set-after '(cua-enable-modeline-indications cua-use-hyper-key)
@@ -1339,8 +1366,6 @@ paste (in addition to the normal Emacs bindings)."
1339 :link '(emacs-commentary-link "cua-base.el") 1366 :link '(emacs-commentary-link "cua-base.el")
1340 (setq mark-even-if-inactive t) 1367 (setq mark-even-if-inactive t)
1341 (setq highlight-nonselected-windows nil) 1368 (setq highlight-nonselected-windows nil)
1342 (make-variable-buffer-local 'cua--explicit-region-start)
1343 (make-variable-buffer-local 'cua--status-string)
1344 1369
1345 (unless cua--keymaps-initalized 1370 (unless cua--keymaps-initalized
1346 (cua--init-keymaps) 1371 (cua--init-keymaps)
@@ -1393,6 +1418,15 @@ paste (in addition to the normal Emacs bindings)."
1393 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" ""))) 1418 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" "")))
1394 (setq cua--saved-state nil)))) 1419 (setq cua--saved-state nil))))
1395 1420
1421
1422;;;###autoload
1423(defun cua-selection-mode (arg)
1424 "Enable CUA selection mode without the C-z/C-x/C-c/C-v bindings."
1425 (interactive "P")
1426 (setq-default cua-enable-cua-keys nil)
1427 (cua-mode arg))
1428
1429
1396(defun cua-debug () 1430(defun cua-debug ()
1397 "Toggle CUA debugging." 1431 "Toggle CUA debugging."
1398 (interactive) 1432 (interactive)
diff --git a/lisp/emulation/cua-gmrk.el b/lisp/emulation/cua-gmrk.el
index 6ebbb6fc008..c7c5dd3db6d 100644
--- a/lisp/emulation/cua-gmrk.el
+++ b/lisp/emulation/cua-gmrk.el
@@ -1,6 +1,7 @@
1;;; cua-gmrk.el --- CUA unified global mark support 1;;; cua-gmrk.el --- CUA unified global mark support
2 2
3;; Copyright (C) 1997-2002 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Kim F. Storm <storm@cua.dk> 6;; Author: Kim F. Storm <storm@cua.dk>
6;; Keywords: keyboard emulations convenience cua mark 7;; Keywords: keyboard emulations convenience cua mark
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 011a0fb8a3f..d83ebd543cd 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -1,6 +1,7 @@
1;;; cua-rect.el --- CUA unified rectangle support 1;;; cua-rect.el --- CUA unified rectangle support
2 2
3;; Copyright (C) 1997-2002, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Kim F. Storm <storm@cua.dk> 6;; Author: Kim F. Storm <storm@cua.dk>
6;; Keywords: keyboard emulations convenience CUA 7;; Keywords: keyboard emulations convenience CUA
@@ -832,6 +833,7 @@ If command is repeated at same position, delete the rectangle."
832 (overlay-put overlay 'after-string as) 833 (overlay-put overlay 'after-string as)
833 (overlay-put overlay 'face rface) 834 (overlay-put overlay 'face rface)
834 (overlay-put overlay 'keymap cua--overlay-keymap) 835 (overlay-put overlay 'keymap cua--overlay-keymap)
836 (overlay-put overlay 'window (selected-window))
835 (setq new (cons overlay new)))))) 837 (setq new (cons overlay new))))))
836 ;; Trim old trailing overlays. 838 ;; Trim old trailing overlays.
837 (mapcar (function delete-overlay) old) 839 (mapcar (function delete-overlay) old)
diff --git a/lisp/emulation/edt-lk201.el b/lisp/emulation/edt-lk201.el
index a56c4656c07..4db235c60fa 100644
--- a/lisp/emulation/edt-lk201.el
+++ b/lisp/emulation/edt-lk201.el
@@ -1,6 +1,7 @@
1;;; edt-lk201.el --- enhanced EDT keypad mode emulation for LK-201 keyboards 1;;; edt-lk201.el --- enhanced EDT keypad mode emulation for LK-201 keyboards
2 2
3;; Copyright (C) 1986, 1992, 1993, 1995 Free Software Foundation, Inc. 3;; Copyright (C) 1986, 1992, 1993, 1995, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Kevin Gallagher <kevingal@onramp.net> 6;; Author: Kevin Gallagher <kevingal@onramp.net>
6;; Maintainer: Kevin Gallagher <kevingal@onramp.net> 7;; Maintainer: Kevin Gallagher <kevingal@onramp.net>
diff --git a/lisp/emulation/edt-mapper.el b/lisp/emulation/edt-mapper.el
index eeb34b9c7bb..9334c74392b 100644
--- a/lisp/emulation/edt-mapper.el
+++ b/lisp/emulation/edt-mapper.el
@@ -1,6 +1,7 @@
1;;; edt-mapper.el --- create an EDT LK-201 map file for X-Windows Emacs 1;;; edt-mapper.el --- create an EDT LK-201 map file for X-Windows Emacs
2 2
3;; Copyright (C) 1994, 1995, 2000, 2001 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 2000, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Kevin Gallagher <kevingal@onramp.net> 6;; Author: Kevin Gallagher <kevingal@onramp.net>
6;; Maintainer: Kevin Gallagher <kevingal@onramp.net> 7;; Maintainer: Kevin Gallagher <kevingal@onramp.net>
diff --git a/lisp/emulation/edt-pc.el b/lisp/emulation/edt-pc.el
index 41d0b772967..419f6549ba6 100644
--- a/lisp/emulation/edt-pc.el
+++ b/lisp/emulation/edt-pc.el
@@ -1,6 +1,7 @@
1;;; edt-pc.el --- enhanced EDT keypad mode emulation for PC 101 keyboards 1;;; edt-pc.el --- enhanced EDT keypad mode emulation for PC 101 keyboards
2 2
3;; Copyright (C) 1986, 1994, 1995 Free Software Foundation, Inc. 3;; Copyright (C) 1986, 1994, 1995, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Kevin Gallagher <kevingal@onramp.net> 6;; Author: Kevin Gallagher <kevingal@onramp.net>
6;; Maintainer: Kevin Gallagher <kevingal@onramp.net> 7;; Maintainer: Kevin Gallagher <kevingal@onramp.net>
diff --git a/lisp/emulation/edt-vt100.el b/lisp/emulation/edt-vt100.el
index 7104c53a77f..cd9a065acf8 100644
--- a/lisp/emulation/edt-vt100.el
+++ b/lisp/emulation/edt-vt100.el
@@ -1,6 +1,7 @@
1;;; edt-vt100.el --- enhanced EDT keypad mode emulation for VT series terminals 1;;; edt-vt100.el --- enhanced EDT keypad mode emulation for VT series terminals
2 2
3;; Copyright (C) 1986, 1992, 1993, 1995 Free Software Foundation, Inc. 3;; Copyright (C) 1986, 1992, 1993, 1995, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Kevin Gallagher <kevingal@onramp.net> 6;; Author: Kevin Gallagher <kevingal@onramp.net>
6;; Maintainer: Kevin Gallagher <kevingal@onramp.net> 7;; Maintainer: Kevin Gallagher <kevingal@onramp.net>
diff --git a/lisp/emulation/edt.el b/lisp/emulation/edt.el
index 8eecf5fca58..8d5071be314 100644
--- a/lisp/emulation/edt.el
+++ b/lisp/emulation/edt.el
@@ -1,7 +1,7 @@
1;;; edt.el --- enhanced EDT keypad mode emulation for GNU Emacs 19 1;;; edt.el --- enhanced EDT keypad mode emulation for GNU Emacs 19
2 2
3;; Copyright (C) 1986, 1992, 1993, 1994, 1995, 2000, 2001 3;; Copyright (C) 1986, 1992, 1993, 1994, 1995, 2000, 2001, 2002, 2003,
4;; Free Software Foundation, Inc. 4;; 2004, 2005 Free Software Foundation, Inc.
5 5
6;; Author: Kevin Gallagher <kevingal@onramp.net> 6;; Author: Kevin Gallagher <kevingal@onramp.net>
7;; Maintainer: Kevin Gallagher <kevingal@onramp.net> 7;; Maintainer: Kevin Gallagher <kevingal@onramp.net>
diff --git a/lisp/emulation/keypad.el b/lisp/emulation/keypad.el
index 3e492005f8d..a42edaa78a1 100644
--- a/lisp/emulation/keypad.el
+++ b/lisp/emulation/keypad.el
@@ -1,6 +1,6 @@
1;;; keypad.el --- simplified keypad bindings 1;;; keypad.el --- simplified keypad bindings
2 2
3;; Copyright (C) 2002 Free Software Foundation, Inc. 3;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5;; Author: Kim F. Storm <storm@cua.dk> 5;; Author: Kim F. Storm <storm@cua.dk>
6;; Keywords: keyboard convenience 6;; Keywords: keyboard convenience
diff --git a/lisp/emulation/pc-mode.el b/lisp/emulation/pc-mode.el
index 3bcb60ec0bb..1ec66664b6a 100644
--- a/lisp/emulation/pc-mode.el
+++ b/lisp/emulation/pc-mode.el
@@ -1,6 +1,6 @@
1;;; pc-mode.el --- emulate certain key bindings used on PCs 1;;; pc-mode.el --- emulate certain key bindings used on PCs
2 2
3;; Copyright (C) 1995 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5;; Maintainer: FSF 5;; Maintainer: FSF
6;; Keywords: emulations 6;; Keywords: emulations
diff --git a/lisp/emulation/pc-select.el b/lisp/emulation/pc-select.el
index 3a85a430153..9b9f4d51b41 100644
--- a/lisp/emulation/pc-select.el
+++ b/lisp/emulation/pc-select.el
@@ -2,7 +2,8 @@
2;;; (or MAC GUI or MS-windoze (bah)) look-and-feel 2;;; (or MAC GUI or MS-windoze (bah)) look-and-feel
3;;; including key bindings. 3;;; including key bindings.
4 4
5;; Copyright (C) 1995, 1996, 1997, 2000, 2001, 2005 Free Software Foundation, Inc. 5;; Copyright (C) 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004,
6;; 2005 Free Software Foundation, Inc.
6 7
7;; Author: Michael Staats <michael@thp.Uni-Duisburg.DE> 8;; Author: Michael Staats <michael@thp.Uni-Duisburg.DE>
8;; Keywords: convenience emulation 9;; Keywords: convenience emulation
diff --git a/lisp/emulation/tpu-edt.el b/lisp/emulation/tpu-edt.el
index 3c18e2f608f..eca6e5c74ce 100644
--- a/lisp/emulation/tpu-edt.el
+++ b/lisp/emulation/tpu-edt.el
@@ -1,6 +1,7 @@
1;;; tpu-edt.el --- Emacs emulating TPU emulating EDT 1;;; tpu-edt.el --- Emacs emulating TPU emulating EDT
2 2
3;; Copyright (C) 1993, 1994, 1995, 2000, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994, 1995, 2000, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Rob Riepel <riepel@networking.stanford.edu> 6;; Author: Rob Riepel <riepel@networking.stanford.edu>
6;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> 7;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
diff --git a/lisp/emulation/tpu-extras.el b/lisp/emulation/tpu-extras.el
index 51ed44346ad..c48aa974762 100644
--- a/lisp/emulation/tpu-extras.el
+++ b/lisp/emulation/tpu-extras.el
@@ -1,6 +1,7 @@
1;;; tpu-extras.el --- scroll margins and free cursor mode for TPU-edt 1;;; tpu-extras.el --- scroll margins and free cursor mode for TPU-edt
2 2
3;; Copyright (C) 1993, 1994, 1995, 2000 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994, 1995, 2000, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Rob Riepel <riepel@networking.stanford.edu> 6;; Author: Rob Riepel <riepel@networking.stanford.edu>
6;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> 7;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
diff --git a/lisp/emulation/tpu-mapper.el b/lisp/emulation/tpu-mapper.el
index 66d6541ac0f..e21a85db2af 100644
--- a/lisp/emulation/tpu-mapper.el
+++ b/lisp/emulation/tpu-mapper.el
@@ -1,6 +1,7 @@
1;;; tpu-mapper.el --- create a TPU-edt X-windows keymap file 1;;; tpu-mapper.el --- create a TPU-edt X-windows keymap file
2 2
3;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994, 1995, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Rob Riepel <riepel@networking.stanford.edu> 6;; Author: Rob Riepel <riepel@networking.stanford.edu>
6;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> 7;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
diff --git a/lisp/emulation/vip.el b/lisp/emulation/vip.el
index aa6e75357ed..51fbdb6b8c4 100644
--- a/lisp/emulation/vip.el
+++ b/lisp/emulation/vip.el
@@ -1,7 +1,7 @@
1;;; vip.el --- a VI Package for GNU Emacs 1;;; vip.el --- a VI Package for GNU Emacs
2 2
3;; Copyright (C) 1986, 1987, 1988, 1992, 1993, 1998, 2005 3;; Copyright (C) 1986, 1987, 1988, 1992, 1993, 1998, 2002, 2003, 2004,
4;; Free Software Foundation, Inc. 4;; 2005 Free Software Foundation, Inc.
5 5
6;; Author: Masahiko Sato <ms@sail.stanford.edu> 6;; Author: Masahiko Sato <ms@sail.stanford.edu>
7;; Keywords: emulations 7;; Keywords: emulations
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 4f247f2cd38..99a130e7f1d 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1,6 +1,7 @@
1;;; viper-cmd.el --- Vi command support for Viper 1;;; viper-cmd.el --- Vi command support for Viper
2 2
3;; Copyright (C) 1997, 98, 99, 2000, 01, 02, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6 7
@@ -36,6 +37,8 @@
36(defvar viper-always) 37(defvar viper-always)
37(defvar viper-mode-string) 38(defvar viper-mode-string)
38(defvar viper-custom-file-name) 39(defvar viper-custom-file-name)
40(defvar viper--key-maps)
41(defvar viper--intercept-key-maps)
39(defvar iso-accents-mode) 42(defvar iso-accents-mode)
40(defvar quail-mode) 43(defvar quail-mode)
41(defvar quail-current-str) 44(defvar quail-current-str)
@@ -92,7 +95,7 @@
92;; Variables for defining VI commands 95;; Variables for defining VI commands
93 96
94;; Modifying commands that can be prefixes to movement commands 97;; Modifying commands that can be prefixes to movement commands
95(defconst viper-prefix-commands '(?c ?d ?y ?! ?= ?# ?< ?> ?\")) 98(defvar viper-prefix-commands '(?c ?d ?y ?! ?= ?# ?< ?> ?\"))
96;; define viper-prefix-command-p 99;; define viper-prefix-command-p
97(viper-test-com-defun viper-prefix-command) 100(viper-test-com-defun viper-prefix-command)
98 101
@@ -440,23 +443,24 @@
440;; This ensures that Viper bindings are in effect, regardless of which minor 443;; This ensures that Viper bindings are in effect, regardless of which minor
441;; modes were turned on by the user or by other packages. 444;; modes were turned on by the user or by other packages.
442(defun viper-normalize-minor-mode-map-alist () 445(defun viper-normalize-minor-mode-map-alist ()
443 (setq minor-mode-map-alist 446 (setq viper--intercept-key-maps
444 (viper-append-filter-alist 447 (list
445 (list (cons 'viper-vi-intercept-minor-mode viper-vi-intercept-map) 448 (cons 'viper-vi-intercept-minor-mode viper-vi-intercept-map)
446 (cons 'viper-vi-minibuffer-minor-mode viper-minibuffer-map) 449 (cons 'viper-insert-intercept-minor-mode viper-insert-intercept-map)
447 (cons 'viper-vi-local-user-minor-mode viper-vi-local-user-map) 450 (cons 'viper-emacs-intercept-minor-mode viper-emacs-intercept-map)
448 (cons 'viper-vi-kbd-minor-mode viper-vi-kbd-map) 451 ))
449 (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map) 452 (setq viper--key-maps
450 (cons 'viper-vi-state-modifier-minor-mode 453 (list (cons 'viper-vi-minibuffer-minor-mode viper-minibuffer-map)
451 (if (keymapp 454 (cons 'viper-vi-local-user-minor-mode viper-vi-local-user-map)
452 (cdr (assoc major-mode 455 (cons 'viper-vi-kbd-minor-mode viper-vi-kbd-map)
453 viper-vi-state-modifier-alist))) 456 (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map)
454 (cdr (assoc major-mode viper-vi-state-modifier-alist)) 457 (cons 'viper-vi-state-modifier-minor-mode
455 viper-empty-keymap)) 458 (if (keymapp
456 (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map) 459 (cdr (assoc major-mode viper-vi-state-modifier-alist)))
457 (cons 'viper-vi-basic-minor-mode viper-vi-basic-map) 460 (cdr (assoc major-mode viper-vi-state-modifier-alist))
458 (cons 'viper-insert-intercept-minor-mode 461 viper-empty-keymap))
459 viper-insert-intercept-map) 462 (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map)
463 (cons 'viper-vi-basic-minor-mode viper-vi-basic-map)
460 (cons 'viper-replace-minor-mode viper-replace-map) 464 (cons 'viper-replace-minor-mode viper-replace-map)
461 ;; viper-insert-minibuffer-minor-mode must come after 465 ;; viper-insert-minibuffer-minor-mode must come after
462 ;; viper-replace-minor-mode 466 ;; viper-replace-minor-mode
@@ -476,8 +480,6 @@
476 viper-empty-keymap)) 480 viper-empty-keymap))
477 (cons 'viper-insert-diehard-minor-mode viper-insert-diehard-map) 481 (cons 'viper-insert-diehard-minor-mode viper-insert-diehard-map)
478 (cons 'viper-insert-basic-minor-mode viper-insert-basic-map) 482 (cons 'viper-insert-basic-minor-mode viper-insert-basic-map)
479 (cons 'viper-emacs-intercept-minor-mode
480 viper-emacs-intercept-map)
481 (cons 'viper-emacs-local-user-minor-mode 483 (cons 'viper-emacs-local-user-minor-mode
482 viper-emacs-local-user-map) 484 viper-emacs-local-user-map)
483 (cons 'viper-emacs-kbd-minor-mode viper-emacs-kbd-map) 485 (cons 'viper-emacs-kbd-minor-mode viper-emacs-kbd-map)
@@ -490,8 +492,16 @@
490 (cdr 492 (cdr
491 (assoc major-mode viper-emacs-state-modifier-alist)) 493 (assoc major-mode viper-emacs-state-modifier-alist))
492 viper-empty-keymap)) 494 viper-empty-keymap))
493 ) 495 ))
494 minor-mode-map-alist))) 496
497 ;; in emacs with emulation-mode-map-alists, nothing needs to be done
498 (unless
499 (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
500 (setq minor-mode-map-alist
501 (viper-append-filter-alist
502 (append viper--intercept-key-maps viper--key-maps)
503 minor-mode-map-alist)))
504 )
495 505
496 506
497 507
@@ -765,7 +775,8 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
765 ) 775 )
766 776
767 (if (commandp com) 777 (if (commandp com)
768 (progn 778 ;; pretend that current state is the state we excaped to
779 (let ((viper-current-state state))
769 (setq prefix-arg (or prefix-arg arg)) 780 (setq prefix-arg (or prefix-arg arg))
770 (command-execute com))) 781 (command-execute com)))
771 ) 782 )
@@ -931,8 +942,10 @@ Suffixes such as .el or .elc should be stripped."
931 942
932 ;; Change the default for minor-mode-map-alist each time a harnessed minor 943 ;; Change the default for minor-mode-map-alist each time a harnessed minor
933 ;; mode adds its own keymap to the a-list. 944 ;; mode adds its own keymap to the a-list.
934 (eval-after-load 945 (unless
935 load-file '(setq-default minor-mode-map-alist minor-mode-map-alist)) 946 (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
947 (eval-after-load
948 load-file '(setq-default minor-mode-map-alist minor-mode-map-alist)))
936 ) 949 )
937 950
938 951
@@ -987,9 +1000,12 @@ as a Meta key and any number of multiple escapes is allowed."
987 (inhibit-quit t)) 1000 (inhibit-quit t))
988 (if (viper-ESC-event-p event) 1001 (if (viper-ESC-event-p event)
989 (progn 1002 (progn
990 (if (viper-fast-keysequence-p) 1003 ;; Emacs 22.50.8 introduced a bug, which makes even a single ESC into
1004 ;; a fast keyseq. To guard against this, we added a check if there
1005 ;; are other events as well
1006 (if (and (viper-fast-keysequence-p) unread-command-events)
991 (progn 1007 (progn
992 (let (minor-mode-map-alist) 1008 (let (minor-mode-map-alist emulation-mode-map-alists)
993 (viper-set-unread-command-events event) 1009 (viper-set-unread-command-events event)
994 (setq keyseq (read-key-sequence nil 'continue-echo)) 1010 (setq keyseq (read-key-sequence nil 'continue-echo))
995 ) ; let 1011 ) ; let
@@ -1021,7 +1037,7 @@ as a Meta key and any number of multiple escapes is allowed."
1021 (not viper-translate-all-ESC-keysequences)) 1037 (not viper-translate-all-ESC-keysequences))
1022 ;; put keys following ESC on the unread list 1038 ;; put keys following ESC on the unread list
1023 ;; and return ESC as the key-sequence 1039 ;; and return ESC as the key-sequence
1024 (viper-set-unread-command-events (subseq keyseq 1)) 1040 (viper-set-unread-command-events (viper-subseq keyseq 1))
1025 (setq last-input-event event 1041 (setq last-input-event event
1026 keyseq (if viper-emacs-p 1042 keyseq (if viper-emacs-p
1027 "\e" 1043 "\e"
@@ -1032,7 +1048,7 @@ as a Meta key and any number of multiple escapes is allowed."
1032 (viper-set-unread-command-events 1048 (viper-set-unread-command-events
1033 (vconcat (vector 1049 (vconcat (vector
1034 (character-to-event (event-key first-key))) 1050 (character-to-event (event-key first-key)))
1035 (subseq keyseq 1))) 1051 (viper-subseq keyseq 1)))
1036 (setq last-input-event event 1052 (setq last-input-event event
1037 keyseq (vector (character-to-event ?\e)))) 1053 keyseq (vector (character-to-event ?\e))))
1038 ((eventp first-key) 1054 ((eventp first-key)
@@ -1407,7 +1423,8 @@ as a Meta key and any number of multiple escapes is allowed."
1407 (if (eq last-command 'd-command) 'kill-region nil)) 1423 (if (eq last-command 'd-command) 'kill-region nil))
1408 (setq chars-deleted (abs (- (point) viper-com-point))) 1424 (setq chars-deleted (abs (- (point) viper-com-point)))
1409 (if (> chars-deleted viper-change-notification-threshold) 1425 (if (> chars-deleted viper-change-notification-threshold)
1410 (message "Deleted %d characters" chars-deleted)) 1426 (unless (viper-is-in-minibuffer)
1427 (message "Deleted %d characters" chars-deleted)))
1411 (kill-region viper-com-point (point)) 1428 (kill-region viper-com-point (point))
1412 (setq this-command 'd-command) 1429 (setq this-command 'd-command)
1413 (if viper-ex-style-motion 1430 (if viper-ex-style-motion
@@ -1433,7 +1450,8 @@ as a Meta key and any number of multiple escapes is allowed."
1433 (if (eq last-command 'D-command) 'kill-region nil)) 1450 (if (eq last-command 'D-command) 'kill-region nil))
1434 (setq lines-deleted (count-lines (point) viper-com-point)) 1451 (setq lines-deleted (count-lines (point) viper-com-point))
1435 (if (> lines-deleted viper-change-notification-threshold) 1452 (if (> lines-deleted viper-change-notification-threshold)
1436 (message "Deleted %d lines" lines-deleted)) 1453 (unless (viper-is-in-minibuffer)
1454 (message "Deleted %d lines" lines-deleted)))
1437 (kill-region (mark t) (point)) 1455 (kill-region (mark t) (point))
1438 (if (eq m-com 'viper-line) (setq this-command 'D-command))) 1456 (if (eq m-com 'viper-line) (setq this-command 'D-command)))
1439 (back-to-indentation))) 1457 (back-to-indentation)))
@@ -1458,7 +1476,8 @@ as a Meta key and any number of multiple escapes is allowed."
1458 (copy-region-as-kill viper-com-point (point)) 1476 (copy-region-as-kill viper-com-point (point))
1459 (setq chars-saved (abs (- (point) viper-com-point))) 1477 (setq chars-saved (abs (- (point) viper-com-point)))
1460 (if (> chars-saved viper-change-notification-threshold) 1478 (if (> chars-saved viper-change-notification-threshold)
1461 (message "Saved %d characters" chars-saved)) 1479 (unless (viper-is-in-minibuffer)
1480 (message "Saved %d characters" chars-saved)))
1462 (goto-char viper-com-point))) 1481 (goto-char viper-com-point)))
1463 1482
1464;; save lines 1483;; save lines
@@ -1482,7 +1501,8 @@ as a Meta key and any number of multiple escapes is allowed."
1482 (copy-region-as-kill (mark t) (point)) 1501 (copy-region-as-kill (mark t) (point))
1483 (setq lines-saved (count-lines (mark t) (point))) 1502 (setq lines-saved (count-lines (mark t) (point)))
1484 (if (> lines-saved viper-change-notification-threshold) 1503 (if (> lines-saved viper-change-notification-threshold)
1485 (message "Saved %d lines" lines-saved)))) 1504 (unless (viper-is-in-minibuffer)
1505 (message "Saved %d lines" lines-saved)))))
1486 (viper-deactivate-mark) 1506 (viper-deactivate-mark)
1487 (goto-char viper-com-point)) 1507 (goto-char viper-com-point))
1488 1508
@@ -3732,7 +3752,8 @@ Null string will repeat previous search."
3732 (interactive "P") 3752 (interactive "P")
3733 (let ((val (viper-P-val arg)) 3753 (let ((val (viper-P-val arg))
3734 (com (viper-getcom arg)) 3754 (com (viper-getcom arg))
3735 (old-str viper-s-string)) 3755 (old-str viper-s-string)
3756 debug-on-error)
3736 (setq viper-s-forward t) 3757 (setq viper-s-forward t)
3737 (viper-if-string "/") 3758 (viper-if-string "/")
3738 ;; this is not used at present, but may be used later 3759 ;; this is not used at present, but may be used later
@@ -3744,7 +3765,8 @@ Null string will repeat previous search."
3744 (if com 3765 (if com
3745 (progn 3766 (progn
3746 (viper-move-marker-locally 'viper-com-point (mark t)) 3767 (viper-move-marker-locally 'viper-com-point (mark t))
3747 (viper-execute-com 'viper-search-next val com))))) 3768 (viper-execute-com 'viper-search-next val com)))
3769 ))
3748 3770
3749(defun viper-search-backward (arg) 3771(defun viper-search-backward (arg)
3750 "Search a string backward. 3772 "Search a string backward.
@@ -3753,7 +3775,8 @@ Null string will repeat previous search."
3753 (interactive "P") 3775 (interactive "P")
3754 (let ((val (viper-P-val arg)) 3776 (let ((val (viper-P-val arg))
3755 (com (viper-getcom arg)) 3777 (com (viper-getcom arg))
3756 (old-str viper-s-string)) 3778 (old-str viper-s-string)
3779 debug-on-error)
3757 (setq viper-s-forward nil) 3780 (setq viper-s-forward nil)
3758 (viper-if-string "?") 3781 (viper-if-string "?")
3759 ;; this is not used at present, but may be used later 3782 ;; this is not used at present, but may be used later
@@ -3858,7 +3881,8 @@ Null string will repeat previous search."
3858 "Repeat previous search." 3881 "Repeat previous search."
3859 (interactive "P") 3882 (interactive "P")
3860 (let ((val (viper-p-val arg)) 3883 (let ((val (viper-p-val arg))
3861 (com (viper-getcom arg))) 3884 (com (viper-getcom arg))
3885 debug-on-error)
3862 (if (null viper-s-string) (error viper-NoPrevSearch)) 3886 (if (null viper-s-string) (error viper-NoPrevSearch))
3863 (viper-search viper-s-string viper-s-forward arg) 3887 (viper-search viper-s-string viper-s-forward arg)
3864 (if com 3888 (if com
@@ -3870,7 +3894,8 @@ Null string will repeat previous search."
3870 "Repeat previous search in the reverse direction." 3894 "Repeat previous search in the reverse direction."
3871 (interactive "P") 3895 (interactive "P")
3872 (let ((val (viper-p-val arg)) 3896 (let ((val (viper-p-val arg))
3873 (com (viper-getcom arg))) 3897 (com (viper-getcom arg))
3898 debug-on-error)
3874 (if (null viper-s-string) (error viper-NoPrevSearch)) 3899 (if (null viper-s-string) (error viper-NoPrevSearch))
3875 (viper-search viper-s-string (not viper-s-forward) arg) 3900 (viper-search viper-s-string (not viper-s-forward) arg)
3876 (if com 3901 (if com
@@ -4001,8 +4026,9 @@ Null string will repeat previous search."
4001 lines-inserted (abs (count-lines (point) sv-point))) 4026 lines-inserted (abs (count-lines (point) sv-point)))
4002 (if (or (> chars-inserted viper-change-notification-threshold) 4027 (if (or (> chars-inserted viper-change-notification-threshold)
4003 (> lines-inserted viper-change-notification-threshold)) 4028 (> lines-inserted viper-change-notification-threshold))
4004 (message "Inserted %d character(s), %d line(s)" 4029 (unless (viper-is-in-minibuffer)
4005 chars-inserted lines-inserted))) 4030 (message "Inserted %d character(s), %d line(s)"
4031 chars-inserted lines-inserted))))
4006 ;; Vi puts cursor on the last char when the yanked text doesn't contain a 4032 ;; Vi puts cursor on the last char when the yanked text doesn't contain a
4007 ;; newline; it leaves the cursor at the beginning when the text contains 4033 ;; newline; it leaves the cursor at the beginning when the text contains
4008 ;; a newline 4034 ;; a newline
@@ -4043,8 +4069,9 @@ Null string will repeat previous search."
4043 lines-inserted (abs (count-lines (point) sv-point))) 4069 lines-inserted (abs (count-lines (point) sv-point)))
4044 (if (or (> chars-inserted viper-change-notification-threshold) 4070 (if (or (> chars-inserted viper-change-notification-threshold)
4045 (> lines-inserted viper-change-notification-threshold)) 4071 (> lines-inserted viper-change-notification-threshold))
4046 (message "Inserted %d character(s), %d line(s)" 4072 (unless (viper-is-in-minibuffer)
4047 chars-inserted lines-inserted))) 4073 (message "Inserted %d character(s), %d line(s)"
4074 chars-inserted lines-inserted))))
4048 ;; Vi puts cursor on the last char when the yanked text doesn't contain a 4075 ;; Vi puts cursor on the last char when the yanked text doesn't contain a
4049 ;; newline; it leaves the cursor at the beginning when the text contains 4076 ;; newline; it leaves the cursor at the beginning when the text contains
4050 ;; a newline 4077 ;; a newline
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index 008b430d167..87d2d7f5d5a 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -1,6 +1,7 @@
1;;; viper-ex.el --- functions implementing the Ex commands for Viper 1;;; viper-ex.el --- functions implementing the Ex commands for Viper
2 2
3;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003,
4;; 2004, 2005 Free Software Foundation, Inc.
4 5
5;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6 7
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index 6e188f21a9d..9c1df1b0ad5 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -1,6 +1,7 @@
1;;; viper-init.el --- some common definitions for Viper 1;;; viper-init.el --- some common definitions for Viper
2 2
3;; Copyright (C) 1997, 98, 99, 2000, 01, 02, 05 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6 7
@@ -362,8 +363,8 @@ Use `M-x viper-set-expert-level' to change this.")
362(defun viper-activate-input-method () 363(defun viper-activate-input-method ()
363 (cond ((and viper-emacs-p (fboundp 'activate-input-method)) 364 (cond ((and viper-emacs-p (fboundp 'activate-input-method))
364 (activate-input-method default-input-method)) 365 (activate-input-method default-input-method))
365 ((and viper-xemacs-p (fboundp 'quail-mode)) 366 ((featurep 'xemacs)
366 (quail-mode 1)))) 367 (if (fboundp 'quail-mode) (quail-mode 1)))))
367 368
368;; Set quail-mode to ARG 369;; Set quail-mode to ARG
369(defun viper-set-input-method (arg) 370(defun viper-set-input-method (arg)
@@ -423,13 +424,20 @@ delete the text being replaced, as in standard Vi."
423 "*Cursor color when Viper is in Replace state." 424 "*Cursor color when Viper is in Replace state."
424 :type 'string 425 :type 'string
425 :group 'viper) 426 :group 'viper)
427(if (fboundp 'make-variable-frame-local)
428 (make-variable-frame-local 'viper-replace-overlay-cursor-color))
429
426(defcustom viper-insert-state-cursor-color "Green" 430(defcustom viper-insert-state-cursor-color "Green"
427 "Cursor color when Viper is in insert state." 431 "Cursor color when Viper is in insert state."
428 :type 'string 432 :type 'string
429 :group 'viper) 433 :group 'viper)
434(if (fboundp 'make-variable-frame-local)
435 (make-variable-frame-local 'viper-insert-state-cursor-color))
430 436
431;; internal var, used to remember the default cursor color of emacs frames 437;; internal var, used to remember the default cursor color of emacs frames
432(defvar viper-vi-state-cursor-color nil) 438(defvar viper-vi-state-cursor-color nil)
439(if (fboundp 'make-variable-frame-local)
440 (make-variable-frame-local 'viper-vi-state-cursor-color))
433 441
434(viper-deflocalvar viper-replace-overlay nil "") 442(viper-deflocalvar viper-replace-overlay nil "")
435(put 'viper-replace-overlay 'permanent-local t) 443(put 'viper-replace-overlay 'permanent-local t)
@@ -855,15 +863,13 @@ Related buffers can be cycled through via :R and :P commands."
855 (t (:underline t :stipple "gray3"))) 863 (t (:underline t :stipple "gray3")))
856 "*Face used to flash out the search pattern." 864 "*Face used to flash out the search pattern."
857 :group 'viper-highlighting) 865 :group 'viper-highlighting)
858;; backward-compatibility alias
859(put 'viper-search-face 'face-alias 'viper-search)
860;; An internal variable. Viper takes the face from here. 866;; An internal variable. Viper takes the face from here.
861(defvar viper-search-face 'viper-search 867(defvar viper-search-face 'viper-search
862 "Face used to flash out the search pattern. 868 "Face used to flash out the search pattern.
863DO NOT CHANGE this variable. Instead, use the customization widget 869DO NOT CHANGE this variable. Instead, use the customization widget
864to customize the actual face object `viper-search-face' 870to customize the actual face object `viper-search'
865this variable represents.") 871this variable represents.")
866(viper-hide-face 'viper-search) 872(viper-hide-face viper-search-face)
867 873
868 874
869(defface viper-replace-overlay 875(defface viper-replace-overlay
@@ -871,15 +877,13 @@ this variable represents.")
871 (t (:underline t :stipple "gray3"))) 877 (t (:underline t :stipple "gray3")))
872 "*Face for highlighting replace regions on a window display." 878 "*Face for highlighting replace regions on a window display."
873 :group 'viper-highlighting) 879 :group 'viper-highlighting)
874;; backward-compatibility alias
875(put 'viper-replace-overlay-face 'face-alias 'viper-replace-overlay)
876;; An internal variable. Viper takes the face from here. 880;; An internal variable. Viper takes the face from here.
877(defvar viper-replace-overlay-face 'viper-replace-overlay 881(defvar viper-replace-overlay-face 'viper-replace-overlay
878 "Face for highlighting replace regions on a window display. 882 "Face for highlighting replace regions on a window display.
879DO NOT CHANGE this variable. Instead, use the customization widget 883DO NOT CHANGE this variable. Instead, use the customization widget
880to customize the actual face object `viper-replace-overlay-face' 884to customize the actual face object `viper-replace-overlay'
881this variable represents.") 885this variable represents.")
882(viper-hide-face 'viper-replace-overlay) 886(viper-hide-face viper-replace-overlay-face)
883 887
884 888
885(defface viper-minibuffer-emacs 889(defface viper-minibuffer-emacs
@@ -887,15 +891,13 @@ this variable represents.")
887 (t (:weight bold))) 891 (t (:weight bold)))
888 "Face used in the Minibuffer when it is in Emacs state." 892 "Face used in the Minibuffer when it is in Emacs state."
889 :group 'viper-highlighting) 893 :group 'viper-highlighting)
890;; backward-compatibility alias
891(put 'viper-minibuffer-emacs-face 'face-alias 'viper-minibuffer-emacs)
892;; An internal variable. Viper takes the face from here. 894;; An internal variable. Viper takes the face from here.
893(defvar viper-minibuffer-emacs-face 'viper-minibuffer-emacs 895(defvar viper-minibuffer-emacs-face 'viper-minibuffer-emacs
894 "Face used in the Minibuffer when it is in Emacs state. 896 "Face used in the Minibuffer when it is in Emacs state.
895DO NOT CHANGE this variable. Instead, use the customization widget 897DO NOT CHANGE this variable. Instead, use the customization widget
896to customize the actual face object `viper-minibuffer-emacs-face' 898to customize the actual face object `viper-minibuffer-emacs'
897this variable represents.") 899this variable represents.")
898(viper-hide-face 'viper-minibuffer-emacs) 900(viper-hide-face viper-minibuffer-emacs-face)
899 901
900 902
901(defface viper-minibuffer-insert 903(defface viper-minibuffer-insert
@@ -903,15 +905,13 @@ this variable represents.")
903 (t (:slant italic))) 905 (t (:slant italic)))
904 "Face used in the Minibuffer when it is in Insert state." 906 "Face used in the Minibuffer when it is in Insert state."
905 :group 'viper-highlighting) 907 :group 'viper-highlighting)
906;; backward-compatibility alias
907(put 'viper-minibuffer-insert-face 'face-alias 'viper-minibuffer-insert)
908;; An internal variable. Viper takes the face from here. 908;; An internal variable. Viper takes the face from here.
909(defvar viper-minibuffer-insert-face 'viper-minibuffer-insert 909(defvar viper-minibuffer-insert-face 'viper-minibuffer-insert
910 "Face used in the Minibuffer when it is in Insert state. 910 "Face used in the Minibuffer when it is in Insert state.
911DO NOT CHANGE this variable. Instead, use the customization widget 911DO NOT CHANGE this variable. Instead, use the customization widget
912to customize the actual face object `viper-minibuffer-insert-face' 912to customize the actual face object `viper-minibuffer-insert'
913this variable represents.") 913this variable represents.")
914(viper-hide-face 'viper-minibuffer-insert) 914(viper-hide-face viper-minibuffer-insert-face)
915 915
916 916
917(defface viper-minibuffer-vi 917(defface viper-minibuffer-vi
@@ -919,15 +919,13 @@ this variable represents.")
919 (t (:inverse-video t))) 919 (t (:inverse-video t)))
920 "Face used in the Minibuffer when it is in Vi state." 920 "Face used in the Minibuffer when it is in Vi state."
921 :group 'viper-highlighting) 921 :group 'viper-highlighting)
922;; backward-compatibility alias
923(put 'viper-minibuffer-vi-face 'face-alias 'viper-minibuffer-vi)
924;; An internal variable. Viper takes the face from here. 922;; An internal variable. Viper takes the face from here.
925(defvar viper-minibuffer-vi-face 'viper-minibuffer-vi 923(defvar viper-minibuffer-vi-face 'viper-minibuffer-vi
926 "Face used in the Minibuffer when it is in Vi state. 924 "Face used in the Minibuffer when it is in Vi state.
927DO NOT CHANGE this variable. Instead, use the customization widget 925DO NOT CHANGE this variable. Instead, use the customization widget
928to customize the actual face object `viper-minibuffer-vi-face' 926to customize the actual face object `viper-minibuffer-vi'
929this variable represents.") 927this variable represents.")
930(viper-hide-face 'viper-minibuffer-vi) 928(viper-hide-face viper-minibuffer-vi-face)
931 929
932;; the current face to be used in the minibuffer 930;; the current face to be used in the minibuffer
933(viper-deflocalvar 931(viper-deflocalvar
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index e83cf14776f..2af0a9bbfa8 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -1,6 +1,7 @@
1;;; viper-keym.el --- Viper keymaps 1;;; viper-keym.el --- Viper keymaps
2 2
3;; Copyright (C) 1994, 95, 96, 97, 2000, 01, 02, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6 7
@@ -50,25 +51,6 @@
50 51
51;;; Variables 52;;; Variables
52 53
53(defcustom viper-toggle-key "\C-z"
54 "The key used to change states from emacs to Vi and back.
55In insert mode, this key also functions as Meta.
56Must be set in .viper file or prior to loading Viper.
57This setting cannot be changed interactively."
58 :type 'string
59 :group 'viper)
60
61(defcustom viper-quoted-insert-key "\C-v"
62 "The key used to quote special characters when inserting them in Insert state."
63 :type 'string
64 :group 'viper)
65
66(defcustom viper-ESC-key "\e"
67 "Key used to ESC.
68Must be set in .viper file or prior to loading Viper.
69This setting cannot be changed interactively."
70 :type 'string
71 :group 'viper)
72 54
73;;; Emacs keys in other states. 55;;; Emacs keys in other states.
74 56
@@ -176,6 +158,78 @@ viper-insert-basic-map. Not recommended, except for novice users.")
176;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map. 158;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map.
177(defvar viper-mode-map (make-sparse-keymap)) 159(defvar viper-mode-map (make-sparse-keymap))
178 160
161;; Some important keys used in viper
162(defcustom viper-toggle-key [(control ?z)] ; "\C-z"
163 "The key used to change states from emacs to Vi and back.
164In insert mode, this key also functions as Meta.
165
166Enter as a sexp. Examples: \"\\C-z\", [(control ?z)]."
167 :type 'sexp
168 :group 'viper
169 :set (lambda (symbol value)
170 (let ((old-value (if (boundp 'viper-toggle-key)
171 viper-toggle-key
172 [(control ?z)])))
173 (mapcar
174 (lambda (buf)
175 (save-excursion
176 (set-buffer buf)
177 (when (and (boundp 'viper-insert-basic-map)
178 (keymapp viper-insert-basic-map))
179 (when old-value
180 (define-key viper-insert-basic-map old-value nil))
181 (define-key viper-insert-basic-map value 'viper-escape-to-vi))
182 (when (and (boundp 'viper-vi-intercept-map)
183 (keymapp viper-vi-intercept-map))
184 (when old-value
185 (define-key viper-vi-intercept-map old-value nil))
186 (define-key
187 viper-vi-intercept-map value 'viper-toggle-key-action))
188 (when (and (boundp 'viper-emacs-intercept-map)
189 (keymapp viper-emacs-intercept-map))
190 (define-key viper-emacs-intercept-map old-value nil)
191 (define-key
192 viper-emacs-intercept-map value 'viper-change-state-to-vi))
193 ))
194 (buffer-list))
195 (set-default symbol value)
196 )))
197
198(defcustom viper-quoted-insert-key "\C-v"
199 "The key used to quote special characters when inserting them in Insert state."
200 :type 'string
201 :group 'viper)
202
203(defcustom viper-ESC-key [(escape)] ; "\e"
204 "Key used to ESC.
205Enter as a sexp. Examples: \"\\e\", [(escape)]."
206 :type 'sexp
207 :group 'viper
208 :set (lambda (symbol value)
209 (let ((old-value (if (boundp 'viper-ESC-key)
210 viper-ESC-key
211 [(escape)])))
212 (mapcar
213 (lambda (buf)
214 (save-excursion
215 (set-buffer buf)
216 (when (and (boundp 'viper-insert-intercept-map)
217 (keymapp viper-insert-intercept-map))
218 (when old-value
219 (define-key viper-insert-intercept-map old-value nil))
220 (define-key
221 viper-insert-intercept-map value 'viper-intercept-ESC-key))
222 (when (and (boundp 'viper-vi-intercept-map)
223 (keymapp viper-vi-intercept-map))
224 (when old-value
225 (define-key viper-vi-intercept-map old-value nil))
226 (define-key
227 viper-vi-intercept-map value 'viper-intercept-ESC-key))
228 ))
229 (buffer-list))
230 (set-default symbol value)
231 )))
232
179 233
180;;; Variables used by minor modes 234;;; Variables used by minor modes
181 235
@@ -197,6 +251,10 @@ viper-insert-basic-map. Not recommended, except for novice users.")
197;; to its Emacs state in various major modes. 251;; to its Emacs state in various major modes.
198(defvar viper-emacs-state-modifier-alist nil) 252(defvar viper-emacs-state-modifier-alist nil)
199 253
254;; The list of viper keymaps. Set by viper-normalize-minor-mode-map-alist
255(viper-deflocalvar viper--key-maps nil)
256(viper-deflocalvar viper--intercept-key-maps nil)
257
200;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new 258;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new
201;; buffers. Not a user option. 259;; buffers. Not a user option.
202(viper-deflocalvar viper-need-new-vi-local-map t "") 260(viper-deflocalvar viper-need-new-vi-local-map t "")
@@ -509,7 +567,7 @@ Usage:
509 567
510(defun viper-zap-local-keys () 568(defun viper-zap-local-keys ()
511 "Unconditionally reset Viper viper-*-local-user-map's. 569 "Unconditionally reset Viper viper-*-local-user-map's.
512Rarely useful, but if u made a mistake by switching to a mode that adds 570Rarely useful, but if you made a mistake by switching to a mode that adds
513undesirable local keys, e.g., comint-mode, then this function can restore 571undesirable local keys, e.g., comint-mode, then this function can restore
514sanity." 572sanity."
515 (interactive) 573 (interactive)
diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el
index 8a3ce5db9eb..edc5cba1bbe 100644
--- a/lisp/emulation/viper-macs.el
+++ b/lisp/emulation/viper-macs.el
@@ -1,6 +1,7 @@
1;;; viper-macs.el --- functions implementing keyboard macros for Viper 1;;; viper-macs.el --- functions implementing keyboard macros for Viper
2 2
3;; Copyright (C) 1994, 95, 96, 97, 2000, 01, 02, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6 7
@@ -178,7 +179,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
178 (if (member 179 (if (member
179 key 180 key
180 '(?\b ?\d '^? '^H (control h) (control \?) backspace delete)) 181 '(?\b ?\d '^? '^H (control h) (control \?) backspace delete))
181 (setq key-seq (subseq key-seq 0 (- (length key-seq) 2)))) 182 (setq key-seq (viper-subseq key-seq 0 (- (length key-seq) 2))))
182 (setq message 183 (setq message
183 (format 184 (format
184 ":map%s %s" 185 ":map%s %s"
@@ -242,9 +243,9 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
242 (cond ((member 243 (cond ((member
243 key 244 key
244 '(?\b ?\d '^? '^H (control h) (control \?) backspace delete)) 245 '(?\b ?\d '^? '^H (control h) (control \?) backspace delete))
245 (setq key-seq (subseq key-seq 0 (- (length key-seq) 2)))) 246 (setq key-seq (viper-subseq key-seq 0 (- (length key-seq) 2))))
246 ((member key '(tab (control i) ?\t)) 247 ((member key '(tab (control i) ?\t))
247 (setq key-seq (subseq key-seq 0 (1- (length key-seq)))) 248 (setq key-seq (viper-subseq key-seq 0 (1- (length key-seq))))
248 (setq message 249 (setq message
249 (format 250 (format
250 ":unmap%s %s" 251 ":unmap%s %s"
@@ -618,7 +619,7 @@ name from there."
618 619
619 (if (null macro-alist-elt) 620 (if (null macro-alist-elt)
620 (setq macro-alist-elt (car next-best-match) 621 (setq macro-alist-elt (car next-best-match)
621 unmatched-suffix (subseq event-seq (cdr next-best-match)))) 622 unmatched-suffix (viper-subseq event-seq (cdr next-best-match))))
622 623
623 (cond ((null macro-alist-elt)) 624 (cond ((null macro-alist-elt))
624 ((setq macro-body (viper-kbd-buf-definition macro-alist-elt))) 625 ((setq macro-body (viper-kbd-buf-definition macro-alist-elt)))
@@ -701,7 +702,7 @@ name from there."
701 (let ((len1 (length seq1)) 702 (let ((len1 (length seq1))
702 (len2 (length seq2))) 703 (len2 (length seq2)))
703 (if (<= len1 len2) 704 (if (<= len1 len2)
704 (equal seq1 (subseq seq2 0 len1))))) 705 (equal seq1 (viper-subseq seq2 0 len1)))))
705 706
706;; find the longest common prefix 707;; find the longest common prefix
707(defun viper-common-seq-prefix (&rest seqs) 708(defun viper-common-seq-prefix (&rest seqs)
@@ -766,7 +767,7 @@ name from there."
766 (setq macro-def (car lis) 767 (setq macro-def (car lis)
767 def-len (length (car macro-def))) 768 def-len (length (car macro-def)))
768 (if (and (>= str-len def-len) 769 (if (and (>= str-len def-len)
769 (equal (car macro-def) (subseq str 0 def-len))) 770 (equal (car macro-def) (viper-subseq str 0 def-len)))
770 (if (or (viper-kbd-buf-definition macro-def) 771 (if (or (viper-kbd-buf-definition macro-def)
771 (viper-kbd-mode-definition macro-def) 772 (viper-kbd-mode-definition macro-def)
772 (viper-kbd-global-definition macro-def)) 773 (viper-kbd-global-definition macro-def))
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el
index 503cd145796..084d70050a2 100644
--- a/lisp/emulation/viper-mous.el
+++ b/lisp/emulation/viper-mous.el
@@ -1,6 +1,7 @@
1;;; viper-mous.el --- mouse support for Viper 1;;; viper-mous.el --- mouse support for Viper
2 2
3;; Copyright (C) 1994, 95, 96, 97, 2001, 02 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 2001, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc.
4 5
5;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6 7
@@ -65,7 +66,7 @@
65(defvar viper-frame-of-focus nil) 66(defvar viper-frame-of-focus nil)
66 67
67;; Frame that was selected before the switch-frame event. 68;; Frame that was selected before the switch-frame event.
68(defconst viper-current-frame-saved (selected-frame)) 69(defvar viper-current-frame-saved (selected-frame))
69 70
70(defcustom viper-surrounding-word-function 'viper-surrounding-word 71(defcustom viper-surrounding-word-function 'viper-surrounding-word
71 "*Function that determines what constitutes a word for clicking events. 72 "*Function that determines what constitutes a word for clicking events.
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index 2d713df6ef6..cc9f42b9800 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -1,6 +1,7 @@
1;;; viper-util.el --- Utilities used by viper.el 1;;; viper-util.el --- Utilities used by viper.el
2 2
3;; Copyright (C) 1994, 95, 96, 97, 99, 2000, 01, 02, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
4;; 2004, 2005 Free Software Foundation, Inc.
4 5
5;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6 7
@@ -41,7 +42,6 @@
41(defvar viper-syntax-preference) 42(defvar viper-syntax-preference)
42(defvar viper-saved-mark) 43(defvar viper-saved-mark)
43 44
44(require 'cl)
45(require 'ring) 45(require 'ring)
46 46
47(if noninteractive 47(if noninteractive
@@ -360,7 +360,7 @@
360 (setq lis2 (delq elt lis2))) 360 (setq lis2 (delq elt lis2)))
361 (setq temp (cdr temp))) 361 (setq temp (cdr temp)))
362 362
363 (nconc lis1 lis2))) 363 (append lis1 lis2)))
364 364
365 365
366 366
@@ -1068,7 +1068,7 @@
1068 (t key))) 1068 (t key)))
1069 1069
1070 ((listp key) 1070 ((listp key)
1071 (setq modifiers (subseq key 0 (1- (length key))) 1071 (setq modifiers (viper-subseq key 0 (1- (length key)))
1072 base-key (viper-seq-last-elt key) 1072 base-key (viper-seq-last-elt key)
1073 base-key-name (symbol-name base-key) 1073 base-key-name (symbol-name base-key)
1074 char-p (= (length base-key-name) 1)) 1074 char-p (= (length base-key-name) 1))
@@ -1503,6 +1503,33 @@ This option is appropriate if you like Emacs-style words."
1503 )) 1503 ))
1504 1504
1505 1505
1506;; this is copied from cl-extra.el
1507;; Return the subsequence of SEQ from START to END.
1508;; If END is omitted, it defaults to the length of the sequence.
1509;; If START or END is negative, it counts from the end.
1510(defun viper-subseq (seq start &optional end)
1511 (if (stringp seq) (substring seq start end)
1512 (let (len)
1513 (and end (< end 0) (setq end (+ end (setq len (length seq)))))
1514 (if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
1515 (cond ((listp seq)
1516 (if (> start 0) (setq seq (nthcdr start seq)))
1517 (if end
1518 (let ((res nil))
1519 (while (>= (setq end (1- end)) start)
1520 (push (pop seq) res))
1521 (nreverse res))
1522 (copy-sequence seq)))
1523 (t
1524 (or end (setq end (or len (length seq))))
1525 (let ((res (make-vector (max (- end start) 0) nil))
1526 (i 0))
1527 (while (< start end)
1528 (aset res i (aref seq start))
1529 (setq i (1+ i) start (1+ start)))
1530 res))))))
1531
1532
1506 1533
1507(provide 'viper-util) 1534(provide 'viper-util)
1508 1535
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index fe65cb69cbb..bfa730cc434 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -3,12 +3,13 @@
3;; and a venomous VI PERil. 3;; and a venomous VI PERil.
4;; Viper Is also a Package for Emacs Rebels. 4;; Viper Is also a Package for Emacs Rebels.
5 5
6;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 2005 Free Software Foundation, Inc. 6;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
7;; 2003, 2004, 2005 Free Software Foundation, Inc.
7 8
8;; Author: Michael Kifer <kifer@cs.stonybrook.edu> 9;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
9;; Keywords: emulations 10;; Keywords: emulations
10 11
11(defconst viper-version "3.11.4 of February 19, 2005" 12(defconst viper-version "3.11.5 of August 6, 2005"
12 "The current version of Viper") 13 "The current version of Viper")
13 14
14;; This file is part of GNU Emacs. 15;; This file is part of GNU Emacs.
@@ -320,6 +321,7 @@
320;; end pacifier 321;; end pacifier
321 322
322(require 'viper-init) 323(require 'viper-init)
324(require 'viper-keym)
323 325
324;; better be defined before Viper custom group. 326;; better be defined before Viper custom group.
325(defvar viper-custom-file-name (convert-standard-filename "~/.viper") 327(defvar viper-custom-file-name (convert-standard-filename "~/.viper")
@@ -370,7 +372,6 @@ widget."
370(defcustom viper-vi-state-mode-list 372(defcustom viper-vi-state-mode-list
371 '(fundamental-mode 373 '(fundamental-mode
372 makefile-mode 374 makefile-mode
373 help-mode
374 375
375 awk-mode 376 awk-mode
376 m4-mode 377 m4-mode
@@ -396,7 +397,7 @@ widget."
396 tex-mode latex-mode bibtex-mode 397 tex-mode latex-mode bibtex-mode
397 ps-mode 398 ps-mode
398 399
399 completion-list-mode 400 ;; completion-list-mode
400 diff-mode 401 diff-mode
401 idl-mode 402 idl-mode
402 403
@@ -424,6 +425,7 @@ widget."
424 425
425 browse-kill-ring-mode 426 browse-kill-ring-mode
426 recentf-mode 427 recentf-mode
428 recentf-dialog-mode
427 occur-mode 429 occur-mode
428 430
429 mh-folder-mode 431 mh-folder-mode
@@ -431,6 +433,9 @@ widget."
431 gnus-group-mode 433 gnus-group-mode
432 gnus-summary-mode 434 gnus-summary-mode
433 435
436 completion-list-mode
437 help-mode
438
434 Info-mode 439 Info-mode
435 Buffer-menu-mode 440 Buffer-menu-mode
436 compilation-mode 441 compilation-mode
@@ -521,7 +526,7 @@ If Viper is enabled, turn it off. Otherwise, turn it on."
521 526
522;;;###autoload 527;;;###autoload
523(defun viper-mode () 528(defun viper-mode ()
524 "Turn on Viper emulation of Vi." 529 "Turn on Viper emulation of Vi in Emacs. See Info node `(viper)Viper'."
525 (interactive) 530 (interactive)
526 (if (not noninteractive) 531 (if (not noninteractive)
527 (progn 532 (progn
@@ -654,8 +659,7 @@ This function tries to do as good a job as possible. However, it may undo some
654user customization, unrelated to Viper. For instance, if the user advised 659user customization, unrelated to Viper. For instance, if the user advised
655`read-file-name', `describe-key', and some others, then this advice will be 660`read-file-name', `describe-key', and some others, then this advice will be
656undone. 661undone.
657It also doesn't undo some Viper settings. For instance, `minor-mode-map-alist' 662It also can't undo some Viper settings."
658remains buffer-local."
659 (interactive) 663 (interactive)
660 664
661 ;; restore non-viper vars 665 ;; restore non-viper vars
@@ -681,7 +685,9 @@ remains buffer-local."
681 'mark-even-if-inactive viper-saved-non-viper-variables))) 685 'mark-even-if-inactive viper-saved-non-viper-variables)))
682 686
683 ;; Ideally, we would like to be able to de-localize local variables 687 ;; Ideally, we would like to be able to de-localize local variables
684 (viper-delocalize-var 'minor-mode-map-alist) 688 (unless
689 (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
690 (viper-delocalize-var 'minor-mode-map-alist))
685 (viper-delocalize-var 'require-final-newline) 691 (viper-delocalize-var 'require-final-newline)
686 (if viper-xemacs-p (viper-delocalize-var 'bar-cursor)) 692 (if viper-xemacs-p (viper-delocalize-var 'bar-cursor))
687 693
@@ -691,6 +697,12 @@ remains buffer-local."
691 697
692 (setq viper-mode nil) 698 (setq viper-mode nil)
693 699
700 (when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
701 (setq emulation-mode-map-alists
702 (delq 'viper--intercept-key-maps
703 (delq 'viper--key-maps emulation-mode-map-alists))
704 ))
705
694 (viper-delocalize-var 'viper-vi-minibuffer-minor-mode) 706 (viper-delocalize-var 'viper-vi-minibuffer-minor-mode)
695 (viper-delocalize-var 'viper-insert-minibuffer-minor-mode) 707 (viper-delocalize-var 'viper-insert-minibuffer-minor-mode)
696 (viper-delocalize-var 'viper-vi-intercept-minor-mode) 708 (viper-delocalize-var 'viper-vi-intercept-minor-mode)
@@ -874,9 +886,35 @@ remains buffer-local."
874 "Switch to emacs state while reading password." 886 "Switch to emacs state while reading password."
875 (viper-change-state-to-emacs))) 887 (viper-change-state-to-emacs)))
876 888
889 (defadvice self-insert-command (around viper-self-insert-ad activate)
890 "Ignore all self-inserting keys in the vi-state."
891 (if (and (eq viper-current-state 'vi-state) (interactive-p))
892 (beep 1)
893 ad-do-it
894 ))
895
896 (defadvice set-cursor-color (after viper-set-cursor-color-ad activate)
897 "Change cursor color in VI state."
898 ;;(setq viper-vi-state-cursor-color (ad-get-arg 0))
899 (modify-frame-parameters
900 (selected-frame)
901 (list (cons 'viper-vi-state-cursor-color (ad-get-arg 0))))
902 )
903
904 (when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
905 ;; needs to be as early as possible
906 (add-to-ordered-list
907 'emulation-mode-map-alists 'viper--intercept-key-maps 100)
908 ;; needs to be after cua-mode
909 (add-to-ordered-list 'emulation-mode-map-alists 'viper--key-maps 500)
910 )
911
877 ;; Emacs shell, ange-ftp, and comint-based modes 912 ;; Emacs shell, ange-ftp, and comint-based modes
878 (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ; comint 913 (add-hook 'comint-mode-hook 'viper-comint-mode-hook) ; comint
879 914
915 (add-hook 'eshell-mode-hook
916 (lambda () (setq viper-auto-indent nil)))
917
880 (viper-set-emacs-state-searchstyle-macros nil 'dired-mode) ; dired 918 (viper-set-emacs-state-searchstyle-macros nil 'dired-mode) ; dired
881 (viper-set-emacs-state-searchstyle-macros nil 'tar-mode) ; tar 919 (viper-set-emacs-state-searchstyle-macros nil 'tar-mode) ; tar
882 (viper-set-emacs-state-searchstyle-macros nil 'mh-folder-mode) ; mhe 920 (viper-set-emacs-state-searchstyle-macros nil 'mh-folder-mode) ; mhe
@@ -967,7 +1005,10 @@ remains buffer-local."
967 ;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have 1005 ;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have
968 ;; different keymaps for different buffers. Also, the keymaps associated 1006 ;; different keymaps for different buffers. Also, the keymaps associated
969 ;; with viper-vi/insert-state-modifier-minor-mode can be different. 1007 ;; with viper-vi/insert-state-modifier-minor-mode can be different.
970 (make-variable-buffer-local 'minor-mode-map-alist) 1008 ;; ***This is needed only in case emulation-mode-map-alists is not defined
1009 (unless
1010 (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
1011 (make-variable-buffer-local 'minor-mode-map-alist))
971 1012
972 ;; Viper changes the default mode-line-buffer-identification 1013 ;; Viper changes the default mode-line-buffer-identification
973 (setq-default mode-line-buffer-identification '(" %b")) 1014 (setq-default mode-line-buffer-identification '(" %b"))
@@ -1058,6 +1099,16 @@ remains buffer-local."
1058 (define-key viper-insert-intercept-map "\C-x)" nil) 1099 (define-key viper-insert-intercept-map "\C-x)" nil)
1059 (define-key viper-emacs-intercept-map "\C-x)" nil)) 1100 (define-key viper-emacs-intercept-map "\C-x)" nil))
1060 1101
1102 (defadvice add-minor-mode (after
1103 viper-advice-add-minor-mode
1104 (toggle name &optional keymap after toggle-fun)
1105 activate)
1106 "Run viper-normalize-minor-mode-map-alist after adding a minor mode."
1107 (viper-normalize-minor-mode-map-alist)
1108 (unless
1109 (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
1110 (setq-default minor-mode-map-alist minor-mode-map-alist)))
1111
1061 ;; catch frame switching event 1112 ;; catch frame switching event
1062 (if (viper-window-display-p) 1113 (if (viper-window-display-p)
1063 (if viper-xemacs-p 1114 (if viper-xemacs-p
@@ -1230,11 +1281,10 @@ These two lines must come in the order given.
1230(define-key 1281(define-key
1231 viper-emacs-intercept-map viper-toggle-key 'viper-change-state-to-vi) 1282 viper-emacs-intercept-map viper-toggle-key 'viper-change-state-to-vi)
1232 1283
1284;;; Removed to avoid bad interaction with cua-mode.
1233;;; Escape from Emacs and Insert modes to Vi for one command 1285;;; Escape from Emacs and Insert modes to Vi for one command
1234(define-key 1286;;(define-key viper-emacs-intercept-map "\C-c\\" 'viper-escape-to-vi)
1235 viper-emacs-intercept-map "\C-c\\" 'viper-escape-to-vi) 1287;;(define-key viper-insert-intercept-map "\C-c\\" 'viper-escape-to-vi)
1236(define-key
1237 viper-insert-intercept-map "\C-c\\" 'viper-escape-to-vi)
1238 1288
1239(if viper-mode 1289(if viper-mode
1240 (setq-default viper-emacs-intercept-minor-mode t 1290 (setq-default viper-emacs-intercept-minor-mode t
@@ -1262,7 +1312,10 @@ These two lines must come in the order given.
1262(if (and viper-mode (eq viper-current-state 'emacs-state)) 1312(if (and viper-mode (eq viper-current-state 'emacs-state))
1263 (progn 1313 (progn
1264 (viper-change-state-to-emacs) 1314 (viper-change-state-to-emacs)
1265 (setq-default minor-mode-map-alist minor-mode-map-alist) 1315 (unless
1316 (and (fboundp 'add-to-ordered-list)
1317 (boundp 'emulation-mode-map-alists))
1318 (setq-default minor-mode-map-alist minor-mode-map-alist))
1266 )) 1319 ))
1267 1320
1268(if (and viper-mode (this-major-mode-requires-vi-state major-mode)) 1321(if (and viper-mode (this-major-mode-requires-vi-state major-mode))
diff --git a/lisp/emulation/ws-mode.el b/lisp/emulation/ws-mode.el
index b1773197483..41e8f5323a5 100644
--- a/lisp/emulation/ws-mode.el
+++ b/lisp/emulation/ws-mode.el
@@ -1,6 +1,6 @@
1;;; ws-mode.el --- WordStar emulation mode for GNU Emacs 1;;; ws-mode.el --- WordStar emulation mode for GNU Emacs
2 2
3;; Copyright (C) 1991 Free Software Foundation, Inc. 3;; Copyright (C) 1991, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de> 5;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de>
6;; Version: 0.7 6;; Version: 0.7