From a8b36b953e3dc4d50dbfe430d5c579f7b1fd71e7 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 1 Oct 2014 18:13:11 -0400 Subject: 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. --- lisp/term/ns-win.el | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'lisp/term/ns-win.el') 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) -- cgit v1.2.1