changeset 45278:97b1e590eb61

(cua-enable-cursor-indications): Default off. (cua-mode): Print Enabled/Disabled messages if interactive. Disable delete-selection-mode and pc-selection-mode when cua-mode is enabled; reenable if cua-mode is turned off. Remember setting of transient-mark-mode when cua-mode is enabled; restore if cua-mode is disabled.
author Kim F. Storm <storm@cua.dk>
date Mon, 13 May 2002 20:35:30 +0000
parents 597192e844f8
children 220c13a65624
files lisp/emulation/cua-base.el
diffstat 1 files changed, 43 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emulation/cua-base.el	Mon May 13 20:34:48 2002 +0000
+++ b/lisp/emulation/cua-base.el	Mon May 13 20:35:30 2002 +0000
@@ -388,7 +388,7 @@
 
 ;;; Cursor Indication Customization
 
-(defcustom cua-enable-cursor-indications t
+(defcustom cua-enable-cursor-indications nil
   "*If non-nil, use different cursor colors for indications."
   :type 'boolean
   :group 'cua)
@@ -1069,6 +1069,13 @@
   (define-key cua--region-keymap [remap keyboard-quit]		'cua-cancel)
   )
 
+;; State prior to enabling cua-mode
+;; Value is a list with the following elements:
+;;   transient-mark-mode
+;;   delete-selection-mode
+;;   pc-selection-mode
+
+(defvar cua--saved-state nil)
 
 ;;;###autoload
 (defun cua-mode (&optional arg)
@@ -1110,10 +1117,41 @@
 
   (if (fboundp 'cua--rectangle-on-off)
       (cua--rectangle-on-off cua-mode))
-  (setq transient-mark-mode (and cua-mode
-				 (if cua-highlight-region-shift-only
-				     (not cua--explicit-region-start)
-				   t))))
+
+  (cond
+   (cua-mode
+    (setq cua--saved-state
+	  (list
+	   transient-mark-mode
+	   (and (boundp 'delete-selection-mode) delete-selection-mode)
+	   (and (boundp 'pc-selection-mode) pc-selection-mode)))
+    (if (and (boundp 'delete-selection-mode) delete-selection-mode)
+	(delete-selection-mode))
+    (if (and (boundp 'pc-selection-mode) pc-selection-mode)
+	(pc-selection-mode))
+    (setq transient-mark-mode (and cua-mode
+				   (if cua-highlight-region-shift-only
+				       (not cua--explicit-region-start)
+				     t)))
+    (if (interactive-p)
+	(message "CUA mode enabled")))
+   (cua--saved-state
+    (setq transient-mark-mode (car cua--saved-state))
+    (if (nth 1 cua--saved-state)
+	(delete-selection-mode 1))
+    (if (nth 2 cua--saved-state)
+	(pc-selection-mode 1))
+    (if (interactive-p)
+	(message "CUA mode disabled.%s%s%s%s"
+		 (if (nth 1 cua--saved-state) " Delete-Selection" "")
+		 (if (and (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " and" "")
+		 (if (nth 2 cua--saved-state) " PC-Selection" "")
+		 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" "")))
+    (setq cua--saved-state nil))
+
+   (t
+    (if (interactive-p)
+	(message "CUA mode disabled")))))
 
 (defun cua-debug ()
   "Toggle cua debugging."