diff options
| author | Stefan Monnier | 2013-12-08 03:11:50 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2013-12-08 03:11:50 -0500 |
| commit | 27262e39e6a1da5db8cf0735615193efc49b9ad7 (patch) | |
| tree | 8e375be0a22aeb7bd0f22ea897064a9aadb5e778 | |
| parent | e9551b12f8c17876a32e1cd075c83af3e7950980 (diff) | |
| download | emacs-27262e39e6a1da5db8cf0735615193efc49b9ad7.tar.gz emacs-27262e39e6a1da5db8cf0735615193efc49b9ad7.zip | |
Make CUA-mode use shift-select-mode.
* lisp/emulation/cua-base.el (cua--explicit-region-start)
(cua--last-region-shifted): Remove.
(cua--deactivate): Use deactivate-mark.
(cua--pre-command-handler-1): Don't handle shift-selection.
(cua--post-command-handler-1): Don't change transient-mark-mode.
(cua--select-keymaps): Use region-active-p rather than
cua--explicit-region-start or cua--last-region-shifted.
(cua-mode): Enable shift-select-mode.
* lisp/emulation/cua-rect.el (cua--rectangle-highlight-for-redisplay):
New function.
(redisplay-highlight-region-function): Use it.
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/emulation/cua-base.el | 60 | ||||
| -rw-r--r-- | lisp/emulation/cua-rect.el | 14 |
3 files changed, 36 insertions, 57 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3556fd4b05e..06d84a4d5a5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,7 +1,22 @@ | |||
| 1 | 2013-12-08 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emulation/cua-rect.el (cua--rectangle-highlight-for-redisplay): | ||
| 4 | New function. | ||
| 5 | (redisplay-highlight-region-function): Use it. | ||
| 6 | |||
| 7 | * emulation/cua-base.el (cua--explicit-region-start) | ||
| 8 | (cua--last-region-shifted): Remove. | ||
| 9 | (cua--deactivate): Use deactivate-mark. | ||
| 10 | (cua--pre-command-handler-1): Don't handle shift-selection. | ||
| 11 | (cua--post-command-handler-1): Don't change transient-mark-mode. | ||
| 12 | (cua--select-keymaps): Use region-active-p rather than | ||
| 13 | cua--explicit-region-start or cua--last-region-shifted. | ||
| 14 | (cua-mode): Enable shift-select-mode. | ||
| 15 | |||
| 1 | 2013-12-08 Leo Liu <sdl.web@gmail.com> | 16 | 2013-12-08 Leo Liu <sdl.web@gmail.com> |
| 2 | 17 | ||
| 3 | * progmodes/flymake.el (flymake-popup-current-error-menu): Rename | 18 | * progmodes/flymake.el (flymake-popup-current-error-menu): |
| 4 | from flymake-display-err-menu-for-current-line. Reimplement. | 19 | Rename from flymake-display-err-menu-for-current-line. Reimplement. |
| 5 | (flymake-posn-at-point-as-event, flymake-popup-menu) | 20 | (flymake-posn-at-point-as-event, flymake-popup-menu) |
| 6 | (flymake-make-emacs-menu): Remove. (Bug#16077) | 21 | (flymake-make-emacs-menu): Remove. (Bug#16077) |
| 7 | 22 | ||
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 66afcc29525..6c891c10eed 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el | |||
| @@ -625,13 +625,6 @@ a cons (TYPE . COLOR), then both properties are affected." | |||
| 625 | 625 | ||
| 626 | ;;; Aux. variables | 626 | ;;; Aux. variables |
| 627 | 627 | ||
| 628 | ;; Current region was started using cua-set-mark. | ||
| 629 | (defvar cua--explicit-region-start nil) | ||
| 630 | (make-variable-buffer-local 'cua--explicit-region-start) | ||
| 631 | |||
| 632 | ;; Latest region was started using shifted movement command. | ||
| 633 | (defvar cua--last-region-shifted nil) | ||
| 634 | |||
| 635 | ;; buffer + point prior to current command when rectangle is active | 628 | ;; buffer + point prior to current command when rectangle is active |
| 636 | ;; checked in post-command hook to see if point was moved | 629 | ;; checked in post-command hook to see if point was moved |
| 637 | (defvar cua--buffer-and-point-before-command nil) | 630 | (defvar cua--buffer-and-point-before-command nil) |
| @@ -762,11 +755,9 @@ Repeating prefix key when region is active works as a single prefix key." | |||
| 762 | deactivate-mark nil)) | 755 | deactivate-mark nil)) |
| 763 | 756 | ||
| 764 | (defun cua--deactivate (&optional now) | 757 | (defun cua--deactivate (&optional now) |
| 765 | (setq cua--explicit-region-start nil) | ||
| 766 | (if (not now) | 758 | (if (not now) |
| 767 | (setq deactivate-mark t) | 759 | (setq deactivate-mark t) |
| 768 | (setq mark-active nil) | 760 | (deactivate-mark))) |
| 769 | (run-hooks 'deactivate-mark-hook))) | ||
| 770 | 761 | ||
| 771 | (defun cua--filter-buffer-noprops (start end) | 762 | (defun cua--filter-buffer-noprops (start end) |
| 772 | (let ((str (filter-buffer-substring start end))) | 763 | (let ((str (filter-buffer-substring start end))) |
| @@ -862,7 +853,6 @@ With numeric prefix arg, copy to register 0-9 instead." | |||
| 862 | "Cancel the active region, rectangle, or global mark." | 853 | "Cancel the active region, rectangle, or global mark." |
| 863 | (interactive) | 854 | (interactive) |
| 864 | (setq mark-active nil) | 855 | (setq mark-active nil) |
| 865 | (setq cua--explicit-region-start nil) | ||
| 866 | (if (fboundp 'cua--cancel-rectangle) | 856 | (if (fboundp 'cua--cancel-rectangle) |
| 867 | (cua--cancel-rectangle))) | 857 | (cua--cancel-rectangle))) |
| 868 | 858 | ||
| @@ -1109,8 +1099,6 @@ With a double \\[universal-argument] prefix argument, unconditionally set mark." | |||
| 1109 | (message "Mark cleared")) | 1099 | (message "Mark cleared")) |
| 1110 | (t | 1100 | (t |
| 1111 | (push-mark-command nil nil) | 1101 | (push-mark-command nil nil) |
| 1112 | (setq cua--explicit-region-start t) | ||
| 1113 | (setq cua--last-region-shifted nil) | ||
| 1114 | (if cua-enable-region-auto-help | 1102 | (if cua-enable-region-auto-help |
| 1115 | (cua-help-for-region t))))) | 1103 | (cua-help-for-region t))))) |
| 1116 | 1104 | ||
| @@ -1203,28 +1191,10 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1203 | ((not (eq (get this-command 'CUA) 'move)) | 1191 | ((not (eq (get this-command 'CUA) 'move)) |
| 1204 | nil) | 1192 | nil) |
| 1205 | 1193 | ||
| 1206 | ;; Handle shifted cursor keys and other movement commands. | ||
| 1207 | ;; If region is not active, region is activated if key is shifted. | ||
| 1208 | ;; If region is active, region is canceled if key is unshifted | ||
| 1209 | ;; (and region not started with C-SPC). | ||
| 1210 | ;; If rectangle is active, expand rectangle in specified direction and | ||
| 1211 | ;; ignore the movement. | ||
| 1212 | (this-command-keys-shift-translated | ||
| 1213 | (unless mark-active | ||
| 1214 | (push-mark-command nil t)) | ||
| 1215 | (setq cua--last-region-shifted t) | ||
| 1216 | (setq cua--explicit-region-start nil)) | ||
| 1217 | |||
| 1218 | ;; Set mark if user explicitly said to do so | 1194 | ;; Set mark if user explicitly said to do so |
| 1219 | ((or cua--explicit-region-start cua--rectangle) | 1195 | (cua--rectangle ;FIXME: ?? |
| 1220 | (unless mark-active | 1196 | (unless mark-active |
| 1221 | (push-mark-command nil nil))) | 1197 | (push-mark-command nil nil)))) |
| 1222 | |||
| 1223 | ;; Else clear mark after this command. | ||
| 1224 | (t | ||
| 1225 | ;; If we set mark-active to nil here, the region highlight will not be | ||
| 1226 | ;; removed by the direct_output_ commands. | ||
| 1227 | (setq deactivate-mark t))) | ||
| 1228 | 1198 | ||
| 1229 | ;; Detect extension of rectangles by mouse or other movement | 1199 | ;; Detect extension of rectangles by mouse or other movement |
| 1230 | (setq cua--buffer-and-point-before-command | 1200 | (setq cua--buffer-and-point-before-command |
| @@ -1244,22 +1214,13 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1244 | (when (fboundp 'cua--rectangle-post-command) | 1214 | (when (fboundp 'cua--rectangle-post-command) |
| 1245 | (cua--rectangle-post-command)) | 1215 | (cua--rectangle-post-command)) |
| 1246 | (setq cua--buffer-and-point-before-command nil) | 1216 | (setq cua--buffer-and-point-before-command nil) |
| 1247 | (if (or (not mark-active) deactivate-mark) | ||
| 1248 | (setq cua--explicit-region-start nil)) | ||
| 1249 | 1217 | ||
| 1250 | ;; Debugging | 1218 | ;; Debugging |
| 1251 | (if cua--debug | 1219 | (if cua--debug |
| 1252 | (cond | 1220 | (cond |
| 1253 | (cua--rectangle (cua--rectangle-assert)) | 1221 | (cua--rectangle (cua--rectangle-assert)) |
| 1254 | (mark-active (message "Mark=%d Point=%d Expl=%s" | 1222 | (mark-active (message "Mark=%d Point=%d" (mark t) (point))))) |
| 1255 | (mark t) (point) cua--explicit-region-start)))) | 1223 | |
| 1256 | |||
| 1257 | ;; Disable transient-mark-mode if rectangle active in current buffer. | ||
| 1258 | (if (not (window-minibuffer-p)) | ||
| 1259 | (setq transient-mark-mode (and (not cua--rectangle) | ||
| 1260 | (if cua-highlight-region-shift-only | ||
| 1261 | (not cua--explicit-region-start) | ||
| 1262 | t)))) | ||
| 1263 | (if cua-enable-cursor-indications | 1224 | (if cua-enable-cursor-indications |
| 1264 | (cua--update-indications)) | 1225 | (cua--update-indications)) |
| 1265 | 1226 | ||
| @@ -1323,7 +1284,7 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1323 | cua-enable-cua-keys | 1284 | cua-enable-cua-keys |
| 1324 | (not cua-inhibit-cua-keys) | 1285 | (not cua-inhibit-cua-keys) |
| 1325 | (or (eq cua-enable-cua-keys t) | 1286 | (or (eq cua-enable-cua-keys t) |
| 1326 | (not cua--explicit-region-start)) | 1287 | (region-active-p)) |
| 1327 | (not executing-kbd-macro) | 1288 | (not executing-kbd-macro) |
| 1328 | (not cua--prefix-override-timer))) | 1289 | (not cua--prefix-override-timer))) |
| 1329 | (setq cua--ena-prefix-repeat-keymap | 1290 | (setq cua--ena-prefix-repeat-keymap |
| @@ -1334,7 +1295,7 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1334 | (and cua-enable-cua-keys | 1295 | (and cua-enable-cua-keys |
| 1335 | (not cua-inhibit-cua-keys) | 1296 | (not cua-inhibit-cua-keys) |
| 1336 | (or (eq cua-enable-cua-keys t) | 1297 | (or (eq cua-enable-cua-keys t) |
| 1337 | cua--last-region-shifted))) | 1298 | (region-active-p)))) |
| 1338 | (setq cua--ena-global-mark-keymap | 1299 | (setq cua--ena-global-mark-keymap |
| 1339 | (and cua--global-mark-active | 1300 | (and cua--global-mark-active |
| 1340 | (not (window-minibuffer-p))))) | 1301 | (not (window-minibuffer-p))))) |
| @@ -1546,11 +1507,8 @@ shifted movement key, set `cua-highlight-region-shift-only'." | |||
| 1546 | (if (and (boundp 'pc-selection-mode) pc-selection-mode) | 1507 | (if (and (boundp 'pc-selection-mode) pc-selection-mode) |
| 1547 | (pc-selection-mode -1)) | 1508 | (pc-selection-mode -1)) |
| 1548 | (cua--deactivate) | 1509 | (cua--deactivate) |
| 1549 | (setq shift-select-mode nil) | 1510 | (setq shift-select-mode t) |
| 1550 | (setq transient-mark-mode (and cua-mode | 1511 | (transient-mark-mode (if cua-highlight-region-shift-only -1 1))) |
| 1551 | (if cua-highlight-region-shift-only | ||
| 1552 | (not cua--explicit-region-start) | ||
| 1553 | t)))) | ||
| 1554 | (cua--saved-state | 1512 | (cua--saved-state |
| 1555 | (setq transient-mark-mode (car cua--saved-state)) | 1513 | (setq transient-mark-mode (car cua--saved-state)) |
| 1556 | (if (nth 1 cua--saved-state) | 1514 | (if (nth 1 cua--saved-state) |
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el index fba80033281..8941bf27de7 100644 --- a/lisp/emulation/cua-rect.el +++ b/lisp/emulation/cua-rect.el | |||
| @@ -877,8 +877,7 @@ With prefix argument, activate previous rectangle if possible." | |||
| 877 | (push-mark nil nil t))) | 877 | (push-mark nil nil t))) |
| 878 | (cua--activate-rectangle) | 878 | (cua--activate-rectangle) |
| 879 | (cua--rectangle-set-corners) | 879 | (cua--rectangle-set-corners) |
| 880 | (setq mark-active t | 880 | (setq mark-active t) |
| 881 | cua--explicit-region-start t) | ||
| 882 | (if cua-enable-rectangle-auto-help | 881 | (if cua-enable-rectangle-auto-help |
| 883 | (cua-help-for-rectangle t)))) | 882 | (cua-help-for-rectangle t)))) |
| 884 | 883 | ||
| @@ -886,8 +885,7 @@ With prefix argument, activate previous rectangle if possible." | |||
| 886 | "Cancel current rectangle." | 885 | "Cancel current rectangle." |
| 887 | (interactive) | 886 | (interactive) |
| 888 | (when cua--rectangle | 887 | (when cua--rectangle |
| 889 | (setq mark-active nil | 888 | (setq mark-active nil) |
| 890 | cua--explicit-region-start nil) | ||
| 891 | (cua--deactivate-rectangle))) | 889 | (cua--deactivate-rectangle))) |
| 892 | 890 | ||
| 893 | (defun cua-toggle-rectangle-mark () | 891 | (defun cua-toggle-rectangle-mark () |
| @@ -1378,6 +1376,14 @@ With prefix arg, indent to that column." | |||
| 1378 | 1376 | ||
| 1379 | (add-function :around region-extract-function | 1377 | (add-function :around region-extract-function |
| 1380 | #'cua--rectangle-region-extract) | 1378 | #'cua--rectangle-region-extract) |
| 1379 | (add-function :around redisplay-highlight-region-function | ||
| 1380 | #'cua--rectangle-highlight-for-redisplay) | ||
| 1381 | |||
| 1382 | (defun cua--rectangle-highlight-for-redisplay (orig &rest args) | ||
| 1383 | (if (not cua--rectangle) (apply orig args) | ||
| 1384 | ;; When cua--rectangle is active, just don't highlight at all, since we | ||
| 1385 | ;; already do it elsewhere. | ||
| 1386 | )) | ||
| 1381 | 1387 | ||
| 1382 | (defun cua--rectangle-region-extract (orig &optional delete) | 1388 | (defun cua--rectangle-region-extract (orig &optional delete) |
| 1383 | (cond | 1389 | (cond |