summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/emacs-lisp/cl-lib.el1
-rw-r--r--lisp/eshell/esh-io.el6
-rw-r--r--lisp/frame.el49
-rw-r--r--lisp/loadup.el2
-rw-r--r--lisp/menu-bar.el10
-rw-r--r--lisp/select.el35
-rw-r--r--lisp/simple.el4
-rw-r--r--lisp/startup.el39
-rw-r--r--lisp/subr.el15
-rw-r--r--lisp/term/common-win.el64
-rw-r--r--lisp/term/ns-win.el25
-rw-r--r--lisp/term/pc-win.el69
-rw-r--r--lisp/term/w32-win.el15
-rw-r--r--lisp/term/x-win.el24
-rw-r--r--lisp/w32-common-fns.el4
-rw-r--r--src/xselect.c4
17 files changed, 182 insertions, 191 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 8c2b64b14fc..ddcd70cb11a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -49,6 +49,9 @@ Use './configure PKG_CONFIG=/full/name/of/pkg-config' if you need to.
* 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 @@ Emacs-21.
* 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).
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 09cc3eee985..c7d21c76fc1 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -701,7 +701,6 @@ If ALIST is non-nil, the new pairs are prepended to it."
(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.
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el
index b7830db08b5..ebbca58a442 100644
--- a/lisp/eshell/esh-io.el
+++ b/lisp/eshell/esh-io.el
@@ -118,8 +118,6 @@ from executing while Emacs is redisplaying."
: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 @@ from executing while Emacs is redisplaying."
'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 @@ last execution result should not be changed."
(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)
diff --git a/lisp/frame.el b/lisp/frame.el
index f144cf23405..18aff5b2879 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -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 @@ the new frame according to its own rules."
((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 @@ the new frame according to its own rules."
(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 @@ the new frame according to its own rules."
(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)
diff --git a/lisp/loadup.el b/lisp/loadup.el
index c1206e243c5..9c052b284b8 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -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'
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 9657c5924f9..35f996c5750 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -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 ()
diff --git a/lisp/select.el b/lisp/select.el
index c4d020343af..c32b45f1c85 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -77,6 +77,41 @@ After the communication, this variable is set to nil.")
;; 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,
diff --git a/lisp/simple.el b/lisp/simple.el
index 8469ff0d892..8504cf4be19 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3629,7 +3629,7 @@ No filtering is done unless a hook says to."
;;;; 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 @@ put in the kill ring, to make the new kill available to other
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
diff --git a/lisp/startup.el b/lisp/startup.el
index c46200a050d..a0bcd1fcaba 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -421,21 +421,6 @@ Warning Warning!!! Pure space overflow !!!Warning Warning
: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 @@ It is the default value of the variable `top-level'."
(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 @@ please check its value")
;; 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 @@ the `--debug-init' option to view a complete error backtrace."
(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))
diff --git a/lisp/subr.el b/lisp/subr.el
index 581e52e8f9d..2435285bf0f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4800,6 +4800,21 @@ which is higher than \"1alpha\", which is higher than \"1snapshot\".
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 '("--")
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index ba59c75c4ec..fcb9fd55bb1 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -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 @@ is not used)."
(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.
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 47d953aebfb..fc13a2c5ddf 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -739,7 +739,6 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; 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 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(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 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; 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)
diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el
index f24a54fbe28..264d881bc15 100644
--- a/lisp/term/pc-win.el
+++ b/lisp/term/pc-win.el
@@ -219,44 +219,10 @@ the operating system.")
;
;;;; 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 @@ Consult the selection. Treat empty strings as if they were unset."
(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 @@ frame's display, or the first available X display.
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 @@ On Nextstep, TERMINAL is unused.
;; 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 @@ Errors out because it is not supposed to be called, ever."
(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))))
;; ---------------------------------------------------------------------------
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index e103562ba7a..3eb8e69c28d 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -371,9 +371,18 @@ This returns an error if any Emacs frames are X frames, or always under W32."
(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)
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 964b9112553..daaef61e494 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1217,8 +1217,6 @@ The value nil is the same as the list (UTF8_STRING COMPOUND_TEXT STRING)."
(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 @@ The value nil is the same as the list (UTF8_STRING COMPOUND_TEXT STRING)."
'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 @@ 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."
(interactive "*")
(let ((clipboard-text (x-selection-value-internal 'CLIPBOARD))
@@ -1463,9 +1461,23 @@ This returns an error if any Emacs frames are X frames, or always under W32."
(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)
diff --git a/lisp/w32-common-fns.el b/lisp/w32-common-fns.el
index d149500c327..343a4c25895 100644
--- a/lisp/w32-common-fns.el
+++ b/lisp/w32-common-fns.el
@@ -104,12 +104,11 @@ ignored on MS-Windows and MS-DOS."
;; 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 @@ Consult the selection. Treat empty strings as if they were unset."
(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)
diff --git a/src/xselect.c b/src/xselect.c
index 0e8a43717e0..a06243f5924 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2638,12 +2638,14 @@ syms_of_xselect (void)
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