]> code.delx.au - gnu-emacs/commitdiff
(cua-enable-cursor-indications): Default off.
authorKim F. Storm <storm@cua.dk>
Mon, 13 May 2002 20:35:30 +0000 (20:35 +0000)
committerKim F. Storm <storm@cua.dk>
Mon, 13 May 2002 20:35:30 +0000 (20:35 +0000)
(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.

lisp/emulation/cua-base.el

index 95423ea5ff1c90901e913f7077c04baf6696c5f8..5f6e966647f2fb99276d70a6f9d853b0be728599 100644 (file)
@@ -388,7 +388,7 @@ Can be toggled by [M-p] while the rectangle is active,"
 
 ;;; 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 @@ Extra commands should be added to `cua-user-movement-commands'")
   (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 @@ paste (in addition to the normal emacs bindings)."
 
   (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."