emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r118006: Consolidate management/ownership of selecti


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r118006: Consolidate management/ownership of selections.
Date: Thu, 02 Oct 2014 03:19:44 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 118006
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2014-10-01 23:19:32 -0400
message:
  Consolidate management/ownership of selections.
  * lisp/select.el (gui-get-selection-alist): New method.
  (gui-get-selection): Use it.  Rename from x-get-selection.
  (x-get-selection): Define as obsolete alias.
  (x-get-clipboard): Mark obsolete.
  (gui-get-primary-selection): New function.
  (x-get-selection-value): Mark obsolete.
  (gui-own-selection-alist, gui-disown-selection-alist)
  (gui-selection-owner-p-alist): New methods.
  (gui-set-selection): Use them.  Rename from x-set-selection.
  (x-set-selection): Define as obsolete alias.
  (gui--valid-simple-selection-p): Rename from
  x-valid-simple-selection-p.
  * lisp/w32-common-fns.el (gui-own-selection, gui-disown-selection)
  (gui-selection-owner-p, gui-get-selection): Define for w32.
  (w32-get-selection-value): Rename from x-get-selection-value.
  Use the new gui-last-selected-text.
  * lisp/term/x-win.el (x-get-selection-value): Remove.
  (x-clipboard-yank): Declare obsolete.
  (gui-own-selection, gui-disown-selection, gui-get-selection)
  (gui-selection-owner-p): Define for x.
  * lisp/term/w32-win.el (w32-win-suspend-error): Rename from
  x-win-suspend-error.
  * lisp/term/pc-win.el (w16-get-selection-value): Rename from
  x-get-selection-value.
  (w16-selection-owner-p): Rename from x-selection-owner-p.
  (gui-own-selection, gui-disown-selection, gui-get-selection)
  (gui-selection-owner-p): Define for pc.
  (w16--select-text): New function.
  * lisp/term/ns-win.el (gui-own-selection, gui-disown-selection)
  (gui-get-selection, gui-selection-owner-p): Define for ns.
  * lisp/term.el (term-mouse-paste):
  * lisp/mouse.el (mouse-yank-primary): Use gui-get-primary-selection.
  * src/nsselect.m (ns-own-selection-internal, ns-disown-selection-internal):
  Rename from the "x-" prefix.
modified:
  etc/NEWS                       news-20100311060928-aoit31wvzf25yr1z-1
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/mouse-copy.el             
mousecopy.el-20091113204419-o5vbwnq5f7feedwu-1016
  lisp/mouse.el                  mouse.el-20091113204419-o5vbwnq5f7feedwu-123
  lisp/obsolete/mouse-sel.el     mousesel.el-20091113204419-o5vbwnq5f7feedwu-635
  lisp/select.el                 select.el-20091113204419-o5vbwnq5f7feedwu-550
  lisp/simple.el                 simple.el-20091113204419-o5vbwnq5f7feedwu-403
  lisp/term.el                   term.el-20091113204419-o5vbwnq5f7feedwu-794
  lisp/term/ns-win.el            nswin.el-20091113204419-o5vbwnq5f7feedwu-8708
  lisp/term/pc-win.el            pcwin.el-20091113204419-o5vbwnq5f7feedwu-795
  lisp/term/w32-win.el           w32win.el-20091113204419-o5vbwnq5f7feedwu-943
  lisp/term/x-win.el             xwin.el-20091113204419-o5vbwnq5f7feedwu-113
  lisp/w32-common-fns.el         
w32commonfns.el-20120917115700-3at3xhn4to67xnca-4
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/nsselect.m                 nsselect.m-20091113204419-o5vbwnq5f7feedwu-8745
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2014-10-01 22:13:11 +0000
+++ b/etc/NEWS  2014-10-02 03:19:32 +0000
@@ -245,7 +245,12 @@
 
 * Lisp Changes in Emacs 25.1
 
-** x-select-text is renamed gui-select-text.
+** Some "x-*" were obsoleted:
+*** x-select-text is renamed gui-select-text.
+*** x-get-selection is renamed gui-get-selection.
+*** x-get-clipboard and x-clipboard-yank are marked obsolete.
+*** x-get-selection-value is renamed to gui-get-primary-selection.
+*** x-set-selection is renamed to gui-set-selection
 
 ** call-process-shell-command and process-file-shell-command
 don't take "&rest args" any more.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-10-02 02:09:30 +0000
