aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emulation
diff options
context:
space:
mode:
authorMiles Bader2005-07-22 08:27:27 +0000
committerMiles Bader2005-07-22 08:27:27 +0000
commit3674ae2f87e47a654524af689ea610ee3edeaca7 (patch)
tree58ea33c40c8521a79fb503080b8bb6231ffbf579 /lisp/emulation
parent3e03f554f116e04ba860dcde7c6d862939911e16 (diff)
parent7929f858f8897f0448771a471f8afc5f244e4bca (diff)
downloademacs-3674ae2f87e47a654524af689ea610ee3edeaca7.tar.gz
emacs-3674ae2f87e47a654524af689ea610ee3edeaca7.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-71
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 485-492) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 92-94) - Merge from emacs--cvs-trunk--0 - Update from CVS
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/cua-base.el251
-rw-r--r--lisp/emulation/viper-cmd.el10
-rw-r--r--lisp/emulation/viper-init.el4
3 files changed, 149 insertions, 116 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index 008a3c3ba49..49979ce3b78 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -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
@@ -1060,118 +1060,122 @@ If ARG is the atom `-', scroll upward by nearly full screen."
1060 1060
1061;;; Pre-command hook 1061;;; Pre-command hook
1062 1062
1063(defun cua--pre-command-handler-1 ()
1064 (let ((movement (eq (get this-command 'CUA) 'move)))
1065
1066 ;; Cancel prefix key timeout if user enters another key.
1067 (when cua--prefix-override-timer
1068 (if (timerp cua--prefix-override-timer)
1069 (cancel-timer cua--prefix-override-timer))
1070 (setq cua--prefix-override-timer nil))
1071
1072 ;; Handle shifted cursor keys and other movement commands.
1073 ;; If region is not active, region is activated if key is shifted.
1074 ;; If region is active, region is cancelled if key is unshifted (and region not started with C-SPC).
1075 ;; If rectangle is active, expand rectangle in specified direction and ignore the movement.
1076 (if movement
1077 (cond
1078 ((if window-system
1079 (memq 'shift (event-modifiers
1080 (aref (this-single-command-raw-keys) 0)))
1081 (or
1082 (memq 'shift (event-modifiers
1083 (aref (this-single-command-keys) 0)))
1084 ;; See if raw escape sequence maps to a shifted event, e.g. S-up or C-S-home.
1085 (and (boundp 'function-key-map)
1086 function-key-map
1087 (let ((ev (lookup-key function-key-map
1088 (this-single-command-raw-keys))))
1089 (and (vector ev)
1090 (symbolp (setq ev (aref ev 0)))
1091 (string-match "S-" (symbol-name ev)))))))
1092 (unless mark-active
1093 (push-mark-command nil t))
1094 (setq cua--last-region-shifted t)
1095 (setq cua--explicit-region-start nil))
1096 ((or cua--explicit-region-start cua--rectangle)
1097 (unless mark-active
1098 (push-mark-command nil nil)))
1099 (t
1100 ;; If we set mark-active to nil here, the region highlight will not be
1101 ;; removed by the direct_output_ commands.
1102 (setq deactivate-mark t)))
1103
1104 ;; Handle delete-selection property on other commands
1105 (if (and mark-active (not deactivate-mark))
1106 (let* ((ds (or (get this-command 'delete-selection)
1107 (get this-command 'pending-delete)))
1108 (nc (cond
1109 ((not ds) nil)
1110 ((eq ds 'yank)
1111 'cua-paste)
1112 ((eq ds 'kill)
1113 (if cua--rectangle
1114 'cua-copy-rectangle
1115 'cua-copy-region))
1116 ((eq ds 'supersede)
1117 (if cua--rectangle
1118 'cua-delete-rectangle
1119 'cua-delete-region))
1120 (t
1121 (if cua--rectangle
1122 'cua-delete-rectangle ;; replace?
1123 'cua-replace-region)))))
1124 (if nc
1125 (setq this-original-command this-command
1126 this-command nc)))))
1127
1128 ;; Detect extension of rectangles by mouse or other movement
1129 (setq cua--buffer-and-point-before-command
1130 (if cua--rectangle (cons (current-buffer) (point))))))
1131
1063(defun cua--pre-command-handler () 1132(defun cua--pre-command-handler ()
1064 (condition-case nil 1133 (when cua-mode
1065 (let ((movement (eq (get this-command 'CUA) 'move))) 1134 (condition-case nil
1066 1135 (cua--pre-command-handler-1)
1067 ;; Cancel prefix key timeout if user enters another key. 1136 (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 'function-key-map)
1087 function-key-map
1088 (let ((ev (lookup-key function-key-map
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 1137
1135;;; Post-command hook 1138;;; Post-command hook
1136 1139
1137(defun cua--post-command-handler () 1140(defun cua--post-command-handler-1 ()
1138 (condition-case nil 1141 (when cua--global-mark-active
1139 (progn 1142 (cua--global-mark-post-command))
1140 (when cua--global-mark-active 1143 (when (fboundp 'cua--rectangle-post-command)
1141 (cua--global-mark-post-command)) 1144 (cua--rectangle-post-command))
1142 (when (fboundp 'cua--rectangle-post-command) 1145 (setq cua--buffer-and-point-before-command nil)
1143 (cua--rectangle-post-command)) 1146 (if (or (not mark-active) deactivate-mark)
1144 (setq cua--buffer-and-point-before-command nil) 1147 (setq cua--explicit-region-start nil))
1145 (if (or (not mark-active) deactivate-mark) 1148
1146 (setq cua--explicit-region-start nil)) 1149 ;; Debugging
1147 1150 (if cua--debug
1148 ;; Debugging 1151 (cond
1149 (if cua--debug 1152 (cua--rectangle (cua--rectangle-assert))
1150 (cond 1153 (mark-active (message "Mark=%d Point=%d Expl=%s"
1151 (cua--rectangle (cua--rectangle-assert)) 1154 (mark t) (point) cua--explicit-region-start))))
1152 (mark-active (message "Mark=%d Point=%d Expl=%s"
1153 (mark t) (point) cua--explicit-region-start))))
1154
1155 ;; Disable transient-mark-mode if rectangle active in current buffer.
1156 (if (not (window-minibuffer-p (selected-window)))
1157 (setq transient-mark-mode (and (not cua--rectangle)
1158 (if cua-highlight-region-shift-only
1159 (not cua--explicit-region-start)
1160 t))))
1161 (if cua-enable-cursor-indications
1162 (cua--update-indications))
1163 1155
1164 (cua--select-keymaps) 1156 ;; Disable transient-mark-mode if rectangle active in current buffer.
1165 ) 1157 (if (not (window-minibuffer-p (selected-window)))
1158 (setq transient-mark-mode (and (not cua--rectangle)
1159 (if cua-highlight-region-shift-only
1160 (not cua--explicit-region-start)
1161 t))))
1162 (if cua-enable-cursor-indications
1163 (cua--update-indications))
1166 1164
1167 (error nil))) 1165 (cua--select-keymaps))
1166
1167(defun cua--post-command-handler ()
1168 (when cua-mode
1169 (condition-case nil
1170 (cua--post-command-handler-1)
1171 (error nil))))
1168 1172
1169 1173
1170;;; Keymaps 1174;;; Keymaps
1171 1175
1172(defun cua--M/H-key (map key fct) 1176(defun cua--M/H-key (map key fct)
1173 ;; bind H-KEY or M-KEY to FCT in MAP 1177 ;; bind H-KEY or M-KEY to FCT in MAP
1174 (if (eq key 'space) (setq key ? )) 1178 (if (eq key 'space) (setq key ?\s))
1175 (unless (listp key) (setq key (list key))) 1179 (unless (listp key) (setq key (list key)))
1176 (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct)) 1180 (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct))
1177 1181
@@ -1240,7 +1244,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) 1244 (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)) 1245 (define-key cua-global-keymap [(hyper mouse-1)] 'cua-mouse-set-rectangle-mark))
1242 1246
1243 (define-key cua-global-keymap [(shift control ? )] 'cua-toggle-global-mark) 1247 (define-key cua-global-keymap [(shift control ?\s)] 'cua-toggle-global-mark)
1244 1248
1245 ;; replace region with rectangle or element on kill ring 1249 ;; replace region with rectangle or element on kill ring
1246 (define-key cua-global-keymap [remap yank] 'cua-paste) 1250 (define-key cua-global-keymap [remap yank] 'cua-paste)
@@ -1328,10 +1332,26 @@ If ARG is the atom `-', scroll upward by nearly full screen."
1328;;;###autoload 1332;;;###autoload
1329(define-minor-mode cua-mode 1333(define-minor-mode cua-mode
1330 "Toggle CUA key-binding mode. 1334 "Toggle CUA key-binding mode.
1331When enabled, using shifted movement keys will activate the region (and 1335When enabled, using shifted movement keys will activate the
1332highlight the region using `transient-mark-mode'), and typed text replaces 1336region (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 1337and typed text replaces the active selection.
1334paste (in addition to the normal Emacs bindings)." 1338
1339Also when enabled, you can use C-z, C-x, C-c, and C-v to undo,
1340cut, copy, and paste in addition to the normal Emacs bindings.
1341The C-x and C-c keys only do cut and copy when the region is
1342active, so in most cases, they do not conflict with the normal
1343function of these prefix keys.
1344
1345If you really need to perform a command which starts with one of
1346the prefix keys even when the region is active, you have three
1347options:
1348- press the prefix key twice very quickly (within 0.2 seconds),
1349- press the prefix key and the following key within 0.2 seconds, or
1350- use the SHIFT key with the prefix key, i.e. C-S-x or C-S-c.
1351
1352You can customize `cua-enable-cua-keys' to completely disable the
1353CUA bindings, or `cua-prefix-override-inhibit-delay' to change
1354the prefix fallback behavior."
1335 :global t 1355 :global t
1336 :group 'cua 1356 :group 'cua
1337 :set-after '(cua-enable-modeline-indications cua-use-hyper-key) 1357 :set-after '(cua-enable-modeline-indications cua-use-hyper-key)
@@ -1393,6 +1413,15 @@ paste (in addition to the normal Emacs bindings)."
1393 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" ""))) 1413 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" "")))
1394 (setq cua--saved-state nil)))) 1414 (setq cua--saved-state nil))))
1395 1415
1416
1417;;;###autoload
1418(defun cua-selection-mode (arg)
1419 "Enable CUA selection mode without the C-z/C-x/C-c/C-v bindings."
1420 (interactive "P")
1421 (setq-default cua-enable-cua-keys nil)
1422 (cua-mode arg))
1423
1424
1396(defun cua-debug () 1425(defun cua-debug ()
1397 "Toggle CUA debugging." 1426 "Toggle CUA debugging."
1398 (interactive) 1427 (interactive)
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index ecd5251891c..47b677b2e19 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -774,7 +774,8 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
774 ) 774 )
775 775
776 (if (commandp com) 776 (if (commandp com)
777 (progn 777 ;; pretend that current state is the state we excaped to
778 (let ((viper-current-state state))
778 (setq prefix-arg (or prefix-arg arg)) 779 (setq prefix-arg (or prefix-arg arg))
779 (command-execute com))) 780 (command-execute com)))
780 ) 781 )
@@ -996,9 +997,12 @@ as a Meta key and any number of multiple escapes is allowed."
996 (inhibit-quit t)) 997 (inhibit-quit t))
997 (if (viper-ESC-event-p event) 998 (if (viper-ESC-event-p event)
998 (progn 999 (progn
999 (if (viper-fast-keysequence-p) 1000 ;; Emacs 22.50.8 introduced a bug, which makes even a single ESC into
1001 ;; a fast keyseq. To guard against this, we added a check if there
1002 ;; are other events as well
1003 (if (and (viper-fast-keysequence-p) unread-command-events)
1000 (progn 1004 (progn
1001 (let (minor-mode-map-alist) 1005 (let (minor-mode-map-alist emulation-mode-map-alists)
1002 (viper-set-unread-command-events event) 1006 (viper-set-unread-command-events event)
1003 (setq keyseq (read-key-sequence nil 'continue-echo)) 1007 (setq keyseq (read-key-sequence nil 'continue-echo))
1004 ) ; let 1008 ) ; let
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index 8d9aed94770..f898c15c158 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -362,8 +362,8 @@ Use `M-x viper-set-expert-level' to change this.")
362(defun viper-activate-input-method () 362(defun viper-activate-input-method ()
363 (cond ((and viper-emacs-p (fboundp 'activate-input-method)) 363 (cond ((and viper-emacs-p (fboundp 'activate-input-method))
364 (activate-input-method default-input-method)) 364 (activate-input-method default-input-method))
365 ((and viper-xemacs-p (fboundp 'quail-mode)) 365 ((featurep 'xemacs)
366 (quail-mode 1)))) 366 (if (fboundp 'quail-mode) (quail-mode 1)))))
367 367
368;; Set quail-mode to ARG 368;; Set quail-mode to ARG
369(defun viper-set-input-method (arg) 369(defun viper-set-input-method (arg)