diff options
| author | Glenn Morris | 2014-11-01 11:05:30 -0700 |
|---|---|---|
| committer | Glenn Morris | 2014-11-01 11:05:30 -0700 |
| commit | d5d8ca30e5f481a32414c42bcc3b5a042061ff07 (patch) | |
| tree | febc223f19801e8e01b9498c5ba9d6c7bfcfa091 /lisp/emulation | |
| parent | e54c5e4e25098be9df9d9c46d32165887b0ff9d3 (diff) | |
| parent | b99e8f833671a2b52be654eb477830294c624a97 (diff) | |
| download | emacs-d5d8ca30e5f481a32414c42bcc3b5a042061ff07.tar.gz emacs-d5d8ca30e5f481a32414c42bcc3b5a042061ff07.zip | |
Merge from emacs-24; up to 117656
Diffstat (limited to 'lisp/emulation')
| -rw-r--r-- | lisp/emulation/cua-base.el | 72 |
1 files changed, 12 insertions, 60 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index ee70071b7ec..0b6891d6d6d 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el | |||
| @@ -277,7 +277,7 @@ enabled." | |||
| 277 | 277 | ||
| 278 | (defcustom cua-remap-control-v t | 278 | (defcustom cua-remap-control-v t |
| 279 | "If non-nil, C-v binding is used for paste (yank). | 279 | "If non-nil, C-v binding is used for paste (yank). |
| 280 | Also, M-v is mapped to `cua-repeat-replace-region'." | 280 | Also, M-v is mapped to `delete-selection-repeat-replace-region'." |
| 281 | :type 'boolean | 281 | :type 'boolean |
| 282 | :group 'cua) | 282 | :group 'cua) |
| 283 | 283 | ||
| @@ -350,6 +350,8 @@ interpreted as a register number." | |||
| 350 | :group 'cua) | 350 | :group 'cua) |
| 351 | 351 | ||
| 352 | (defcustom cua-delete-copy-to-register-0 t | 352 | (defcustom cua-delete-copy-to-register-0 t |
| 353 | ;; FIXME: Obey delete-selection-save-to-register rather than hardcoding | ||
| 354 | ;; register 0. | ||
| 353 | "If non-nil, save last deleted region or rectangle to register 0." | 355 | "If non-nil, save last deleted region or rectangle to register 0." |
| 354 | :type 'boolean | 356 | :type 'boolean |
| 355 | :group 'cua) | 357 | :group 'cua) |
| @@ -788,26 +790,12 @@ Repeating prefix key when region is active works as a single prefix key." | |||
| 788 | 790 | ||
| 789 | ;;; Region specific commands | 791 | ;;; Region specific commands |
| 790 | 792 | ||
| 791 | (defvar cua--last-deleted-region-pos nil) | ||
| 792 | (defvar cua--last-deleted-region-text nil) | ||
| 793 | |||
| 794 | (defun cua-delete-region () | 793 | (defun cua-delete-region () |
| 795 | "Delete the active region. | 794 | "Delete the active region. |
| 796 | Save a copy in register 0 if `cua-delete-copy-to-register-0' is non-nil." | 795 | Save a copy in register 0 if `cua-delete-copy-to-register-0' is non-nil." |
| 797 | (interactive) | 796 | (interactive) |
| 798 | (let ((start (mark)) (end (point))) | 797 | (require 'delsel) |
| 799 | (or (<= start end) | 798 | (delete-active-region)) |
| 800 | (setq start (prog1 end (setq end start)))) | ||
| 801 | (setq cua--last-deleted-region-text | ||
| 802 | (funcall region-extract-function t)) | ||
| 803 | (if cua-delete-copy-to-register-0 | ||
| 804 | (set-register ?0 cua--last-deleted-region-text)) | ||
| 805 | (setq cua--last-deleted-region-pos | ||
| 806 | (cons (current-buffer) | ||
| 807 | (and (consp buffer-undo-list) | ||
| 808 | (car buffer-undo-list)))) | ||
| 809 | (cua--deactivate) | ||
| 810 | (/= start end))) | ||
| 811 | 799 | ||
| 812 | (defun cua-copy-region (arg) | 800 | (defun cua-copy-region (arg) |
| 813 | "Copy the region to the kill ring. | 801 | "Copy the region to the kill ring. |
| @@ -958,48 +946,8 @@ See also `exchange-point-and-mark'." | |||
| 958 | (t | 946 | (t |
| 959 | (let (mark-active) | 947 | (let (mark-active) |
| 960 | (exchange-point-and-mark) | 948 | (exchange-point-and-mark) |
| 961 | (if cua--rectangle | 949 | (if cua--rectangle |
| 962 | (cua--rectangle-corner 0)))))) | 950 | (cua--rectangle-corner 0)))))) |
| 963 | |||
| 964 | ;; Typed text that replaced the highlighted region. | ||
| 965 | (defvar cua--repeat-replace-text nil) | ||
| 966 | |||
| 967 | (defun cua-repeat-replace-region (arg) | ||
| 968 | "Repeat replacing text of highlighted region with typed text. | ||
| 969 | Searches for the next stretch of text identical to the region last | ||
| 970 | replaced by typing text over it and replaces it with the same stretch | ||
| 971 | of text." | ||
| 972 | (interactive "P") | ||
| 973 | (when cua--last-deleted-region-pos | ||
| 974 | (with-current-buffer (car cua--last-deleted-region-pos) | ||
| 975 | (save-restriction | ||
| 976 | (widen) | ||
| 977 | ;; Find the text that replaced the region via the undo list. | ||
| 978 | (let ((ul buffer-undo-list) | ||
| 979 | (elt (cdr cua--last-deleted-region-pos)) | ||
| 980 | u s e) | ||
| 981 | (when elt | ||
| 982 | (while (consp ul) | ||
| 983 | (setq u (car ul) ul (cdr ul)) | ||
| 984 | (cond | ||
| 985 | ((eq u elt) ;; got it | ||
| 986 | (setq ul nil)) | ||
| 987 | ((and (consp u) (integerp (car u)) (integerp (cdr u))) | ||
| 988 | (if (and s (= (cdr u) s)) | ||
| 989 | (setq s (car u)) | ||
| 990 | (setq s (car u) e (cdr u))))))) | ||
| 991 | (cond ((and s e (<= s e) (= s (mark t))) | ||
| 992 | (setq cua--repeat-replace-text (cua--filter-buffer-noprops s e))) | ||
| 993 | ((and (null s) (eq u elt)) ;; nothing inserted | ||
| 994 | (setq cua--repeat-replace-text | ||
| 995 | "")) | ||
| 996 | (t | ||
| 997 | (message "Cannot locate replacement text")))))) | ||
| 998 | (setq cua--last-deleted-region-pos nil)) | ||
| 999 | (if (and cua--last-deleted-region-text | ||
| 1000 | cua--repeat-replace-text | ||
| 1001 | (search-forward cua--last-deleted-region-text nil t nil)) | ||
| 1002 | (replace-match cua--repeat-replace-text arg t))) | ||
| 1003 | 951 | ||
| 1004 | (defun cua-help-for-region (&optional help) | 952 | (defun cua-help-for-region (&optional help) |
| 1005 | "Show region specific help in echo area." | 953 | "Show region specific help in echo area." |
| @@ -1320,7 +1268,8 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1320 | (define-key cua--cua-keys-keymap [(control z)] 'undo)) | 1268 | (define-key cua--cua-keys-keymap [(control z)] 'undo)) |
| 1321 | (when cua-remap-control-v | 1269 | (when cua-remap-control-v |
| 1322 | (define-key cua--cua-keys-keymap [(control v)] 'yank) | 1270 | (define-key cua--cua-keys-keymap [(control v)] 'yank) |
| 1323 | (define-key cua--cua-keys-keymap [(meta v)] 'cua-repeat-replace-region)) | 1271 | (define-key cua--cua-keys-keymap [(meta v)] |
| 1272 | 'delete-selection-repeat-replace-region)) | ||
| 1324 | 1273 | ||
| 1325 | (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler) | 1274 | (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler) |
| 1326 | (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler) | 1275 | (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler) |
| @@ -1359,6 +1308,7 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1359 | ;; delete-selection-mode | 1308 | ;; delete-selection-mode |
| 1360 | 1309 | ||
| 1361 | (defvar cua--saved-state nil) | 1310 | (defvar cua--saved-state nil) |
| 1311 | (defvar delete-selection-save-to-register) | ||
| 1362 | 1312 | ||
| 1363 | ;;;###autoload | 1313 | ;;;###autoload |
| 1364 | (define-minor-mode cua-mode | 1314 | (define-minor-mode cua-mode |
| @@ -1426,6 +1376,8 @@ the prefix fallback behavior." | |||
| 1426 | (if (and (boundp 'delete-selection-mode) delete-selection-mode) | 1376 | (if (and (boundp 'delete-selection-mode) delete-selection-mode) |
| 1427 | (delete-selection-mode -1))) | 1377 | (delete-selection-mode -1))) |
| 1428 | (if cua-highlight-region-shift-only (transient-mark-mode -1)) | 1378 | (if cua-highlight-region-shift-only (transient-mark-mode -1)) |
| 1379 | (if cua-delete-copy-to-register-0 | ||
| 1380 | (setq delete-selection-save-to-register ?0)) | ||
| 1429 | (cua--deactivate)) | 1381 | (cua--deactivate)) |
| 1430 | (cua--saved-state | 1382 | (cua--saved-state |
| 1431 | (if (nth 0 cua--saved-state) | 1383 | (if (nth 0 cua--saved-state) |