+++ b/lisp/ChangeLog    2014-10-02 03:19:32 +0000
@@ -1,3 +1,39 @@
+2014-10-02  Stefan Monnier  <address@hidden>
+
+       Consolidate management/ownership of selections.
+       * select.el (gui-get-selection-alist): New method.
+       (gui-get-selection): Use it.  Rename from x-get-selection.
+       (x-get-selection): Define as obsolete alias.
+       (x-get-clipboard): Mark obsolete.
+       (gui-get-primary-selection): New function.
+       (x-get-selection-value): Mark obsolete.
+       (gui-own-selection-alist, gui-disown-selection-alist)
+       (gui-selection-owner-p-alist): New methods.
+       (gui-set-selection): Use them.  Rename from x-set-selection.
+       (x-set-selection): Define as obsolete alias.
+       (gui--valid-simple-selection-p): Rename from
+       x-valid-simple-selection-p.
+       * w32-common-fns.el (gui-own-selection, gui-disown-selection)
+       (gui-selection-owner-p, gui-get-selection): Define for w32.
+       (w32-get-selection-value): Rename from x-get-selection-value.
+       Use the new gui-last-selected-text.
+       * term/x-win.el (x-get-selection-value): Remove.
+       (x-clipboard-yank): Declare obsolete.
+       (gui-own-selection, gui-disown-selection, gui-get-selection)
+       (gui-selection-owner-p): Define for x.
+       * term/w32-win.el (w32-win-suspend-error): Rename from
+       x-win-suspend-error.
+       * term/pc-win.el (w16-get-selection-value): Rename from
+       x-get-selection-value.
+       (w16-selection-owner-p): Rename from x-selection-owner-p.
+       (gui-own-selection, gui-disown-selection, gui-get-selection)
+       (gui-selection-owner-p): Define for pc.
+       (w16--select-text): New function.
+       * term/ns-win.el (gui-own-selection, gui-disown-selection)
+       (gui-get-selection, gui-selection-owner-p): Define for ns.
+       * term.el (term-mouse-paste):
+       * mouse.el (mouse-yank-primary): Use gui-get-primary-selection.
+
 2014-10-02  H. Dieter Wilhelm <address@hidden>  (tiny change)
 
        * calc/calc-help.el (calc-describe-thing): Quote strings

=== modified file 'lisp/mouse-copy.el'
--- a/lisp/mouse-copy.el        2014-01-01 07:43:34 +0000
+++ b/lisp/mouse-copy.el        2014-10-02 03:19:32 +0000
@@ -147,7 +147,7 @@
       ;; Third, set the selection.
       ;; (setq me-beg beg me-end end me-range range)  ; for debugging
       (set-buffer end-buffer)
