]> code.delx.au - gnu-emacs/blobdiff - lisp/obsolete/mouse-sel.el
; Fix breakage from previous commit
[gnu-emacs] / lisp / obsolete / mouse-sel.el
index 074d712d131943a4cf97322e2e83d1075bd34a88..b4fd7615e18ee77a5af0272c34c018e68781ef37 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mouse-sel.el --- multi-click selection support
 
-;; Copyright (C) 1993-1995, 2001-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 2001-2016 Free Software Foundation, Inc.
 
 ;; Author: Mike Williams <mdub@bigfoot.com>
 ;; Keywords: mouse
@@ -97,8 +97,8 @@
 ;;      In this mode, mouse-insert-selection just calls mouse-yank-at-click.
 ;;
 ;;       Selection/kill-ring interaction is retained
-;;         interprogram-cut-function   = x-select-text
-;;         interprogram-paste-function = x-selection-value
+;;         interprogram-cut-function   = gui-select-text
+;;         interprogram-paste-function = gui-selection-value
 ;;
 ;;       What you lose is the ability to select some text in
 ;;       delete-selection-mode and yank over the top of it.
@@ -190,12 +190,9 @@ If nil, point will always be placed at the beginning of the region."
 
 ;;=== 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)
+
+(defalias 'mouse-sel--ignore #'ignore)
 
 ;;;###autoload
 (define-minor-mode mouse-sel-mode
@@ -242,14 +239,11 @@ kill ring; mouse-1 or mouse-3 kills it."
                              (global-set-key event (cdr binding)))))
                        mouse-sel-bound-events))
          ;; Update interprogram functions.
-         (setq mouse-sel-original-interprogram-cut-function
-               interprogram-cut-function
-               mouse-sel-original-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))))
+           (add-function :override interprogram-cut-function
+                          #'mouse-sel--ignore)
+            (add-function :override interprogram-paste-function
+                          #'mouse-sel--ignore))))
 
     ;; Restore original bindings
     (remove-hook 'x-lost-selection-functions 'mouse-sel-lost-selection-hook)
@@ -257,11 +251,8 @@ kill ring; mouse-1 or mouse-3 kills it."
       (global-set-key (car binding) (cdr binding)))
     ;; Restore the old values of these variables,
     ;; only if they were actually saved previously.
-    (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))))
+    (remove-function interprogram-cut-function #'mouse-sel--ignore)
+    (remove-function interprogram-paste-function #'mouse-sel--ignore)))
 
 (make-obsolete 'mouse-sel-mode "use the normal mouse modes" "24.3")
 
@@ -301,15 +292,13 @@ where   SELECTION-NAME          = name of selection
        SELECTION-THING-SYMBOL  = name of variable where the current selection
                                  type for this selection should be stored.")
 
-(declare-function x-select-text "term/common-win" (text))
-
 (defvar mouse-sel-set-selection-function
   (if (eq mouse-sel-default-bindings 'interprogram-cut-paste)
-      'x-set-selection
+      'gui-set-selection
     (lambda (selection value)
       (if (eq selection 'PRIMARY)
-         (x-select-text value)
-       (x-set-selection selection value))))
+         (gui-select-text value)
+       (gui-set-selection selection value))))
   "Function to call to set selection.
 Called with two arguments:
 
@@ -319,15 +308,14 @@ Called with two arguments:
 This sets the selection, unless `mouse-sel-default-bindings'
 is `interprogram-cut-paste'.")
 
-(declare-function x-selection-value "term/x-win" ())
 
 (defvar mouse-sel-get-selection-function
   (lambda (selection)
     (if (eq selection 'PRIMARY)
-       (or (x-selection-value)
-           (bound-and-true-p x-last-selected-text)
-           (bound-and-true-p x-last-selected-text-primary))
-      (x-get-selection selection)))
+       (or (gui-selection-value)
+           (bound-and-true-p x-last-selected-text-primary)
+            gui--last-selected-text-primary)
+      (gui-get-selection selection)))
   "Function to call to get the selection.
 Called with one argument: