emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r118002: Consolidate x-select-text.


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r118002: Consolidate x-select-text.
Date: Wed, 01 Oct 2014 22:13:32 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 118002
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2014-10-01 18:13:11 -0400
message:
  Consolidate x-select-text.
  * lisp/frame.el (gui-method, gui-method-define, gui-method-declare)
  (gui-call): New macros.
  (gui-method--name): New function.
  (frame-creation-function-alist): Use gui-method-declare.
  (make-frame): Use gui-method.
  * lisp/select.el (gui-select-enable-clipboard): Rename from
  x-select-enable-clipboard and move here.
  (x-select-enable-clipboard): Define as obsolete alias.
  (gui-last-selected-text): New var, to replace x-last-selected-text.
  (gui-select-text): New GUI method.
  (gui-select-text): New function.
  (x-select-text): Define as obsolete alias.
  * lisp/term/common-win.el (x-select-enable-clipboard, x-select-text):
  Move to select.el.
  * lisp/simple.el (interprogram-cut-function): Change default to
  x-select-text.
  (interprogram-paste-function): Change default to `ignore'.
  * lisp/w32-common-fns.el (interprogram-cut-function): Don't modify.
  * lisp/term/x-win.el (interprogram-cut-function): Don't modify.
  (gui-select-text): Add method for x.
  * lisp/term/w32-win.el (gui-select-text): Add method for w32.
  * lisp/term/pc-win.el (x-last-selected-text): Remove, use
  gui-last-selected-text instead.
  (msdos-initialize-window-system): Don't set interprogram-cut-function.
  (gui-select-text): Add method for pc.
  * lisp/term/ns-win.el (ns-last-selected-text): Remove, use
  gui-last-selected-text instead.
  (gui-select-text): Add method for ns.
  (x-setup-function-keys): Don't change interprogram-cut-function.
  * lisp/loadup.el ("startup"): Load after "frame".
  * lisp/subr.el (package--builtin-versions, package--description-file):
  Move from startup.el.
  * lisp/startup.el (package--builtin-versions, package--description-file):
  Move to subr.el.
  (handle-args-function-alist, window-system-initialization-alist):
  Use gui-method-declare.
  (command-line): Use gui-method.
  * src/xselect.c (selection-converter-alist): Fix docstring.
modified:
  etc/NEWS                       news-20100311060928-aoit31wvzf25yr1z-1
  lisp/emacs-lisp/cl-lib.el      cl.el-20091113204419-o5vbwnq5f7feedwu-614
  lisp/eshell/esh-io.el          eshio.el-20091113204419-o5vbwnq5f7feedwu-1870
  lisp/frame.el                  frame.el-20091113204419-o5vbwnq5f7feedwu-275
  lisp/loadup.el                 loadup.el-20091113204419-o5vbwnq5f7feedwu-49
  lisp/menu-bar.el               menubar.el-20091113204419-o5vbwnq5f7feedwu-546
  lisp/select.el                 select.el-20091113204419-o5vbwnq5f7feedwu-550
  lisp/simple.el                 simple.el-20091113204419-o5vbwnq5f7feedwu-403
  lisp/startup.el                startup.el-20091113204419-o5vbwnq5f7feedwu-260
  lisp/subr.el                   subr.el-20091113204419-o5vbwnq5f7feedwu-151
  lisp/term/common-win.el        
commonwin.el-20091113204419-o5vbwnq5f7feedwu-8752
  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/xselect.c                  xselect.c-20091113204419-o5vbwnq5f7feedwu-543
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2014-10-01 17:23:42 +0000
+++ b/etc/NEWS  2014-10-01 22:13:11 +0000
@@ -49,6 +49,9 @@
 
 * Changes in Emacs 25.1
 
+** x-select-enable-clipboard is renamed gui-select-enable-clipboard.
+Additionally it now also applies to OSX and GNUstep.
+
 ** `insert-register' now leaves point after the inserted text
 when called interactively.  A prefix argument toggles this behavior.
 
