changeset 54257:b647c5859635

(mouse-sel-has-been-enabled): New var. (mouse-sel-mode): When enabling, set mouse-sel-has-been-enabled. When disabling, restore old values only if mouse-sel-has-been-enabled.
author Richard M. Stallman <rms@gnu.org>
date Thu, 04 Mar 2004 16:55:51 +0000
parents c8bd7417eb31
children baeae7be621d
files lisp/mouse-sel.el
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mouse-sel.el	Thu Mar 04 16:54:08 2004 +0000
+++ b/lisp/mouse-sel.el	Thu Mar 04 16:55:51 2004 +0000
@@ -196,6 +196,9 @@
 
 ;;=== User Command ========================================================
 
+(defvar mouse-sel-has-been-enabled nil
+  "Non-nil if Mouse Sel mode has been enabled at least once.")
+
 (defvar mouse-sel-original-bindings nil)
 (defvar mouse-sel-original-interprogram-cut-function nil)
 (defvar mouse-sel-original-interprogram-paste-function nil)
@@ -252,7 +255,8 @@
 	  (setq mouse-sel-original-interprogram-cut-function
 		interprogram-cut-function
 		mouse-sel-original-interprogram-paste-function
-		interprogram-paste-function)
+		interprogram-paste-function
+		mouse-sel-has-been-enabled t)
 	  (unless (eq mouse-sel-default-bindings 'interprogram-cut-paste)
 	    (setq interprogram-cut-function nil
 		  interprogram-paste-function nil))))
@@ -261,10 +265,11 @@
     (remove-hook 'x-lost-selection-hooks 'mouse-sel-lost-selection-hook)
     (dolist (binding mouse-sel-original-bindings)
       (global-set-key (car binding) (cdr binding)))
-    (setq interprogram-cut-function
-          mouse-sel-original-interprogram-cut-function
-          interprogram-paste-function
-          mouse-sel-original-interprogram-paste-function)))
+    (if mouse-sel-has-been-enabled
+	(setq interprogram-cut-function
+	      mouse-sel-original-interprogram-cut-function
+	      interprogram-paste-function
+	      mouse-sel-original-interprogram-paste-function))))
 
 ;;=== Internal Variables/Constants ========================================