Mercurial > emacs
comparison lisp/emulation/cua-base.el @ 90103:3ebd9bdb4fe5
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-13
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-83
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-89
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-90
Update from CVS: man/calc.texi: Add macro for LaTeX for info output.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-91
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-94
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 13 Feb 2005 07:19:08 +0000 |
parents | eac554634bfa aac0a33f5772 |
children | 29e773288013 |
comparison
equal
deleted
inserted
replaced
90102:9b4f359c4117 | 90103:3ebd9bdb4fe5 |
---|---|
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, 2003, 2004 | 3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 |
4 ;; Free Software Foundation, Inc. | 4 ;; 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 |
8 | 8 |
265 "Emulate CUA key bindings including C-x and C-c." | 265 "Emulate CUA key bindings including C-x and C-c." |
266 :prefix "cua" | 266 :prefix "cua" |
267 :group 'editing-basics | 267 :group 'editing-basics |
268 :group 'convenience | 268 :group 'convenience |
269 :group 'emulations | 269 :group 'emulations |
270 :version "21.4" | 270 :version "22.1" |
271 :link '(emacs-commentary-link :tag "Commentary" "cua-base.el") | 271 :link '(emacs-commentary-link :tag "Commentary" "cua-base.el") |
272 :link '(emacs-library-link :tag "Lisp File" "cua-base.el")) | 272 :link '(emacs-library-link :tag "Lisp File" "cua-base.el")) |
273 | 273 |
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. |
388 "*Font used by CUA for highlighting the rectangle." | 388 "*Font used by CUA for highlighting the rectangle." |
389 :group 'cua) | 389 :group 'cua) |
390 | 390 |
391 (defface cua-rectangle-noselect-face 'nil | 391 (defface cua-rectangle-noselect-face 'nil |
392 "*Font used by CUA for highlighting the non-selected rectangle lines." | 392 "*Font used by CUA for highlighting the non-selected rectangle lines." |
393 :group 'cua) | |
394 | |
395 (defcustom cua-undo-max 64 | |
396 "*Max no of undoable CUA rectangle changes (including undo)." | |
397 :type 'integer | |
398 :group 'cua) | 393 :group 'cua) |
399 | 394 |
400 | 395 |
401 ;;; Global Mark Customization | 396 ;;; Global Mark Customization |
402 | 397 |
737 ctrl-u-prefix) | 732 ctrl-u-prefix) |
738 (t t))) | 733 (t t))) |
739 (+ arg ?0))) | 734 (+ arg ?0))) |
740 (if cua--register nil arg)) | 735 (if cua--register nil arg)) |
741 | 736 |
742 ;;; Enhanced undo - restore rectangle selections | |
743 | |
744 (defun cua-undo (&optional arg) | |
745 "Undo some previous changes. | |
746 Knows about CUA rectangle highlighting in addition to standard undo." | |
747 (interactive "*P") | |
748 (if (fboundp 'cua--rectangle-undo) | |
749 (cua--rectangle-undo arg) | |
750 (undo arg))) | |
751 | 737 |
752 ;;; Region specific commands | 738 ;;; Region specific commands |
753 | 739 |
754 (defvar cua--last-deleted-region-pos nil) | 740 (defvar cua--last-deleted-region-pos nil) |
755 (defvar cua--last-deleted-region-text nil) | 741 (defvar cua--last-deleted-region-text nil) |
986 (setq cua--explicit-region-start t) | 972 (setq cua--explicit-region-start t) |
987 (setq cua--last-region-shifted nil) | 973 (setq cua--last-region-shifted nil) |
988 (if cua-enable-region-auto-help | 974 (if cua-enable-region-auto-help |
989 (cua-help-for-region t))))) | 975 (cua-help-for-region t))))) |
990 | 976 |
991 (defvar cua--standard-movement-commands | |
992 '(forward-char backward-char | |
993 next-line previous-line | |
994 forward-word backward-word | |
995 end-of-line beginning-of-line | |
996 end-of-buffer beginning-of-buffer | |
997 scroll-up scroll-down cua-scroll-up cua-scroll-down | |
998 forward-sentence backward-sentence | |
999 forward-paragraph backward-paragraph) | |
1000 "List of standard movement commands. | |
1001 Extra commands should be added to `cua-movement-commands'") | |
1002 | |
1003 (defvar cua-movement-commands nil | |
1004 "User may add additional movement commands to this list.") | |
1005 | |
1006 ;;; Scrolling commands which does not signal errors at top/bottom | 977 ;;; Scrolling commands which does not signal errors at top/bottom |
1007 ;;; of buffer at first key-press (instead moves to top/bottom | 978 ;;; of buffer at first key-press (instead moves to top/bottom |
1008 ;;; of buffer). | 979 ;;; of buffer). |
1009 | 980 |
1010 (defun cua-scroll-up (&optional arg) | 981 (defun cua-scroll-up (&optional arg) |
1023 (t | 994 (t |
1024 (condition-case nil | 995 (condition-case nil |
1025 (scroll-up arg) | 996 (scroll-up arg) |
1026 (end-of-buffer (goto-char (point-max))))))) | 997 (end-of-buffer (goto-char (point-max))))))) |
1027 | 998 |
999 (put 'cua-scroll-up 'CUA 'move) | |
1000 | |
1028 (defun cua-scroll-down (&optional arg) | 1001 (defun cua-scroll-down (&optional arg) |
1029 "Scroll text of current window downward ARG lines; or near full screen if no ARG. | 1002 "Scroll text of current window downward ARG lines; or near full screen if no ARG. |
1030 If window cannot be scrolled further, move cursor to top line instead. | 1003 If window cannot be scrolled further, move cursor to top line instead. |
1031 A near full screen is `next-screen-context-lines' less than a full screen. | 1004 A near full screen is `next-screen-context-lines' less than a full screen. |
1032 Negative ARG means scroll upward. | 1005 Negative ARG means scroll upward. |
1040 (scroll-down arg)) ; signal error | 1013 (scroll-down arg)) ; signal error |
1041 (t | 1014 (t |
1042 (condition-case nil | 1015 (condition-case nil |
1043 (scroll-down arg) | 1016 (scroll-down arg) |
1044 (beginning-of-buffer (goto-char (point-min))))))) | 1017 (beginning-of-buffer (goto-char (point-min))))))) |
1018 | |
1019 (put 'cua-scroll-up 'CUA 'move) | |
1045 | 1020 |
1046 ;;; Cursor indications | 1021 ;;; Cursor indications |
1047 | 1022 |
1048 (defun cua--update-indications () | 1023 (defun cua--update-indications () |
1049 (let* ((cursor | 1024 (let* ((cursor |
1071 | 1046 |
1072 ;;; Pre-command hook | 1047 ;;; Pre-command hook |
1073 | 1048 |
1074 (defun cua--pre-command-handler () | 1049 (defun cua--pre-command-handler () |
1075 (condition-case nil | 1050 (condition-case nil |
1076 (let ((movement (or (memq this-command cua--standard-movement-commands) | 1051 (let ((movement (eq (get this-command 'CUA) 'move))) |
1077 (memq this-command cua-movement-commands)))) | |
1078 | 1052 |
1079 ;; Cancel prefix key timeout if user enters another key. | 1053 ;; Cancel prefix key timeout if user enters another key. |
1080 (when cua--prefix-override-timer | 1054 (when cua--prefix-override-timer |
1081 (if (timerp cua--prefix-override-timer) | 1055 (if (timerp cua--prefix-override-timer) |
1082 (cancel-timer cua--prefix-override-timer)) | 1056 (cancel-timer cua--prefix-override-timer)) |
1249 (define-key cua-global-keymap [remap clipboard-yank] 'cua-paste) | 1223 (define-key cua-global-keymap [remap clipboard-yank] 'cua-paste) |
1250 ;; replace current yank with previous kill ring element | 1224 ;; replace current yank with previous kill ring element |
1251 (define-key cua-global-keymap [remap yank-pop] 'cua-paste-pop) | 1225 (define-key cua-global-keymap [remap yank-pop] 'cua-paste-pop) |
1252 ;; set mark | 1226 ;; set mark |
1253 (define-key cua-global-keymap [remap set-mark-command] 'cua-set-mark) | 1227 (define-key cua-global-keymap [remap set-mark-command] 'cua-set-mark) |
1254 ;; undo | |
1255 (define-key cua-global-keymap [remap undo] 'cua-undo) | |
1256 (define-key cua-global-keymap [remap advertised-undo] 'cua-undo) | |
1257 | 1228 |
1258 ;; scrolling | 1229 ;; scrolling |
1259 (define-key cua-global-keymap [remap scroll-up] 'cua-scroll-up) | 1230 (define-key cua-global-keymap [remap scroll-up] 'cua-scroll-up) |
1260 (define-key cua-global-keymap [remap scroll-down] 'cua-scroll-down) | 1231 (define-key cua-global-keymap [remap scroll-down] 'cua-scroll-down) |
1261 | 1232 |
1303 ;; cancel current region/rectangle | 1274 ;; cancel current region/rectangle |
1304 (define-key cua--region-keymap [remap keyboard-escape-quit] 'cua-cancel) | 1275 (define-key cua--region-keymap [remap keyboard-escape-quit] 'cua-cancel) |
1305 (define-key cua--region-keymap [remap keyboard-quit] 'cua-cancel) | 1276 (define-key cua--region-keymap [remap keyboard-quit] 'cua-cancel) |
1306 ) | 1277 ) |
1307 | 1278 |
1279 | |
1280 ;; Setup standard movement commands to be recognized by CUA. | |
1281 | |
1282 (dolist (cmd | |
1283 '(forward-char backward-char | |
1284 next-line previous-line | |
1285 forward-word backward-word | |
1286 end-of-line beginning-of-line | |
1287 end-of-buffer beginning-of-buffer | |
1288 scroll-up scroll-down | |
1289 forward-sentence backward-sentence | |
1290 forward-paragraph backward-paragraph)) | |
1291 (put cmd 'CUA 'move)) | |
1292 | |
1308 ;; State prior to enabling cua-mode | 1293 ;; State prior to enabling cua-mode |
1309 ;; Value is a list with the following elements: | 1294 ;; Value is a list with the following elements: |
1310 ;; transient-mark-mode | 1295 ;; transient-mark-mode |
1311 ;; delete-selection-mode | 1296 ;; delete-selection-mode |
1312 ;; pc-selection-mode | 1297 ;; pc-selection-mode |
1347 | 1332 |
1348 (if (not cua-mode) | 1333 (if (not cua-mode) |
1349 (setq emulation-mode-map-alists (delq 'cua--keymap-alist emulation-mode-map-alists)) | 1334 (setq emulation-mode-map-alists (delq 'cua--keymap-alist emulation-mode-map-alists)) |
1350 (add-to-list 'emulation-mode-map-alists 'cua--keymap-alist) | 1335 (add-to-list 'emulation-mode-map-alists 'cua--keymap-alist) |
1351 (cua--select-keymaps)) | 1336 (cua--select-keymaps)) |
1352 | |
1353 (if (fboundp 'cua--rectangle-on-off) | |
1354 (cua--rectangle-on-off cua-mode)) | |
1355 | 1337 |
1356 (cond | 1338 (cond |
1357 (cua-mode | 1339 (cua-mode |
1358 (setq cua--saved-state | 1340 (setq cua--saved-state |
1359 (list | 1341 (list |
1387 "Toggle cua debugging." | 1369 "Toggle cua debugging." |
1388 (interactive) | 1370 (interactive) |
1389 (setq cua--debug (not cua--debug))) | 1371 (setq cua--debug (not cua--debug))) |
1390 | 1372 |
1391 ;; Install run-time check for older versions of CUA-mode which does not | 1373 ;; Install run-time check for older versions of CUA-mode which does not |
1392 ;; work with GNU Emacs version 21.4 and newer. | 1374 ;; work with GNU Emacs version 22.1 and newer. |
1393 ;; | 1375 ;; |
1394 ;; Except for version 1.2, all of the 1.x and 2.x version of cua-mode | 1376 ;; Except for version 1.2, all of the 1.x and 2.x version of cua-mode |
1395 ;; provided the `CUA-mode' feature. Since this is no longer true, | 1377 ;; provided the `CUA-mode' feature. Since this is no longer true, |
1396 ;; we can warn the user if the `CUA-mode' feature is ever provided. | 1378 ;; we can warn the user if the `CUA-mode' feature is ever provided. |
1397 | 1379 |