@@ -242,7 +245,9 @@
 
 * Lisp Changes in Emacs 25.1
 
-*** call-process-shell-command and process-file-shell-command
+** x-select-text is renamed gui-select-text.
+
+** call-process-shell-command and process-file-shell-command
 don't take "&rest args" any more.
 
 ** New function `alist-get', which is also a valid place (aka lvalue).

=== modified file 'lisp/emacs-lisp/cl-lib.el'
--- a/lisp/emacs-lisp/cl-lib.el 2014-09-26 00:15:21 +0000
+++ b/lisp/emacs-lisp/cl-lib.el 2014-10-01 22:13:11 +0000
@@ -701,7 +701,6 @@
 (gv-define-setter window-width (store)
   `(progn (enlarge-window (- ,store (window-width)) t) ,store))
 (gv-define-simple-setter x-get-secondary-selection x-own-secondary-selection t)
-(gv-define-simple-setter x-get-selection x-own-selection t)
 
 ;; More complex setf-methods.
 

=== modified file 'lisp/eshell/esh-io.el'
--- a/lisp/eshell/esh-io.el     2014-01-01 07:43:34 +0000
+++ b/lisp/eshell/esh-io.el     2014-10-01 22:13:11 +0000
@@ -118,8 +118,6 @@
   :type 'integer
   :group 'eshell-io)
 
-(defvar x-select-enable-clipboard)     ; term/common-win
-
 (defcustom eshell-virtual-targets
   '(("/dev/eshell" eshell-interactive-print nil)
     ("/dev/kill" (lambda (mode)
@@ -128,7 +126,7 @@
                   'eshell-kill-append) t)
     ("/dev/clip" (lambda (mode)
                   (if (eq mode 'overwrite)
-                      (let ((x-select-enable-clipboard t))
+                      (let ((gui-select-enable-clipboard t))
                         (kill-new "")))
                   'eshell-clipboard-append) t))
   "Map virtual devices name to Emacs Lisp functions.
@@ -328,7 +326,7 @@
 (defun eshell-clipboard-append (string)
   "Call `kill-append' with STRING, if it is indeed a string."
   (if (stringp string)
-      (let ((x-select-enable-clipboard t))
+      (let ((gui-select-enable-clipboard t))
        (kill-append string nil))))
 
 (defun eshell-get-target (target &optional mode)

=== modified file 'lisp/frame.el'
--- a/lisp/frame.el     2014-09-03 15:10:29 +0000
+++ b/lisp/frame.el     2014-10-01 22:13:11 +0000
@@ -26,21 +26,39 @@
 ;;; Code:
 (eval-when-compile (require 'cl-lib))
 
-(defvar frame-creation-function-alist
-  (list (cons nil
-             (if (fboundp 'tty-create-frame-with-faces)
-                 'tty-create-frame-with-faces
-                (lambda (_parameters)
-                  (error "Can't create multiple frames without a window 
system")))))
-  "Alist of window-system dependent functions to call to create a new frame.
+;; Dispatch tables for GUI methods.
+
+(defun gui-method--name (base)
+  (intern (format "%s-alist" base)))
+
+(defmacro gui-method (name &optional type)
+  (macroexp-let2 nil type (or type `(framep (selected-frame)))
+    `(alist-get ,type ,(gui-method--name name)
+                (lambda (&rest _args)
+                  (error "No method %S for %S frame" ',name ,type)))))
+
+(defmacro gui-method-define (name type fun)
+  `(setf (gui-method ,name ',type) ,fun))
+
+(defmacro gui-method-declare (name &optional tty-fun doc)
+  (declare (doc-string 3) (indent 2))
+  `(defvar ,(gui-method--name name)
+     ,(if tty-fun `(list (cons t ,tty-fun))) ,doc))
+
+(defmacro gui-call (name &rest args)
+  `(funcall (gui-method ,name) ,@args))
+
+(gui-method-declare frame-creation-function
+    #'tty-create-frame-with-faces
+  "Method for window-system dependent functions to create a new frame.
 The window system startup file should add its frame creation
-function to this list, which should take an alist of parameters
+function to this method, which should take an alist of parameters
 as its argument.")
 
 (defvar window-system-default-frame-alist nil
   "Window-system dependent default frame parameters.
 The value should be an alist of elements (WINDOW-SYSTEM . ALIST),
-where WINDOW-SYSTEM is a window system symbol (see `window-system')
+where WINDOW-SYSTEM is a window system symbol (as returned by `framep')
 and ALIST is a frame parameter alist like `default-frame-alist'.
 Then, for frames on WINDOW-SYSTEM, any parameters specified in
 ALIST supersede the corresponding parameters specified in
@@ -632,9 +650,8 @@
             ((assq 'terminal parameters)
              (let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
                (cond
-                ((eq type t) nil)
-                ((eq type nil) (error "Terminal %s does not exist"
-                                       (cdr (assq 'terminal parameters))))
+                ((null type) (error "Terminal %s does not exist"
+                                     (cdr (assq 'terminal parameters))))
                 (t type))))
             ((assq 'window-system parameters)
              (cdr (assq 'window-system parameters)))
@@ -643,15 +660,12 @@
                   (error "Don't know how to interpret display %S"
                          display)))
             (t window-system)))
-        (frame-creation-function (cdr (assq w frame-creation-function-alist)))
         (oldframe (selected-frame))
         (params parameters)
         frame)
-    (unless frame-creation-function
-      (error "Don't know how to create a frame on window system %s" w))
 
     (unless (get w 'window-system-initialized)
-      (funcall (cdr (assq w window-system-initialization-alist)) display)
+      (funcall (gui-method window-system-initialization w) display)
       (setq x-display-name display)
       (put w 'window-system-initialized t))
 
@@ -665,7 +679,8 @@
        (push p params)))
     ;; Now make the frame.
     (run-hooks 'before-make-frame-hook)
-    (setq frame (funcall frame-creation-function params))
+    (setq frame
+          (funcall (gui-method frame-creation-function w) params))
     (normal-erase-is-backspace-setup-frame frame)
     ;; Inherit the original frame's parameters.
     (dolist (param frame-inherited-parameters)

=== modified file 'lisp/loadup.el'
--- a/lisp/loadup.el    2014-09-27 03:57:41 +0000
+++ b/lisp/loadup.el    2014-10-01 22:13:11 +0000
@@ -126,7 +126,6 @@
 (load "faces")  ; after here, `defface' may be used.
 
 (load "button")
-(load "startup")
 
 ;; We don't want to store loaddefs.el in the repository because it is
 ;; a generated file; but it is required in order to compile the lisp files.
@@ -193,6 +192,7 @@
 
 (load "indent")
 (load "frame")
+(load "startup")
 (load "term/tty-colors")
 (load "font-core")
 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'

=== modified file 'lisp/menu-bar.el'
--- a/lisp/menu-bar.el  2014-09-05 10:29:34 +0000
+++ b/lisp/menu-bar.el  2014-10-01 22:13:11 +0000
@@ -545,19 +545,19 @@
 (defun clipboard-yank ()
   "Insert the clipboard contents, or the last stretch of killed text."
   (interactive "*")
-  (let ((x-select-enable-clipboard t))
+  (let ((gui-select-enable-clipboard t))
     (yank)))
 
 (defun clipboard-kill-ring-save (beg end &optional region)
-  "Copy region to kill ring, and save in the X clipboard."
+  "Copy region to kill ring, and save in the GUI's clipboard."
   (interactive "r\np")
-  (let ((x-select-enable-clipboard t))
+  (let ((gui-select-enable-clipboard t))
     (kill-ring-save beg end region)))
 
 (defun clipboard-kill-region (beg end &optional region)
-  "Kill the region, and save it in the X clipboard."
+  "Kill the region, and save it in the GUI's clipboard."
   (interactive "r\np")
-  (let ((x-select-enable-clipboard t))
+  (let ((gui-select-enable-clipboard t))
     (kill-region beg end region)))
 
 (defun menu-bar-enable-clipboard ()

=== modified file 'lisp/select.el'
--- a/lisp/select.el    2014-02-10 17:05:52 +0000
+++ b/lisp/select.el    2014-10-01 22:13:11 +0000
@@ -77,6 +77,41 @@
 ;; Only declared obsolete in 23.3.
 (define-obsolete-function-alias 'x-selection 'x-get-selection "at least 19.34")
 
+(defcustom gui-select-enable-clipboard t
+  "Non-nil means cutting and pasting uses the clipboard.
+This can be in addition to, but in preference to, the primary selection,
+if applicable (i.e. under X11)."
+  :type 'boolean
+  :group 'killing
+  ;; The GNU/Linux version changed in 24.1, the MS-Windows version did not.
+  :version "24.1")
+(define-obsolete-variable-alias 'x-select-enable-clipboard
+  'gui-select-enable-clipboard "25.1")
+
+(gui-method-declare gui-select-text #'ignore
+  "Method used to pass the current selection to the system.
+Called with one argument (the text selected).
+Should obey `gui-select-enable-clipboard' where applicable.")
+
+(defvar gui-last-selected-text nil
+  "Last text passed to `gui-select-text'.")
+
+(defun gui-select-text (text)
+  "Select TEXT, a string, according to the window system.
+if `gui-select-enable-clipboard' is non-nil, copy TEXT to the system's 
clipboard.
+
+On X, if `x-select-enable-primary' is non-nil, put TEXT in
+the primary selection.
+
+On MS-Windows, make TEXT the current selection."
+  ;; FIXME: We should test gui-select-enable-clipboard here!
+  ;; But that would break the independence between x-select-enable-primary
+  ;; and x-select-enable-clipboard!
+  ;;(when gui-select-enable-clipboard
+    (gui-call gui-select-text text) ;;)
+  (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)
   "Return the value of an X Windows selection.
 The argument TYPE (default `PRIMARY') says which selection,

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2014-09-29 18:14:08 +0000
+++ b/lisp/simple.el    2014-10-01 22:13:11 +0000
@@ -3629,7 +3629,7 @@
 
 ;;;; Window system cut and paste hooks.
 
-(defvar interprogram-cut-function nil
+(defvar interprogram-cut-function #'x-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
@@ -3640,7 +3640,7 @@
 programs.  The function takes one argument, TEXT, which is a
 string containing the text which should be made available.")
 
-(defvar interprogram-paste-function nil
+(defvar interprogram-paste-function #'ignore
   "Function to call to get text cut from other programs.
 Most window systems provide a facility for cutting and pasting
 text between different programs, such as the clipboard on X and

=== modified file 'lisp/startup.el'
--- a/lisp/startup.el   2014-09-03 04:21:40 +0000
+++ b/lisp/startup.el   2014-10-01 22:13:11 +0000
@@ -421,21 +421,6 @@
   :type 'directory
   :initialize 'custom-initialize-delay)
 
-(defvar package--builtin-versions
-  ;; Mostly populated by loaddefs.el via autoload-builtin-package-versions.
-  (purecopy `((emacs . ,(version-to-list emacs-version))))
-  "Alist giving the version of each versioned builtin package.
-I.e. each element of the list is of the form (NAME . VERSION) where
-NAME is the package name as a symbol, and VERSION is its version
-as a list.")
-
-(defun package--description-file (dir)
-  (concat (let ((subdir (file-name-nondirectory
-                         (directory-file-name dir))))
-            (if (string-match 
"\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)"
 subdir)
-                (match-string 1 subdir) subdir))
-          "-pkg.el"))
-
 (defun normal-top-level-add-subdirs-to-load-path ()
   "Add all subdirectories of `default-directory' to `load-path'.
 More precisely, this uses only the subdirectories whose names
@@ -719,17 +704,17 @@
 (defconst tool-bar-images-pixel-height 24
   "Height in pixels of images in the tool-bar.")
 
-(defvar handle-args-function-alist '((nil . tty-handle-args))
-  "Functions for processing window-system dependent command-line arguments.
+(gui-method-declare handle-args-function #'tty-handle-args
+  "Method for processing window-system dependent command-line arguments.
 Window system startup files should add their own function to this
-alist, which should parse the command line arguments.  Those
+method, which should parse the command line arguments.  Those
 pertaining to the window system should be processed and removed
 from the returned command line.")
 
-(defvar window-system-initialization-alist '((nil . ignore))
-  "Alist of window-system initialization functions.
-Window-system startup files should add their own initialization
-function to this list.  The function should take no arguments,
+(gui-method-declare window-system-initialization #'ignore
+  "Method for window-system initialization.
+Window-system startup files should add their own implementation
+to this method.  The function should take no arguments,
 and initialize the window system environment to prepare for
 opening the first frame (e.g. open a connection to an X server).")
 
@@ -965,8 +950,7 @@
       ;; Process window-system specific command line parameters.
       (setq command-line-args
            (funcall
-            (or (cdr (assq initial-window-system handle-args-function-alist))
-                (error "Unsupported window system `%s'" initial-window-system))
+             (gui-method handle-args-function (or initial-window-system t))
             command-line-args))
       ;; Initialize the window system. (Open connection, etc.)
       (funcall
@@ -1311,9 +1295,10 @@
                            (format "Your `load-path' seems to contain
 your `.emacs.d' directory: %s\n\
 This is likely to cause problems...\n\
-Consider using a subdirectory instead, e.g.: %s" dir
-(expand-file-name "lisp" user-emacs-directory))
-                            :warning))))
+Consider using a subdirectory instead, e.g.: %s"
+                                    dir (expand-file-name
+                                         "lisp" user-emacs-directory))
+                            :warning))))
 
   ;; If -batch, terminate after processing the command options.
   (if noninteractive (kill-emacs t))

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2014-10-01 17:23:42 +0000
+++ b/lisp/subr.el      2014-10-01 22:13:11 +0000
@@ -4800,6 +4800,21 @@
 Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
   (version-list-= (version-to-list v1) (version-to-list v2)))
 
+(defvar package--builtin-versions
+  ;; Mostly populated by loaddefs.el via autoload-builtin-package-versions.
+  (purecopy `((emacs . ,(version-to-list emacs-version))))
+  "Alist giving the version of each versioned builtin package.
+I.e. each element of the list is of the form (NAME . VERSION) where
+NAME is the package name as a symbol, and VERSION is its version
+as a list.")
+
+(defun package--description-file (dir)
+  (concat (let ((subdir (file-name-nondirectory
+                         (directory-file-name dir))))
+            (if (string-match 
"\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)"
 subdir)
+                (match-string 1 subdir) subdir))
+          "-pkg.el"))
+
 
 ;;; Misc.
 (defconst menu-bar-separator '("--")

=== modified file 'lisp/term/common-win.el'
--- a/lisp/term/common-win.el   2014-02-10 01:34:22 +0000
+++ b/lisp/term/common-win.el   2014-10-01 22:13:11 +0000
@@ -24,67 +24,6 @@
 
 ;;; Code:
 
-(defcustom x-select-enable-clipboard t
-  "Non-nil means cutting and pasting uses the clipboard.
-This is in addition to, but in preference to, the primary selection.
-
-Note that MS-Windows does not support selection types other than the
-clipboard.  (The primary selection that is set by Emacs is not
-accessible to other programs on MS-Windows.)
-
-This variable is not used by the Nextstep port."
-  :type 'boolean
-  :group 'killing
-  ;; The GNU/Linux version changed in 24.1, the MS-Windows version did not.
-  :version "24.1")
-
-(defvar x-last-selected-text)          ; w32-fns.el
-(declare-function w32-set-clipboard-data "w32select.c"
-                 (string &optional ignored))
-(defvar ns-last-selected-text)         ; ns-win.el
-(declare-function ns-set-pasteboard "ns-win" (string))
-
-(defvar x-select-enable-primary)       ; x-win.el
-(defvar x-last-selected-text-primary)
-(defvar x-last-selected-text-clipboard)
-(defvar saved-region-selection)        ; simple.el
-
-(defun x-select-text (text)
-  "Select TEXT, a string, according to the window system.
-
-On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the
-clipboard.  If `x-select-enable-primary' is non-nil, put TEXT in
-the primary selection.
-
-On MS-Windows, make TEXT the current selection.  If
-`x-select-enable-clipboard' is non-nil, copy the text to the
-clipboard as well.
-
-On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard'
-is not used)."
-  (cond ((eq (framep (selected-frame)) 'w32)
-        (if x-select-enable-clipboard
-            (w32-set-clipboard-data text))
-        (setq x-last-selected-text text))
-       ((featurep 'ns)
-        ;; Don't send the pasteboard too much text.
-        ;; It becomes slow, and if really big it causes errors.
-        (ns-set-pasteboard text)
-        (setq ns-last-selected-text text))
-       (t
-        ;; With multi-tty, this function may be called from a tty frame.
-        (when (eq (framep (selected-frame)) 'x)
-          (when x-select-enable-primary
-            (x-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)
-            (setq x-last-selected-text-clipboard text))))))
-
 ;;;; Function keys
 
 (defvar x-alternatives-map
@@ -117,8 +56,7 @@
         (set-keymap-parent map (keymap-parent local-function-key-map))
         (set-keymap-parent local-function-key-map map))
       (when (featurep 'ns)
-       (setq interprogram-cut-function 'x-select-text
-             interprogram-paste-function 'x-selection-value
+       (setq interprogram-paste-function 'x-selection-value
              system-key-alist
              (list
               ;; These are special "keys" used to pass events from C to lisp.

=== modified file 'lisp/term/ns-win.el'
--- a/lisp/term/ns-win.el       2014-03-15 18:12:54 +0000
+++ b/lisp/term/ns-win.el       2014-10-01 22:13:11 +0000
@@ -739,7 +739,6 @@
 ;; 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 ns-last-selected-text nil)
 
 ;; Return the value of the current Nextstep selection.  For
 ;; compatibility with older Nextstep applications, this checks cut
@@ -751,13 +750,13 @@
     (if (string= text "") (setq text nil))
     (cond
      ((not text) nil)
-     ((eq text ns-last-selected-text) nil)
-     ((string= text ns-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 ns-last-selected-text text)
+      (setq gui-last-selected-text text)
       nil)
      (t
-      (setq ns-last-selected-text text)))))
+      (setq gui-last-selected-text text)))))
 
 (defun ns-copy-including-secondary ()
   (interactive)
@@ -959,10 +958,18 @@
 
 ;; Any display name is OK.
 (add-to-list 'display-format-alist '(".*" . ns))
-(add-to-list 'handle-args-function-alist '(ns . x-handle-args))
-(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
-(add-to-list 'window-system-initialization-alist '(ns . 
ns-initialize-window-system))
+(gui-method-define handle-args-function ns #'x-handle-args)
+(gui-method-define frame-creation-function ns #'x-create-frame-with-faces)
+(gui-method-define window-system-initialization ns
+                   #'ns-initialize-window-system)
 
+(declare-function ns-set-pasteboard "ns-win" (string))
+(gui-method-define gui-select-text ns
+                   (lambda (text)
+                     ;; Don't send the pasteboard too much text.
+                     ;; It becomes slow, and if really big it causes errors.
+                     (when gui-select-enable-clipboard
+                       (ns-set-pasteboard text))))
 
 (provide 'ns-win)
 

=== modified file 'lisp/term/pc-win.el'
--- a/lisp/term/pc-win.el       2014-04-16 13:27:28 +0000
+++ b/lisp/term/pc-win.el       2014-10-01 22:13:11 +0000
@@ -219,44 +219,10 @@
 ;
 ;;;; Selections
 ;
-;;; 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)
-
-(defcustom x-select-enable-clipboard t
-  "Non-nil means cutting and pasting uses the clipboard.
-This is in addition to, but in preference to, the primary selection.
-
-Note that MS-Windows does not support selection types other than the
-clipboard.  (The primary selection that is set by Emacs is not
-accessible to other programs on MS-Windows.)
-
-This variable is not used by the Nextstep port."
-  :type 'boolean
-  :group 'killing)
-
-(defun x-select-text (text)
-  "Select TEXT, a string, according to the window system.
-
-On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the
-clipboard.  If `x-select-enable-primary' is non-nil, put TEXT in
-the primary selection.
-
-On MS-Windows, make TEXT the current selection.  If
-`x-select-enable-clipboard' is non-nil, copy the text to the
-clipboard as well.
-
-On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard'
-is not used)."
-  (if x-select-enable-clipboard
-      (w16-set-clipboard-data text))
-  (setq x-last-selected-text text))
-
 (defun x-get-selection-value ()
   "Return the value of the current selection.
 Consult the selection.  Treat empty strings as if they were unset."
-  (if x-select-enable-clipboard
+  (if gui-select-enable-clipboard
       (let (text)
        ;; Don't die if x-get-selection signals an error.
        (with-demoted-errors "w16-get-clipboard-data:%s"
@@ -264,13 +230,13 @@
        (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))))))
 
 ;; x-selection-owner-p is used in simple.el.
 (defun x-selection-owner-p (&optional _selection _terminal)
@@ -288,7 +254,7 @@
 On Nextstep, TERMINAL is unused.
 
 \(fn &optional SELECTION TERMINAL)"
-    (if x-select-enable-clipboard
+    (if gui-select-enable-clipboard
       (let (text)
        ;; Don't die if w16-get-clipboard-data signals an error.
        (ignore-errors
@@ -298,8 +264,8 @@
        ;; we've put into the Windows clipboard.
        (cond
         ((not text) t)
-        ((or (eq text x-last-selected-text)
-             (string= text x-last-selected-text))
+        ((or (eq text gui-last-selected-text)
+             (string= text gui-last-selected-text))
          text)
         (t nil)))))
 
@@ -463,20 +429,27 @@
   (setq split-window-keep-point t)
   ;; Arrange for the kill and yank functions to set and check the
   ;; clipboard.
-  (setq interprogram-cut-function 'x-select-text)
   (setq interprogram-paste-function 'x-get-selection-value)
   (menu-bar-enable-clipboard)
   (run-hooks 'terminal-init-msdos-hook))
 
 ;; frame-creation-function-alist is examined by frame.el:make-frame.
-(add-to-list 'frame-creation-function-alist
-            '(pc . msdos-create-frame-with-faces))
+(gui-method-define frame-creation-function
+                   pc #'msdos-create-frame-with-faces)
 ;; window-system-initialization-alist is examined by startup.el:command-line.
-(add-to-list 'window-system-initialization-alist
-            '(pc . msdos-initialize-window-system))
+(gui-method-define window-system-initialization
+                   pc #'msdos-initialize-window-system)
 ;; We don't need anything beyond tty-handle-args for handling
 ;; command-line argument; see startup.el.
-(add-to-list 'handle-args-function-alist '(pc . tty-handle-args))
+(gui-method-define handle-args-function pc #'tty-handle-args)
+
+
+(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))))
 
 ;; ---------------------------------------------------------------------------
 

=== modified file 'lisp/term/w32-win.el'
--- a/lisp/term/w32-win.el      2014-06-18 15:15:52 +0000
+++ b/lisp/term/w32-win.el      2014-10-01 22:13:11 +0000
@@ -371,9 +371,18 @@
   (setq w32-initialized t))
 
 (add-to-list 'display-format-alist '("\\`w32\\'" . w32))
-(add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
-(add-to-list 'frame-creation-function-alist '(w32 . x-create-frame-with-faces))
-(add-to-list 'window-system-initialization-alist '(w32 . 
w32-initialize-window-system))
+(gui-method-define handle-args-function w32 #'x-handle-args)
+(gui-method-define frame-creation-function w32
+                   #'x-create-frame-with-faces)
+(gui-method-define window-system-initialization w32
+                   #'w32-initialize-window-system)
+
+(declare-function w32-set-clipboard-data "w32select.c"
+                 (string &optional ignored))
+(gui-method-define gui-select-text w32
+                   (lambda (text)
+                     (if gui-select-enable-clipboard
+                         (w32-set-clipboard-data text))))
 
 (provide 'w32-win)
 

=== modified file 'lisp/term/x-win.el'
--- a/lisp/term/x-win.el        2014-04-11 07:02:28 +0000
+++ b/lisp/term/x-win.el        2014-10-01 22:13:11 +0000
@@ -1217,8 +1217,6 @@
        (remove-text-properties 0 (length text) '(foreign-selection nil) text))
     text))
 
-(defvar x-select-enable-clipboard)     ; common-win
-
 ;; Return the value of the current X selection.
 ;; Consult the selection.  Treat empty strings as if they were unset.
 ;; If this function is called twice and finds the same text,
@@ -1290,7 +1288,6 @@
   'x-selection-value "24.1")
 
 ;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-cut-function 'x-select-text)
 (setq interprogram-paste-function 'x-selection-value)
 
 ;; Make paste from other applications use the decoding in x-select-request-type
@@ -1301,6 +1298,7 @@
   (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."
   (interactive "*")
   (let ((clipboard-text (x-selection-value-internal 'CLIPBOARD))
@@ -1463,9 +1461,23 @@
   (setq x-initialized t))
 
 (add-to-list 'display-format-alist '("\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" . x))
-(add-to-list 'handle-args-function-alist '(x . x-handle-args))
-(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
-(add-to-list 'window-system-initialization-alist '(x . 
x-initialize-window-system))
+(gui-method-define handle-args-function x #'x-handle-args)
+(gui-method-define frame-creation-function x #'x-create-frame-with-faces)
+(gui-method-define window-system-initialization x #'x-initialize-window-system)
+
+(defvar x-select-enable-primary)       ; x-win.el
+(gui-method-define gui-select-text x
+                   (lambda (text)
+                     (when x-select-enable-primary
+                       (x-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)
+                       (setq x-last-selected-text-clipboard text))))
 
 ;; 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-03-22 00:24:00 +0000
+++ b/lisp/w32-common-fns.el    2014-10-01 22:13:11 +0000
@@ -104,12 +104,11 @@
 ;; current selection against it, and avoid passing back our own text
 ;; from x-selection-value.
 (defvar x-last-selected-text nil)
-(defvar x-select-enable-clipboard)
 
 (defun x-get-selection-value ()
   "Return the value of the current selection.
 Consult the selection.  Treat empty strings as if they were unset."
-  (if x-select-enable-clipboard
+  (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"
@@ -128,7 +127,6 @@
 (defalias 'x-selection-value 'x-get-selection-value)
 
 ;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-cut-function 'x-select-text)
 (setq interprogram-paste-function 'x-get-selection-value)
 
 (provide 'w32-common-fns)

=== modified file 'src/xselect.c'
--- a/src/xselect.c     2014-10-01 03:28:16 +0000
+++ b/src/xselect.c     2014-10-01 22:13:11 +0000
@@ -2638,12 +2638,14 @@
   converted_selections = NULL;
   conversion_fail_tag = None;
 
+  /* FIXME: Duplicate definition in nsselect.c.  */
   DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist,
               doc: /* An alist associating X Windows selection-types with 
functions.
 These functions are called to convert the selection, with three args:
 the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
 a desired type to which the selection should be converted;
-and the local selection value (whatever was given to `x-own-selection').
+and the local selection value (whatever was given to
+`x-own-selection-internal').
 
 The function should return the value to send to the X server
 \(typically a string).  A return value of nil


reply via email to

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