-      (x-set-selection 'SECONDARY (buffer-substring beg end)))))
+      (gui-set-selection 'SECONDARY (buffer-substring beg end)))))
 
 
 (defun mouse-drag-secondary-pasting (start-event)
@@ -203,7 +203,7 @@
     (kill-region (overlay-start mouse-secondary-overlay)
                 (overlay-end mouse-secondary-overlay)))
   ;; (delete-overlay mouse-secondary-overlay)
-  ;; (x-set-selection 'SECONDARY nil)
+  ;; (gui-set-selection 'SECONDARY nil)
   ;; (setq mouse-secondary-overlay nil)
 )
 

=== modified file 'lisp/mouse.el'
--- a/lisp/mouse.el     2014-09-15 00:20:21 +0000
+++ b/lisp/mouse.el     2014-10-02 03:19:32 +0000
@@ -1068,24 +1068,7 @@
     (let (select-active-regions)
       (deactivate-mark)))
   (or mouse-yank-at-point (mouse-set-point click))
-  (let ((primary
-         (if (fboundp 'x-get-selection-value)
-             (if (eq (framep (selected-frame)) 'w32)
-                 ;; MS-Windows emulates PRIMARY in x-get-selection, but not
-                 ;; in x-get-selection-value (the latter only accesses the
-                 ;; clipboard).  So try PRIMARY first, in case they selected
-                 ;; something with the mouse in the current Emacs session.
-                 (or (x-get-selection 'PRIMARY)
-                     (x-get-selection-value))
-               ;; Else MS-DOS or X.
-               ;; On X, x-get-selection-value supports more formats and
-               ;; encodings, so use it in preference to x-get-selection.
-               (or (x-get-selection-value)
-                   (x-get-selection 'PRIMARY)))
-           ;; FIXME: What about xterm-mouse-mode etc.?
-           (x-get-selection 'PRIMARY))))
-    (unless primary
-      (error "No selection is available"))
+  (let ((primary (gui-get-primary-selection)))
     (push-mark (point))
     (insert-for-yank primary)))
 
@@ -1272,7 +1255,7 @@
       (if (numberp (posn-point posn))
          (setq beg (posn-point posn)))
       (move-overlay mouse-secondary-overlay beg (posn-point end))
-      (x-set-selection
+      (gui-set-selection
        'SECONDARY
        (buffer-substring (overlay-start mouse-secondary-overlay)
                         (overlay-end mouse-secondary-overlay))))))
@@ -1347,13 +1330,13 @@
            (if (marker-position mouse-secondary-start)
                (save-window-excursion
                  (delete-overlay mouse-secondary-overlay)
-                 (x-set-selection 'SECONDARY nil)
+                 (gui-set-selection 'SECONDARY nil)
                  (select-window start-window)
                  (save-excursion
                    (goto-char mouse-secondary-start)
                    (sit-for 1)
                    nil))
-             (x-set-selection
+             (gui-set-selection
               'SECONDARY
               (buffer-substring (overlay-start mouse-secondary-overlay)
                                 (overlay-end mouse-secondary-overlay)))))))))
@@ -1486,7 +1469,7 @@
         (setq str (buffer-substring (overlay-start mouse-secondary-overlay)
                                     (overlay-end mouse-secondary-overlay)))
         (> (length str) 0)
-        (x-set-selection 'SECONDARY str))))
+        (gui-set-selection 'SECONDARY str))))
 
 
 (defcustom mouse-buffer-menu-maxlen 20

=== modified file 'lisp/obsolete/mouse-sel.el'
--- a/lisp/obsolete/mouse-sel.el        2014-08-13 14:15:54 +0000
+++ b/lisp/obsolete/mouse-sel.el        2014-10-02 03:19:32 +0000
@@ -97,7 +97,7 @@
 ;;      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-cut-function   = gui-select-text
 ;;         interprogram-paste-function = x-selection-value
 ;;
 ;;       What you lose is the ability to select some text in
@@ -292,15 +292,13 @@
        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:
 
@@ -316,7 +314,6 @@
   (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)))
   "Function to call to get the selection.

=== modified file 'lisp/select.el'
--- a/lisp/select.el    2014-10-01 22:13:11 +0000
+++ b/lisp/select.el    2014-10-02 03:19:32 +0000
@@ -71,9 +71,6 @@
 variable is set, it is used for the next communication only.
 After the communication, this variable is set to nil.")
 
-(declare-function x-get-selection-internal "xselect.c"
-                 (selection-symbol target-type &optional time-stamp terminal))
-
 ;; Only declared obsolete in 23.3.
 (define-obsolete-function-alias 'x-selection 'x-get-selection "at least 19.34")
 
@@ -93,6 +90,13 @@
 Called with one argument (the text selected).
 Should obey `gui-select-enable-clipboard' where applicable.")
 
+(gui-method-declare gui-get-selection #'ignore
+  "Return selected text.
+Called with 2 arguments: (SELECTION-SYMBOL TARGET-TYPE)
+SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+\(Those are literal upper-case symbol names, since that's what X expects.)
+TARGET-TYPE is the type of data desired, typically `STRING'.")
+
 (defvar gui-last-selected-text nil
   "Last text passed to `gui-select-text'.")
 
@@ -112,7 +116,7 @@
   (setq gui-last-selected-text text))
 (define-obsolete-function-alias 'x-select-text 'gui-select-text "25.1")
 
-(defun x-get-selection (&optional type data-type)
+(defun gui-get-selection (&optional type data-type)
   "Return the value of an X Windows selection.
 The argument TYPE (default `PRIMARY') says which selection,
 and the argument DATA-TYPE (default `STRING') says
@@ -126,39 +130,69 @@
 DATA-TYPE is usually `STRING', but can also be one of the symbols
 in `selection-converter-alist', which see.  This argument is
 ignored on MS-Windows and MS-DOS."
-  (let ((data (x-get-selection-internal (or type 'PRIMARY)
-                                       (or data-type 'STRING)))
-       coding)
+  (let ((data (gui-call gui-get-selection (or type 'PRIMARY)
+                        (or data-type 'STRING))))
     (when (and (stringp data)
               (setq data-type (get-text-property 0 'foreign-selection data)))
-      (setq coding (or next-selection-coding-system
-                      selection-coding-system
-                      (cond ((eq data-type 'UTF8_STRING)
-                             'utf-8)
-                            ((eq data-type 'COMPOUND_TEXT)
-                             'compound-text-with-extensions)
-                            ((eq data-type 'C_STRING)
-                             nil)
-                            ((eq data-type 'STRING)
-                             'iso-8859-1)
-                            (t
-                             (error "Unknown selection data type: %S" type))))
-           data (if coding (decode-coding-string data coding)
-                  (string-to-multibyte data)))
+      (let ((coding (or next-selection-coding-system
+                        selection-coding-system
+                        (pcase data-type
+                          ('UTF8_STRING 'utf-8)
+                          ('COMPOUND_TEXT 'compound-text-with-extensions)
+                          ('C_STRING nil)
+                          ('STRING 'iso-8859-1)
+                          (_ (error "Unknown selection data type: %S"
+                                    type))))))
+        (setq data (if coding (decode-coding-string data coding)
+                     (string-to-multibyte data))))
       (setq next-selection-coding-system nil)
       (put-text-property 0 (length data) 'foreign-selection data-type data))
     data))
+(define-obsolete-function-alias 'x-get-selection 'gui-get-selection "25.1")
 
 (defun x-get-clipboard ()
   "Return text pasted to the clipboard."
-  (x-get-selection-internal 'CLIPBOARD 'STRING))
-
-(declare-function x-own-selection-internal "xselect.c"
-                 (selection-name selection-value &optional frame))
-(declare-function x-disown-selection-internal "xselect.c"
-                 (selection &optional time terminal))
-
-(defun x-set-selection (type data)
+  (declare (obsolete gui-get-selection "25.1"))
+  (gui-call gui-get-selection 'CLIPBOARD 'STRING))
+
+(defun gui-get-primary-selection ()
+  "Return the PRIMARY selection, or the best emulation thereof."
+  (or (gui-get-selection 'PRIMARY)
+      (and (fboundp 'w32-get-selection-value)
+           (eq (framep (selected-frame)) 'w32)
+           ;; MS-Windows emulates PRIMARY in x-get-selection, but only
+           ;; within the Emacs session, so consult the clipboard if
+           ;; primary is not found.
+           (w32-get-selection-value))
+      (error "No selection is available")))
+(define-obsolete-function-alias 'x-get-selection-value
+  'gui-get-primary-selection "25.1")
+
+(gui-method-declare gui-own-selection nil
+  "Method to assert a selection of type SELECTION and value VALUE.
+SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+(Those are literal upper-case symbol names, since that's what X expects.)
+VALUE is typically a string, or a cons of two markers, but may be
+anything that the functions on `selection-converter-alist' know about.
+
+Called with 2 args: (SELECTION VALUE).")
+
+(gui-method-declare gui-disown-selection nil
+  "If we own the selection SELECTION, disown it.
+Disowning it means there is no such selection.
+
+Called with one argument: (SELECTION)")
+
+(gui-method-declare gui-selection-owner-p #'ignore
+  "Whether the current Emacs process owns the given X Selection.
+Called with one argument: (SELECTION).
+The arg should be the name of the selection in question, typically one of
+the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+(Those are literal upper-case symbol names, since that's what X expects.)
+For convenience, the symbol nil is the same as `PRIMARY',
+and t is the same as `SECONDARY'.")
+
+(defun gui-set-selection (type data)
   "Make an X selection of type TYPE and value DATA.
 The argument TYPE (nil means `PRIMARY') says which selection, and
 DATA specifies the contents.  TYPE must be a symbol.  \(It can also
@@ -186,23 +220,24 @@
                   (list 'PRIMARY (read-string "Set text for pasting: "))
                 (list 'PRIMARY (buffer-substring (region-beginning) 
(region-end)))))
   (if (stringp type) (setq type (intern type)))
-  (or (x-valid-simple-selection-p data)
+  (or (gui--valid-simple-selection-p data)
       (and (vectorp data)
           (let ((valid t)
                 (i (1- (length data))))
             (while (>= i 0)
-              (or (x-valid-simple-selection-p (aref data i))
+              (or (gui--valid-simple-selection-p (aref data i))
                   (setq valid nil))
               (setq i (1- i)))
             valid))
       (signal 'error (list "invalid selection" data)))
   (or type (setq type 'PRIMARY))
   (if data
-      (x-own-selection-internal type data)
-    (x-disown-selection-internal type))
+      (gui-call gui-own-selection type data)
+    (gui-call gui-disown-selection type))
   data)
+(define-obsolete-function-alias 'x-set-selection 'gui-set-selection "25.1")
 
-(defun x-valid-simple-selection-p (data)
+(defun gui--valid-simple-selection-p (data)
   (or (bufferp data)
       (and (consp data)
           (markerp (car data))
@@ -358,7 +393,7 @@
     (apply 'vector all)))
 
 (defun xselect-convert-to-delete (selection _type _value)
-  (x-disown-selection-internal selection)
+  (gui-call gui-disown-selection selection)
   ;; A return value of nil means that we do not know how to do this conversion,
   ;; and replies with an "error".  A return value of NULL means that we have
   ;; done the conversion (and any side-effects) but have no value to return.

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2014-10-01 22:13:11 +0000
+++ b/lisp/simple.el    2014-10-02 03:19:32 +0000
@@ -3629,7 +3629,7 @@
 
 ;;;; Window system cut and paste hooks.
 
-(defvar interprogram-cut-function #'x-select-text
+(defvar interprogram-cut-function #'gui-select-text
   "Function to call to make a killed region available to other programs.
 Most window systems provide a facility for cutting and pasting
 text between different programs, such as the clipboard on X and
@@ -4497,8 +4497,6 @@
     (signal 'mark-inactive nil)))
 
 ;; Behind display-selections-p.
-(declare-function x-selection-owner-p "xselect.c"
-                  (&optional selection terminal))
 (declare-function x-selection-exists-p "xselect.c"
                   (&optional selection terminal))
 
@@ -4525,15 +4523,15 @@
       ;; the region prior to the last command modifying the buffer.
       ;; Set the selection to that, or to the current region.
       (cond (saved-region-selection
-            (x-set-selection 'PRIMARY saved-region-selection)
+            (gui-set-selection 'PRIMARY saved-region-selection)
             (setq saved-region-selection nil))
            ;; If another program has acquired the selection, region
            ;; deactivation should not clobber it (Bug#11772).
            ((and (/= (region-beginning) (region-end))
-                 (or (x-selection-owner-p 'PRIMARY)
-                     (null (x-selection-exists-p 'PRIMARY))))
-            (x-set-selection 'PRIMARY
-                              (funcall region-extract-function nil)))))
+                 (or (call-gui gui-selection-owner-p 'PRIMARY)
+                     (null (gui-selection-exists-p 'PRIMARY))))
+            (gui-set-selection 'PRIMARY
+                                (funcall region-extract-function nil)))))
     (when mark-active (force-mode-line-update)) ;Refresh toolbar (bug#16382).
     (cond
      ((eq (car-safe transient-mark-mode) 'only)

=== modified file 'lisp/term.el'
--- a/lisp/term.el      2014-07-08 19:15:28 +0000
+++ b/lisp/term.el      2014-10-02 03:19:32 +0000
@@ -1249,16 +1249,7 @@
     (run-hooks 'mouse-leave-buffer-hook)
     (setq this-command 'yank)
     (mouse-set-point click)
-    (term-send-raw-string
-     ;; From `mouse-yank-primary':
-     (or (if (fboundp 'x-get-selection-value)
-             (if (eq system-type 'windows-nt)
-                 (or (x-get-selection 'PRIMARY)
-                     (x-get-selection-value))
-               (or (x-get-selection-value)
-                   (x-get-selection 'PRIMARY)))
-          (x-get-selection 'PRIMARY))
-        (error "No selection is available")))))
+    (term-send-raw-string (gui-get-primary-selection))))
 
 (defun term-paste ()
   "Insert the last stretch of killed text at point."

=== modified file 'lisp/term/ns-win.el'
--- a/lisp/term/ns-win.el       2014-10-01 22:13:11 +0000
+++ b/lisp/term/ns-win.el       2014-10-02 03:19:32 +0000
@@ -971,6 +971,11 @@
                      (when gui-select-enable-clipboard
                        (ns-set-pasteboard text))))
 
+(gui-method-define gui-own-selection x #'ns-own-selection-internal)
+(gui-method-define gui-disown-selection x #'ns-disown-selection-internal)
+(gui-method-define gui-selection-owner-p x #'ns-selection-owner-p)
+(gui-method-define gui-get-selection x #'x-get-selection-internal) ;FIXME:name!
+
 (provide 'ns-win)
 
 ;;; ns-win.el ends here

=== modified file 'lisp/term/pc-win.el'
--- a/lisp/term/pc-win.el       2014-10-01 22:13:11 +0000
+++ b/lisp/term/pc-win.el       2014-10-02 03:19:32 +0000
@@ -219,7 +219,7 @@
 ;
 ;;;; Selections
 ;
-(defun x-get-selection-value ()
+(defun w16-get-selection-value ()
   "Return the value of the current selection.
 Consult the selection.  Treat empty strings as if they were unset."
   (if gui-select-enable-clipboard
@@ -238,93 +238,44 @@
         (t
          (setq gui-last-selected-text text))))))
 
-;; x-selection-owner-p is used in simple.el.
-(defun x-selection-owner-p (&optional _selection _terminal)
-  "Whether the current Emacs process owns the given X Selection.
-The arg should be the name of the selection in question, typically one of
-the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
-\(Those are literal upper-case symbol names, since that's what X expects.)
-For convenience, the symbol nil is the same as `PRIMARY',
-and t is the same as `SECONDARY'.
-
-TERMINAL should be a terminal object or a frame specifying the X
-server to query.  If omitted or nil, that stands for the selected
-frame's display, or the first available X display.
-
-On Nextstep, TERMINAL is unused.
-
-\(fn &optional SELECTION TERMINAL)"
-    (if gui-select-enable-clipboard
-      (let (text)
-       ;; Don't die if w16-get-clipboard-data signals an error.
-       (ignore-errors
-         (setq text (w16-get-clipboard-data)))
-       ;; We consider ourselves the owner of the selection if it does
-       ;; not exist, or exists and compares equal with the last text
-       ;; we've put into the Windows clipboard.
-       (cond
-        ((not text) t)
-        ((or (eq text gui-last-selected-text)
-             (string= text gui-last-selected-text))
-         text)
-        (t nil)))))
-
-;; x-own-selection-internal and x-disown-selection-internal are used
-;; in select.el:x-set-selection.
-(defun x-own-selection-internal (_selection value &optional _frame)
-  "Assert an X selection of the type SELECTION with and value VALUE.
-SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
-\(Those are literal upper-case symbol names, since that's what X expects.)
-VALUE is typically a string, or a cons of two markers, but may be
-anything that the functions on `selection-converter-alist' know about.
-
-FRAME should be a frame that should own the selection.  If omitted or
-nil, it defaults to the selected frame.
-
-On Nextstep, FRAME is unused.
-
-\(fn SELECTION VALUE &optional FRAME)"
-  (ignore-errors
-    (x-select-text value))
-  value)
-
-(defun x-disown-selection-internal (selection &optional _time-object _terminal)
-  "If we own the selection SELECTION, disown it.
-Disowning it means there is no such selection.
-
-Sets the last-change time for the selection to TIME-OBJECT (by default
-the time of the last event).
-
-TERMINAL should be a terminal object or a frame specifying the X
-server to query.  If omitted or nil, that stands for the selected
-frame's display, or the first available X display.
-
-On Nextstep, the TIME-OBJECT and TERMINAL arguments are unused.
-On MS-DOS, all this does is return non-nil if we own the selection.
-
-\(fn SELECTION &optional TIME-OBJECT TERMINAL)"
-  (if (x-selection-owner-p selection)
-      t))
-
-;; x-get-selection-internal is used in select.el
-(defun x-get-selection-internal (_selection-symbol _target-type
-                                                 &optional _time-stamp 
_terminal)
-  "Return text selected from some X window.
-SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
-\(Those are literal upper-case symbol names, since that's what X expects.)
-TARGET-TYPE is the type of data desired, typically `STRING'.
-
-TIME-STAMP is the time to use in the XConvertSelection call for foreign
-selections.  If omitted, defaults to the time for the last event.
-
-TERMINAL should be a terminal object or a frame specifying the X
-server to query.  If omitted or nil, that stands for the selected
-frame's display, or the first available X display.
-
-On Nextstep, TIME-STAMP and TERMINAL are unused.
-
-\(fn SELECTION-SYMBOL TARGET-TYPE &optional TIME-STAMP TERMINAL)"
-  (x-get-selection-value))
+;; gui-selection-owner-p is used in simple.el.
+(gui-method-define gui-selection-owner-p pc #'w16-selection-owner-p)
+(defun w16-selection-owner-p (_selection)
+  ;; FIXME: Other systems don't obey gui-select-enable-clipboard here.
+  (if gui-select-enable-clipboard
+      (let ((text
+             ;; Don't die if w16-get-clipboard-data signals an error.
+             (ignore-errors
+               (w16-get-clipboard-data))))
+        ;; We consider ourselves the owner of the selection
+        ;; if it does not exist, or exists and compares
+        ;; equal with the last text we've put into the
+        ;; Windows clipboard.
+        (cond
+         ((not text) t)
+         ((or (eq text gui-last-selected-text)
+              (string= text gui-last-selected-text))
+          text)
+         (t nil)))))
+
+;; gui-own-selection and gui-disown-selection are used in gui-set-selection.
+(gui-method-define gui-own-selection pc
+                   (lambda (_selection value)
+                     ;; FIXME: Other systems don't obey
+                     ;; gui-select-enable-clipboard here.
+                     (ignore-errors
+                       (w16--select-text value))
+                     value))
+
+(gui-method-define gui-disown-selection pc
+                   (lambda (selection &optional _time-object _terminal)
+                     (if (w16-selection-owner-p selection)
+                         t)))
+
+;; gui-get-selection is used in select.el
+(gui-method-define gui-get-selection pc
+                   (lambda (selection-symbol target-type)
+                     (w16-get-selection-value)))
 
 ;; From src/fontset.c:
 (fset 'query-fontset 'ignore)
@@ -429,7 +380,7 @@
   (setq split-window-keep-point t)
   ;; Arrange for the kill and yank functions to set and check the
   ;; clipboard.
-  (setq interprogram-paste-function 'x-get-selection-value)
+  (setq interprogram-paste-function #'w16-get-selection-value)
   (menu-bar-enable-clipboard)
   (run-hooks 'terminal-init-msdos-hook))
 
@@ -446,10 +397,10 @@
 
 (declare-function w16-set-clipboard-data "w16select.c"
                  (string &optional ignored))
-(gui-method-define gui-select-text pc
-                   (lambda (text)
-                     (when gui-select-enable-clipboard
-                       (w16-set-clipboard-data text))))
+(gui-method-define gui-select-text pc #'w16--select-text)
+(defun w16--select-text (text)
+  (when gui-select-enable-clipboard
+    (w16-set-clipboard-data text)))
 
 ;; ---------------------------------------------------------------------------
 

=== modified file 'lisp/term/w32-win.el'
--- a/lisp/term/w32-win.el      2014-10-01 22:13:11 +0000
+++ b/lisp/term/w32-win.el      2014-10-02 03:19:32 +0000
@@ -205,9 +205,8 @@
 
 See the documentation of `create-fontset-from-fontset-spec' for the format.")
 
-(defun x-win-suspend-error ()
-  "Report an error when a suspend is attempted.
-This returns an error if any Emacs frames are X frames, or always under W32."
+(defun w32-win-suspend-error ()
+  "Report an error when a suspend is attempted."
   (error "Suspending an Emacs running under W32 makes no sense"))
 
 (defvar dynamic-library-alist)
@@ -353,7 +352,7 @@
                 (cons '(reverse . t) default-frame-alist)))))
 
   ;; Don't let Emacs suspend under Windows.
-  (add-hook 'suspend-hook 'x-win-suspend-error)
+  (add-hook 'suspend-hook #'w32-win-suspend-error)
 
   ;; Turn off window-splitting optimization; w32 is usually fast enough
   ;; that this is only annoying.

=== modified file 'lisp/term/x-win.el'
--- a/lisp/term/x-win.el        2014-10-01 22:13:11 +0000
+++ b/lisp/term/x-win.el        2014-10-02 03:19:32 +0000
@@ -1290,16 +1290,9 @@
 ;; Arrange for the kill and yank functions to set and check the clipboard.
 (setq interprogram-paste-function 'x-selection-value)
 
-;; Make paste from other applications use the decoding in x-select-request-type
-;; and not just STRING.
-(defun x-get-selection-value ()
-  "Get the current value of the PRIMARY selection.
-Request data types in the order specified by `x-select-request-type'."
-  (x-selection-value-internal 'PRIMARY))
-
 (defun x-clipboard-yank ()
-  ;; FIXME: How is that different from `clipboard-yank'?
   "Insert the clipboard contents, or the last stretch of killed text."
+  (declare (obsolete clipboard-yank "25.1"))
   (interactive "*")
   (let ((clipboard-text (x-selection-value-internal 'CLIPBOARD))
        (x-select-enable-clipboard t))
@@ -1325,9 +1318,9 @@
 
 (defun x-win-suspend-error ()
   "Report an error when a suspend is attempted.
-This returns an error if any Emacs frames are X frames, or always under W32."
+This returns an error if any Emacs frames are X frames."
   ;; Don't allow suspending if any of the frames are X frames.
-  (if (memq 'x (mapcar 'window-system (frame-list)))
+  (if (memq 'x (mapcar #'window-system (frame-list)))
       (error "Cannot suspend Emacs while running under X")))
 
 (defvar x-initialized nil
@@ -1469,15 +1462,19 @@
 (gui-method-define gui-select-text x
                    (lambda (text)
                      (when x-select-enable-primary
-                       (x-set-selection 'PRIMARY text)
+                       (gui-set-selection 'PRIMARY text)
                        (setq x-last-selected-text-primary text))
                      (when x-select-enable-clipboard
                        ;; When cutting, the selection is cleared and PRIMARY
                        ;; set to the empty string.  Prevent that, PRIMARY
                        ;; should not be reset by cut (Bug#16382).
                        (setq saved-region-selection text)
-                       (x-set-selection 'CLIPBOARD text)
+                       (gui-set-selection 'CLIPBOARD text)
                        (setq x-last-selected-text-clipboard text))))
+(gui-method-define gui-own-selection x #'x-own-selection-internal)
+(gui-method-define gui-disown-selection x #'x-disown-selection-internal)
+(gui-method-define gui-selection-owner-p x #'x-selection-owner-p)
+(gui-method-define gui-get-selection x #'x-get-selection-internal)
 
 ;; Initiate drag and drop
 (add-hook 'after-make-frame-functions 'x-dnd-init-frame)

=== modified file 'lisp/w32-common-fns.el'
--- a/lisp/w32-common-fns.el    2014-10-01 22:13:11 +0000
+++ b/lisp/w32-common-fns.el    2014-10-02 03:19:32 +0000
@@ -41,53 +41,23 @@
 (declare-function x-server-version "w32fns.c" (&optional display))
 
 ;;; Fix interface to (X-specific) mouse.el
-(defun x-set-selection (type data)
-  "Make an X selection of type TYPE and value DATA.
-The argument TYPE (nil means `PRIMARY') says which selection, and
-DATA specifies the contents.  TYPE must be a symbol.  \(It can also
-be a string, which stands for the symbol with that name, but this
-is considered obsolete.)  DATA may be a string, a symbol, an
-integer (or a cons of two integers or list of two integers).
-
-The selection may also be a cons of two markers pointing to the same buffer,
-or an overlay.  In these cases, the selection is considered to be the text
-between the markers *at whatever time the selection is examined*.
-Thus, editing done in the buffer after you specify the selection
-can alter the effective value of the selection.
-
-The data may also be a vector of valid non-vector selection values.
-
-The return value is DATA.
-
-Interactively, this command sets the primary selection.  Without
-prefix argument, it reads the selection in the minibuffer.  With
-prefix argument, it uses the text of the region as the selection value.
-
-Note that on MS-Windows, primary and secondary selections set by Emacs
-are not available to other programs."
-  (put 'x-selections (or type 'PRIMARY) data))
-
-(defun x-get-selection (&optional type _data-type)
-  "Return the value of an X Windows selection.
-The argument TYPE (default `PRIMARY') says which selection,
-and the argument DATA-TYPE (default `STRING') says
-how to convert the data.
-
-TYPE may be any symbol \(but nil stands for `PRIMARY').  However,
-only a few symbols are commonly used.  They conventionally have
-all upper-case names.  The most often used ones, in addition to
-`PRIMARY', are `SECONDARY' and `CLIPBOARD'.
-
-DATA-TYPE is usually `STRING', but can also be one of the symbols
-in `selection-converter-alist', which see.  This argument is
-ignored on MS-Windows and MS-DOS."
-  (get 'x-selections (or type 'PRIMARY)))
-
-;; x-selection-owner-p is used in simple.el
-(defun x-selection-owner-p (&optional selection _terminal)
-  "" ; placeholder for doc.c
-  (and (memq selection '(nil PRIMARY SECONDARY))
-       (get 'x-selections (or selection 'PRIMARY))))
+(gui-method-define gui-own-selection w32
+                   (lambda (type value)
+                     (put 'x-selections (or type 'PRIMARY) data)))
+
+(gui-method-define gui-disown-selection w32
+                   (lambda (type &optional _time-object _frame)
+                     (put 'x-selections (or type 'PRIMARY) nil)))
+
+(gui-method-define gui-get-selection w32
+                   (lambda (&optional type _data-type)
+                     (get 'x-selections (or type 'PRIMARY))))
+
+;; gui-selection-owner-p is used in simple.el
+(gui-method-define gui-selection-owner-p w32
+                   (lambda (selection)
+                     (and (memq selection '(nil PRIMARY SECONDARY))
+                          (get 'x-selections (or selection 'PRIMARY)))))
 
 ;; The "Windows" keys on newer keyboards bring up the Start menu
 ;; whether you want it or not - make Emacs ignore these keystrokes
@@ -103,30 +73,29 @@
 ;; We keep track of the last text selected here, so we can check the
 ;; current selection against it, and avoid passing back our own text
 ;; from x-selection-value.
-(defvar x-last-selected-text nil)
 
-(defun x-get-selection-value ()
+(defun w32-get-selection-value ()
   "Return the value of the current selection.
 Consult the selection.  Treat empty strings as if they were unset."
   (if gui-select-enable-clipboard
-      (let (text)
-       ;; Don't die if x-get-selection signals an error.
-       (with-demoted-errors "w32-get-clipboard-data:%s"
-         (setq text (w32-get-clipboard-data)))
+      (let ((text
+             ;; Don't die if x-get-selection signals an error.
+             (with-demoted-errors "w32-get-clipboard-data:%S"
+               (w32-get-clipboard-data))))
        (if (string= text "") (setq text nil))
        (cond
         ((not text) nil)
-        ((eq text x-last-selected-text) nil)
-        ((string= text x-last-selected-text)
+        ((eq text gui-last-selected-text) nil)
+        ((string= text gui-last-selected-text)
          ;; Record the newer string, so subsequent calls can use the 'eq' test.
-         (setq x-last-selected-text text)
+         (setq gui-last-selected-text text)
          nil)
         (t
-         (setq x-last-selected-text text))))))
+         (setq gui-last-selected-text text))))))
 
-(defalias 'x-selection-value 'x-get-selection-value)
+(defalias 'x-selection-value #'w32-get-selection-value)
 
 ;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-paste-function 'x-get-selection-value)
+(setq interprogram-paste-function #'w32-get-selection-value)
 
 (provide 'w32-common-fns)

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-10-01 22:14:43 +0000
+++ b/src/ChangeLog     2014-10-02 03:19:32 +0000
@@ -1,3 +1,8 @@
+2014-10-02  Stefan Monnier  <address@hidden>
+
+       * nsselect.m (ns-own-selection-internal, ns-disown-selection-internal):
+       Rename from the "x-" prefix.
+
 2014-10-01  Stefan Monnier  <address@hidden>
 
        * xselect.c (selection-converter-alist): Fix docstring.

=== modified file 'src/nsselect.m'
--- a/src/nsselect.m    2014-05-05 17:37:43 +0000
+++ b/src/nsselect.m    2014-10-02 03:19:32 +0000
@@ -328,19 +328,14 @@
    ========================================================================== 
*/
 
 
-DEFUN ("x-own-selection-internal", Fx_own_selection_internal,
-       Sx_own_selection_internal, 2, 3, 0,
+DEFUN ("ns-own-selection-internal", Fns_own_selection_internal,
+       Sns_own_selection_internal, 2, 2, 0,
        doc: /* Assert an X selection of type SELECTION and value VALUE.
 SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
 \(Those are literal upper-case symbol names, since that's what X expects.)
 VALUE is typically a string, or a cons of two markers, but may be
-anything that the functions on `selection-converter-alist' know about.
-
-FRAME should be a frame that should own the selection.  If omitted or
-nil, it defaults to the selected frame.
-
-On Nextstep, FRAME is unused.  */)
-     (Lisp_Object selection, Lisp_Object value, Lisp_Object frame)
+anything that the functions on `selection-converter-alist' know about.  */)
+     (Lisp_Object selection, Lisp_Object value)
 {
   id pb;
   Lisp_Object old_value, new_value;
@@ -385,21 +380,11 @@
 }
 
 
-DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal,
-       Sx_disown_selection_internal, 1, 3, 0,
+DEFUN ("ns-disown-selection-internal", Fns_disown_selection_internal,
+       Sns_disown_selection_internal, 1, 1, 0,
        doc: /* If we own the selection SELECTION, disown it.
-Disowning it means there is no such selection.
-
-Sets the last-change time for the selection to TIME-OBJECT (by default
-the time of the last event).
-
-TERMINAL should be a terminal object or a frame specifying the X
-server to query.  If omitted or nil, that stands for the selected
-frame's display, or the first available X display.
-
-On Nextstep, the TIME-OBJECT and TERMINAL arguments are unused.
-On MS-DOS, all this does is return non-nil if we own the selection.  */)
-  (Lisp_Object selection, Lisp_Object time_object, Lisp_Object terminal)
+Disowning it means there is no such selection.  */)
+  (Lisp_Object selection)
 {
   id pb;
   check_window_system (NULL);
@@ -443,7 +428,7 @@
 }
 
 
-DEFUN ("x-selection-owner-p", Fx_selection_owner_p, Sx_selection_owner_p,
+DEFUN ("ns-selection-owner-p", Fns_selection_owner_p, Sns_selection_owner_p,
        0, 2, 0,
        doc: /* Whether the current Emacs process owns the given X Selection.
 The arg should be the name of the selection in question, typically one of
@@ -507,7 +492,7 @@
 DEFUN ("ns-get-selection-internal", Fns_get_selection_internal,
        Sns_get_selection_internal, 1, 1, 0,
        doc: /* Returns the value of SELECTION as a string.
-SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
+SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.  */)
      (Lisp_Object selection)
 {
   id pb;
@@ -520,7 +505,7 @@
 DEFUN ("ns-store-selection-internal", Fns_store_selection_internal,
        Sns_store_selection_internal, 2, 2, 0,
        doc: /* Sets the string value of SELECTION.
-SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
+SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.  */)
      (Lisp_Object selection, Lisp_Object string)
 {
   id pb;
@@ -546,11 +531,11 @@
   QTEXT      = intern_c_string ("TEXT");       staticpro (&QTEXT);
   QFILE_NAME = intern_c_string ("FILE_NAME");  staticpro (&QFILE_NAME);
 
-  defsubr (&Sx_disown_selection_internal);
+  defsubr (&Sns_disown_selection_internal);
   defsubr (&Sx_get_selection_internal);
-  defsubr (&Sx_own_selection_internal);
+  defsubr (&Sns_own_selection_internal);
   defsubr (&Sx_selection_exists_p);
-  defsubr (&Sx_selection_owner_p);
+  defsubr (&Sns_selection_owner_p);
   defsubr (&Sns_get_selection_internal);
   defsubr (&Sns_store_selection_internal);
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]