2014-10-23 01:38:59 +00:00
|
|
|
|
;;; select.el --- lisp portion of standard selection support -*- lexical-binding:t -*-
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
|
;; Copyright (C) 1993-1994, 2001-2024 Free Software Foundation, Inc.
|
2010-10-24 02:13:37 +00:00
|
|
|
|
|
2019-05-25 20:43:06 +00:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
1993-03-17 17:19:16 +00:00
|
|
|
|
;; Keywords: internal
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1993-03-17 17:19:16 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2001-07-15 19:53:53 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2010-10-24 02:13:37 +00:00
|
|
|
|
;; Based partially on earlier release by Lucid.
|
|
|
|
|
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
;; The functionality here is divided in two parts:
|
2022-03-13 20:05:18 +00:00
|
|
|
|
;; - Low-level: gui-backend-get-selection, gui-backend-set-selection,
|
|
|
|
|
;; gui-backend-selection-owner-p, gui-backend-selection-exists-p are
|
|
|
|
|
;; the backend-dependent functions meant to access various kinds of
|
|
|
|
|
;; selections (CLIPBOARD, PRIMARY, SECONDARY).
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
;; - Higher-level: gui-select-text and gui-selection-value go together to
|
|
|
|
|
;; access the general notion of "GUI selection" for interoperation with other
|
|
|
|
|
;; applications. This can use either the clipboard or the primary selection,
|
|
|
|
|
;; or both or none according to select-enable-clipboard/primary. These are
|
|
|
|
|
;; the default values of interprogram-cut/paste-function.
|
|
|
|
|
;; Additionally, there's gui-get-primary-selection which is used to get the
|
|
|
|
|
;; PRIMARY selection, specifically for mouse-yank-primary.
|
2014-10-03 02:15:42 +00:00
|
|
|
|
|
1993-03-17 17:19:16 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2008-02-08 20:16:52 +00:00
|
|
|
|
(defcustom selection-coding-system nil
|
2010-10-24 02:22:43 +00:00
|
|
|
|
"Coding system for communicating with other programs.
|
2007-11-18 09:12:14 +00:00
|
|
|
|
|
2010-10-24 02:22:43 +00:00
|
|
|
|
For MS-Windows and MS-DOS:
|
|
|
|
|
When sending or receiving text via selection and clipboard, the text
|
|
|
|
|
is encoded or decoded by this coding system. The default value is
|
|
|
|
|
the current system default encoding on 9x/Me, `utf-16le-dos'
|
|
|
|
|
\(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS.
|
|
|
|
|
|
|
|
|
|
For X Windows:
|
2007-11-18 09:12:14 +00:00
|
|
|
|
|
2023-10-26 04:50:19 +00:00
|
|
|
|
This coding system replaces that of the default coding system
|
|
|
|
|
selection text is encoded by in reaction to a request for the
|
|
|
|
|
polymorphic `TEXT' selection target when its base coding system
|
|
|
|
|
is compatible with `compound-text' and the text being encoded
|
|
|
|
|
cannot be rendered Latin-1 without loss of information.
|
|
|
|
|
|
|
|
|
|
It also replaces the coding system by which calls to
|
|
|
|
|
`gui-get-selection' decode selection requests for text data
|
|
|
|
|
types, which are enumerated below beside their respective coding
|
|
|
|
|
systems otherwise used.
|
|
|
|
|
|
|
|
|
|
DATA TYPE CODING SYSTEM
|
|
|
|
|
-------------------------- -------------
|
|
|
|
|
UTF8_STRING utf-8
|
|
|
|
|
text/plain\\;charset=utf-8 utf-8
|
|
|
|
|
COMPOUND_TEXT compound-text-with-extensions
|
|
|
|
|
STRING iso-latin-1
|
|
|
|
|
C_STRING raw-text-unix
|
2007-11-18 09:12:14 +00:00
|
|
|
|
|
2023-10-26 04:50:19 +00:00
|
|
|
|
See also the documentation of the variable `x-select-request-type' how
|
|
|
|
|
to control which data-type to request for receiving text."
|
2008-02-08 20:16:52 +00:00
|
|
|
|
:type 'coding-system
|
|
|
|
|
:group 'mule
|
|
|
|
|
;; Default was compound-text-with-extensions in 22.x (pre-unicode).
|
|
|
|
|
:version "23.1"
|
|
|
|
|
:set (lambda (symbol value)
|
|
|
|
|
(set-selection-coding-system value)
|
|
|
|
|
(set symbol value)))
|
2007-11-18 09:12:14 +00:00
|
|
|
|
|
|
|
|
|
(defvar next-selection-coding-system nil
|
2010-10-24 02:13:37 +00:00
|
|
|
|
"Coding system for the next communication with other programs.
|
2007-11-18 09:12:14 +00:00
|
|
|
|
Usually, `selection-coding-system' is used for communicating with
|
2010-10-24 02:13:37 +00:00
|
|
|
|
other programs (X Windows clients or MS Windows programs). But, if this
|
|
|
|
|
variable is set, it is used for the next communication only.
|
|
|
|
|
After the communication, this variable is set to nil.")
|
2007-11-18 09:12:14 +00:00
|
|
|
|
|
2018-04-20 22:34:39 +00:00
|
|
|
|
(define-obsolete-variable-alias 'x-select-enable-clipboard
|
|
|
|
|
'select-enable-clipboard "25.1")
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(defcustom select-enable-clipboard t
|
2014-10-01 22:13:11 +00:00
|
|
|
|
"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")
|
|
|
|
|
|
2018-04-20 22:34:39 +00:00
|
|
|
|
(define-obsolete-variable-alias 'x-select-enable-primary
|
|
|
|
|
'select-enable-primary "25.1")
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(defcustom select-enable-primary nil
|
2017-10-29 16:32:35 +00:00
|
|
|
|
"Non-nil means cutting and pasting uses the primary selection.
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
The existence of a primary selection depends on the underlying GUI you use.
|
|
|
|
|
E.g. it doesn't exist under MS-Windows."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'killing
|
2017-01-06 13:23:17 +00:00
|
|
|
|
:version "25.1")
|
2014-10-01 22:13:11 +00:00
|
|
|
|
|
2022-03-13 20:05:18 +00:00
|
|
|
|
;; We keep track of the last selection here, so we can check the
|
|
|
|
|
;; current selection against it, and avoid passing back with
|
|
|
|
|
;; gui-selection-value the same text we previously killed or
|
2022-07-01 02:23:13 +00:00
|
|
|
|
;; yanked. We track both separately in case another X application only
|
|
|
|
|
;; sets one of them we aren't fooled by the PRIMARY or CLIPBOARD
|
|
|
|
|
;; selection staying the same.
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(defvar gui--last-selected-text-clipboard nil
|
|
|
|
|
"The value of the CLIPBOARD selection last seen.")
|
2022-07-01 02:23:13 +00:00
|
|
|
|
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(defvar gui--last-selected-text-primary nil
|
|
|
|
|
"The value of the PRIMARY selection last seen.")
|
2014-10-01 22:13:11 +00:00
|
|
|
|
|
2022-03-13 20:05:18 +00:00
|
|
|
|
(defvar gui--last-selection-timestamp-clipboard nil
|
|
|
|
|
"The timestamp of the CLIPBOARD selection last seen.")
|
2022-07-01 02:23:13 +00:00
|
|
|
|
|
2022-03-13 20:05:18 +00:00
|
|
|
|
(defvar gui--last-selection-timestamp-primary nil
|
|
|
|
|
"The timestamp of the PRIMARY selection last seen.")
|
|
|
|
|
|
2022-07-01 02:23:13 +00:00
|
|
|
|
(defvar gui-last-cut-in-clipboard nil
|
|
|
|
|
"Whether or not the last call to `interprogram-cut-function' owned CLIPBOARD.")
|
|
|
|
|
|
|
|
|
|
(defvar gui-last-cut-in-primary nil
|
|
|
|
|
"Whether or not the last call to `interprogram-cut-function' owned PRIMARY.")
|
|
|
|
|
|
2022-03-13 20:05:18 +00:00
|
|
|
|
(defun gui--set-last-clipboard-selection (text)
|
|
|
|
|
"Save last clipboard selection.
|
|
|
|
|
Save the selected text, passed as argument, and for window
|
|
|
|
|
systems that support it, save the selection timestamp too."
|
|
|
|
|
(setq gui--last-selected-text-clipboard text)
|
|
|
|
|
(when (eq window-system 'x)
|
|
|
|
|
(setq gui--last-selection-timestamp-clipboard
|
|
|
|
|
(gui-backend-get-selection 'CLIPBOARD 'TIMESTAMP))))
|
|
|
|
|
|
|
|
|
|
(defun gui--set-last-primary-selection (text)
|
|
|
|
|
"Save last primary selection.
|
|
|
|
|
Save the selected text, passed as argument, and for window
|
|
|
|
|
systems that support it, save the selection timestamp too."
|
|
|
|
|
(setq gui--last-selected-text-primary text)
|
|
|
|
|
(when (eq window-system 'x)
|
|
|
|
|
(setq gui--last-selection-timestamp-primary
|
|
|
|
|
(gui-backend-get-selection 'PRIMARY 'TIMESTAMP))))
|
|
|
|
|
|
|
|
|
|
(defun gui--clipboard-selection-unchanged-p (text)
|
|
|
|
|
"Check whether the clipboard selection has changed.
|
|
|
|
|
Compare the selection text, passed as argument, with the text
|
2024-07-20 00:22:49 +00:00
|
|
|
|
from the last saved selection. For window systems that support
|
2022-03-13 20:05:18 +00:00
|
|
|
|
it, compare the selection timestamp too."
|
|
|
|
|
(and
|
|
|
|
|
(equal text gui--last-selected-text-clipboard)
|
|
|
|
|
(or (not (eq window-system 'x))
|
|
|
|
|
(eq gui--last-selection-timestamp-clipboard
|
|
|
|
|
(gui-backend-get-selection 'CLIPBOARD 'TIMESTAMP)))))
|
|
|
|
|
|
|
|
|
|
(defun gui--primary-selection-unchanged-p (text)
|
|
|
|
|
"Check whether the primary selection has changed.
|
|
|
|
|
Compare the selection text, passed as argument, with the text
|
|
|
|
|
from the last saved selection. For window systems that support
|
|
|
|
|
it, compare the selection timestamp too."
|
|
|
|
|
(and
|
|
|
|
|
(equal text gui--last-selected-text-primary)
|
|
|
|
|
(or (not (eq window-system 'x))
|
|
|
|
|
(eq gui--last-selection-timestamp-primary
|
|
|
|
|
(gui-backend-get-selection 'PRIMARY 'TIMESTAMP)))))
|
|
|
|
|
|
|
|
|
|
|
2014-10-01 22:13:11 +00:00
|
|
|
|
(defun gui-select-text (text)
|
|
|
|
|
"Select TEXT, a string, according to the window system.
|
2022-03-13 20:05:18 +00:00
|
|
|
|
If `select-enable-clipboard' is non-nil, copy TEXT to the system's clipboard.
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
If `select-enable-primary' is non-nil, put TEXT in the primary selection.
|
|
|
|
|
|
|
|
|
|
MS-Windows does not have a \"primary\" selection."
|
|
|
|
|
(when select-enable-primary
|
|
|
|
|
(gui-set-selection 'PRIMARY text)
|
2022-03-13 20:05:18 +00:00
|
|
|
|
(gui--set-last-primary-selection text))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(when 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)
|
|
|
|
|
(gui-set-selection 'CLIPBOARD text)
|
2022-07-01 02:23:13 +00:00
|
|
|
|
(gui--set-last-clipboard-selection text))
|
|
|
|
|
;; Record which selections we now have ownership over.
|
|
|
|
|
(setq gui-last-cut-in-clipboard select-enable-clipboard
|
|
|
|
|
gui-last-cut-in-primary select-enable-primary))
|
2014-10-01 22:13:11 +00:00
|
|
|
|
(define-obsolete-function-alias 'x-select-text 'gui-select-text "25.1")
|
|
|
|
|
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(defcustom x-select-request-type nil
|
|
|
|
|
"Data type request for X selection.
|
|
|
|
|
The value is one of the following data types, a list of them, or nil:
|
2021-03-02 13:44:42 +00:00
|
|
|
|
`COMPOUND_TEXT', `UTF8_STRING', `STRING', `TEXT', `text/plain\\;charset=utf-8'
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
|
|
|
|
|
If the value is one of the above symbols, try only the specified type.
|
|
|
|
|
|
|
|
|
|
If the value is a list of them, try each of them in the specified
|
|
|
|
|
order until succeed.
|
|
|
|
|
|
2021-03-02 13:44:42 +00:00
|
|
|
|
The value nil is the same as the list (UTF8_STRING COMPOUND_TEXT STRING
|
|
|
|
|
text/plain\\;charset=utf-8)."
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
:type '(choice (const :tag "Default" nil)
|
|
|
|
|
(const COMPOUND_TEXT)
|
|
|
|
|
(const UTF8_STRING)
|
|
|
|
|
(const STRING)
|
|
|
|
|
(const TEXT)
|
2021-03-02 13:44:42 +00:00
|
|
|
|
(const text/plain\;charset=utf-8)
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(set :tag "List of values"
|
|
|
|
|
(const COMPOUND_TEXT)
|
|
|
|
|
(const UTF8_STRING)
|
|
|
|
|
(const STRING)
|
2021-03-02 12:08:50 +00:00
|
|
|
|
(const TEXT)
|
2021-03-02 13:44:42 +00:00
|
|
|
|
(const text/plain\;charset=utf-8)))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
:group 'killing)
|
|
|
|
|
|
|
|
|
|
(defun gui--selection-value-internal (type)
|
2019-09-13 12:53:41 +00:00
|
|
|
|
"Get a selection value of type TYPE.
|
|
|
|
|
Call `gui-get-selection' with an appropriate DATA-TYPE argument
|
|
|
|
|
decided by `x-select-request-type'. The return value is already
|
|
|
|
|
decoded. If `gui-get-selection' signals an error, return nil."
|
2022-02-01 02:03:05 +00:00
|
|
|
|
;; The doc string of `interprogram-paste-function' says to return
|
|
|
|
|
;; nil if no other program has provided text to paste.
|
2022-07-01 02:23:13 +00:00
|
|
|
|
(unless (and gui-last-cut-in-clipboard
|
|
|
|
|
;; `gui-backend-selection-owner-p' might be unreliable on
|
|
|
|
|
;; some other window systems.
|
|
|
|
|
(memq window-system '(x haiku))
|
|
|
|
|
(eq type 'CLIPBOARD)
|
|
|
|
|
;; Should we unify this with gui--clipboard-selection-unchanged-p?
|
|
|
|
|
(gui-backend-selection-owner-p type))
|
2022-02-14 10:17:58 +00:00
|
|
|
|
(let ((request-type (if (memq window-system '(x pgtk haiku))
|
2022-02-01 02:03:05 +00:00
|
|
|
|
(or x-select-request-type
|
|
|
|
|
'(UTF8_STRING COMPOUND_TEXT STRING text/plain\;charset=utf-8))
|
|
|
|
|
'STRING))
|
|
|
|
|
text)
|
|
|
|
|
(with-demoted-errors "gui-get-selection: %S"
|
|
|
|
|
(if (consp request-type)
|
|
|
|
|
(while (and request-type (not text))
|
|
|
|
|
(setq text (gui-get-selection type (car request-type)))
|
|
|
|
|
(setq request-type (cdr request-type)))
|
|
|
|
|
(setq text (gui-get-selection type request-type))))
|
|
|
|
|
(if text
|
|
|
|
|
(remove-text-properties 0 (length text) '(foreign-selection nil) text))
|
|
|
|
|
text)))
|
2014-10-03 01:39:49 +00:00
|
|
|
|
|
|
|
|
|
(defun gui-selection-value ()
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(let ((clip-text
|
|
|
|
|
(when select-enable-clipboard
|
|
|
|
|
(let ((text (gui--selection-value-internal 'CLIPBOARD)))
|
2021-07-06 17:25:41 +00:00
|
|
|
|
(when (string= text "")
|
|
|
|
|
(setq text nil))
|
2022-03-13 20:05:18 +00:00
|
|
|
|
;; Check the CLIPBOARD selection for 'newness', i.e.,
|
|
|
|
|
;; whether it is different from the last time we did a
|
|
|
|
|
;; yank operation or whether it was set by Emacs itself
|
|
|
|
|
;; with a kill operation, since in both cases the text
|
|
|
|
|
;; will already be in the kill ring. See (bug#27442) and
|
|
|
|
|
;; (bug#53894) for further discussion about this DWIM
|
|
|
|
|
;; action, and possible ways to make this check less
|
|
|
|
|
;; fragile, if so desired.
|
2022-07-01 02:23:13 +00:00
|
|
|
|
|
|
|
|
|
;; Don't check the "newness" of CLIPBOARD if the last
|
|
|
|
|
;; call to `gui-select-text' didn't cause us to become
|
|
|
|
|
;; its owner. This lets the user yank text killed by
|
|
|
|
|
;; `clipboard-kill-region' with `clipboard-yank' without
|
|
|
|
|
;; interference from text killed by other means when
|
|
|
|
|
;; `select-enable-clipboard' is nil.
|
|
|
|
|
(unless (and gui-last-cut-in-clipboard
|
|
|
|
|
(gui--clipboard-selection-unchanged-p text))
|
2022-03-13 20:05:18 +00:00
|
|
|
|
(gui--set-last-clipboard-selection text)
|
|
|
|
|
text))))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(primary-text
|
|
|
|
|
(when select-enable-primary
|
|
|
|
|
(let ((text (gui--selection-value-internal 'PRIMARY)))
|
|
|
|
|
(if (string= text "") (setq text nil))
|
|
|
|
|
;; Check the PRIMARY selection for 'newness', is it different
|
|
|
|
|
;; from what we remembered them to be last time we did a
|
|
|
|
|
;; cut/paste operation.
|
2022-07-01 02:23:13 +00:00
|
|
|
|
(unless (and gui-last-cut-in-primary
|
|
|
|
|
(gui--primary-selection-unchanged-p text))
|
2022-03-13 20:05:18 +00:00
|
|
|
|
(gui--set-last-primary-selection text)
|
|
|
|
|
text)))))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
|
|
|
|
|
;; As we have done one selection, clear this now.
|
|
|
|
|
(setq next-selection-coding-system nil)
|
|
|
|
|
|
|
|
|
|
;; At this point we have recorded the current values for the
|
|
|
|
|
;; selection from clipboard (if we are supposed to) and primary.
|
|
|
|
|
;; So return the first one that has changed
|
|
|
|
|
;; (which is the first non-null one).
|
|
|
|
|
;;
|
|
|
|
|
;; NOTE: There will be cases where more than one of these has
|
|
|
|
|
;; changed and the new values differ. This indicates that
|
|
|
|
|
;; something like the following has happened since the last time
|
|
|
|
|
;; we looked at the selections: Application X set all the
|
|
|
|
|
;; selections, then Application Y set only one of them.
|
2022-03-13 20:05:18 +00:00
|
|
|
|
;; In this case, for systems that support selection timestamps, we
|
|
|
|
|
;; could return the newer. For systems that don't, there is no
|
|
|
|
|
;; way to know what the 'correct' value to return is. The nice
|
|
|
|
|
;; thing to do would be to tell the user we saw multiple possible
|
|
|
|
|
;; selections and ask the user which was the one they wanted.
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(or clip-text primary-text)
|
|
|
|
|
))
|
2014-10-03 01:39:49 +00:00
|
|
|
|
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(define-obsolete-function-alias 'x-selection-value 'gui-selection-value "25.1")
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
|
|
|
|
(defun x-get-clipboard ()
|
|
|
|
|
"Return text pasted to the clipboard."
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
(declare (obsolete gui-get-selection "25.1"))
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
(gui-backend-get-selection 'CLIPBOARD 'STRING))
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
|
|
|
|
|
(defun gui-get-primary-selection ()
|
|
|
|
|
"Return the PRIMARY selection, or the best emulation thereof."
|
2015-10-08 13:45:32 +00:00
|
|
|
|
(or (gui--selection-value-internal 'PRIMARY)
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
(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")
|
|
|
|
|
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
;;; Lower-level, backend dependent selection handling.
|
|
|
|
|
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
(cl-defgeneric gui-backend-get-selection (_selection-symbol _target-type)
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
"Return selected text.
|
|
|
|
|
SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
|
|
|
|
|
\(Those are literal upper-case symbol names, since that's what X expects.)
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
TARGET-TYPE is the type of data desired, typically `STRING'."
|
|
|
|
|
nil)
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
(cl-defgeneric gui-backend-set-selection (_selection _value)
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
"Method to assert a selection of type SELECTION and value VALUE.
|
|
|
|
|
SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
If VALUE is nil and we own the selection SELECTION, disown it instead.
|
|
|
|
|
Disowning it means there is no such selection.
|
|
|
|
|
\(Those are literal upper-case symbol names, since that's what X expects.)
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
VALUE is typically a string, or a cons of two markers, but may be
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
anything that the functions on `selection-converter-alist' know about."
|
|
|
|
|
nil)
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
(cl-defgeneric gui-backend-selection-owner-p (_selection)
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
"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'.
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
\(Those are literal upper-case symbol names, since that's what X expects.)"
|
|
|
|
|
nil)
|
2014-10-10 03:28:24 +00:00
|
|
|
|
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
(cl-defgeneric gui-backend-selection-exists-p (_selection)
|
2014-10-10 03:28:24 +00:00
|
|
|
|
"Whether there is an owner for the given X Selection.
|
|
|
|
|
The arg should be the name of the selection in question, typically one of
|
|
|
|
|
the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
\(Those are literal upper-case symbol names, since that's what X expects.)"
|
|
|
|
|
nil)
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
|
|
|
|
|
(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
|
|
|
|
|
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
|
2018-04-14 07:53:34 +00:00
|
|
|
|
in `selection-converter-alist', which see. Window systems other
|
|
|
|
|
than X usually support only a small subset of these symbols, in
|
|
|
|
|
addition to `STRING'; MS-Windows supports `TARGETS', which reports
|
|
|
|
|
the formats available in the clipboard if TYPE is `CLIPBOARD'."
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
(let ((data (gui-backend-get-selection (or type 'PRIMARY)
|
|
|
|
|
(or data-type 'STRING))))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(when (and (stringp data)
|
2021-11-11 04:22:02 +00:00
|
|
|
|
;; If this text property is set, then the data needs to
|
|
|
|
|
;; be decoded -- otherwise it has already been decoded
|
|
|
|
|
;; by the lower level functions.
|
|
|
|
|
(get-text-property 0 'foreign-selection data))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(let ((coding (or next-selection-coding-system
|
|
|
|
|
selection-coding-system
|
|
|
|
|
(pcase data-type
|
|
|
|
|
('UTF8_STRING 'utf-8)
|
2021-03-02 13:44:42 +00:00
|
|
|
|
('text/plain\;charset=utf-8 'utf-8)
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
('COMPOUND_TEXT 'compound-text-with-extensions)
|
|
|
|
|
('C_STRING nil)
|
2021-11-11 04:22:02 +00:00
|
|
|
|
('STRING 'iso-8859-1)))))
|
|
|
|
|
(setq data
|
|
|
|
|
(cond (coding (decode-coding-string data coding))
|
2019-05-17 08:01:20 +00:00
|
|
|
|
;; We want to convert each non-ASCII byte to the
|
|
|
|
|
;; corresponding eight-bit character, which has
|
|
|
|
|
;; a codepoint >= #x3FFF00.
|
2021-11-11 04:22:02 +00:00
|
|
|
|
((eq data-type 'C_STRING)
|
|
|
|
|
(string-to-multibyte data))
|
|
|
|
|
;; Guess at the charset for types like text/html
|
|
|
|
|
;; -- it can be anything, and different
|
|
|
|
|
;; applications use different encodings.
|
|
|
|
|
((string-match-p "\\`text/" (symbol-name data-type))
|
|
|
|
|
(decode-coding-string
|
|
|
|
|
data (car (detect-coding-string data))))
|
|
|
|
|
;; Do nothing.
|
|
|
|
|
(t data))))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(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")
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
|
|
|
|
|
(defun gui-set-selection (type data)
|
2009-08-02 23:22:03 +00:00
|
|
|
|
"Make an X selection of type TYPE and value DATA.
|
2009-07-25 09:31:05 +00:00
|
|
|
|
The argument TYPE (nil means `PRIMARY') says which selection, and
|
2022-03-28 12:34:03 +00:00
|
|
|
|
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, or
|
|
|
|
|
an integer.
|
2009-07-25 09:31:05 +00:00
|
|
|
|
|
2022-06-01 08:25:53 +00:00
|
|
|
|
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. If DATA is a string, then its text properties can
|
|
|
|
|
specify alternative values for different data types. For
|
|
|
|
|
example, the value of any property named `text/uri-list' will be
|
|
|
|
|
used instead of DATA itself when another program converts TYPE to
|
|
|
|
|
the target `text/uri-list'.
|
2009-07-25 09:31:05 +00:00
|
|
|
|
|
|
|
|
|
The data may also be a vector of valid non-vector selection values.
|
1995-04-13 02:34:03 +00:00
|
|
|
|
|
2004-07-24 21:53:10 +00:00
|
|
|
|
The return value is DATA.
|
|
|
|
|
|
|
|
|
|
Interactively, this command sets the primary selection. Without
|
|
|
|
|
prefix argument, it reads the selection in the minibuffer. With
|
2009-07-25 09:31:05 +00:00
|
|
|
|
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."
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(interactive (if (not current-prefix-arg)
|
1995-04-13 02:34:03 +00:00
|
|
|
|
(list 'PRIMARY (read-string "Set text for pasting: "))
|
1999-11-12 13:09:37 +00:00
|
|
|
|
(list 'PRIMARY (buffer-substring (region-beginning) (region-end)))))
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(if (stringp type) (setq type (intern type)))
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
(or (gui--valid-simple-selection-p data)
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(and (vectorp data)
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(let ((valid t))
|
|
|
|
|
(dotimes (i (length data))
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
(or (gui--valid-simple-selection-p (aref data i))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(setq valid nil)))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
valid))
|
|
|
|
|
(signal 'error (list "invalid selection" data)))
|
|
|
|
|
(or type (setq type 'PRIMARY))
|
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define)
(gui-method-declare, gui-call): Remove.
(frame-creation-function): Use cl-defgeneric.
(make-frame): Adjust callers.
* lisp/menu-bar.el (menu-bar-edit-menu):
Use gui-backend-selection-exists-p.
* lisp/select.el (x-get-clipboard): Use gui-backend-get-selection.
(gui-backend-get-selection): New cl-generic to replace
gui-get-selection method.
(gui-backend-set-selection): New cl-generic to replace
gui-set-selection method.
(gui-selection-owner-p): New cl-generic to replace
gui-selection-owner-p method.
(gui-backend-selection-exists-p): New cl-generic to replace
gui-selection-exists-p method. Adjust all callers.
* lisp/server.el (server-create-window-system-frame): Don't ignore
window-system spec even when unsupported.
* lisp/simple.el (deactivate-mark): Use new gui-backend-* functions.
* lisp/startup.el (handle-args-function, window-system-initialization):
Use cl-defgeneric.
(command-line): Adjust calls accordingly.
* lisp/term/ns-win.el (ns-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/pc-win.el (w16-get-selection-value): Turn into
a gui-backend-get-selection method.
(gui-selection-exists-p, gui-selection-owner-p, gui-set-selection):
Use cl-defmethod on the new functions instead.
(msdos-window-system-initialization): Turn into
a window-system-initialization method.
(frame-creation-function, handle-args-function): Use cl-defmethod.
* lisp/term/w32-win.el (w32-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/x-win.el (x-window-system-initialization): Turn into
a window-system-initialization method.
(handle-args-function, frame-creation-function): Use cl-defmethod.
(gui-set-selection, gui-selection-owner-p, gui-selection-exists-p)
(gui-get-selection): Use cl-defmethod on the new functions instead.
* lisp/term/xterm.el (xterm--set-selection): Turn into
a gui-backend-set-selection method.
* src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'.
(Fns_selection_owner_p): Remove unused arg `terminal'.
(Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
2015-05-23 15:32:29 +00:00
|
|
|
|
(gui-backend-set-selection type data)
|
1993-03-17 17:19:16 +00:00
|
|
|
|
data)
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
(define-obsolete-function-alias 'x-set-selection 'gui-set-selection "25.1")
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
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.
2014-10-02 03:19:32 +00:00
|
|
|
|
(defun gui--valid-simple-selection-p (data)
|
2009-07-15 01:25:32 +00:00
|
|
|
|
(or (bufferp data)
|
|
|
|
|
(and (consp data)
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(markerp (car data))
|
|
|
|
|
(markerp (cdr data))
|
|
|
|
|
(marker-buffer (car data))
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(buffer-live-p (marker-buffer (car data)))
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(eq (marker-buffer (car data))
|
|
|
|
|
(marker-buffer (cdr data))))
|
|
|
|
|
(stringp data)
|
|
|
|
|
(and (overlayp data)
|
|
|
|
|
(overlay-buffer data)
|
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection
management functions.
* select.el (select-enable-clipboard): Rename from
gui-select-enable-clipboard.
(select-enable-primary): Move from x-win.el and rename from
x-select-enable-primary.
(gui-last-selected-text): Remove.
(gui--last-selected-text-clipboard, gui--last-selected-text-primary):
New vars.
(gui-select-text): Rewrite, based on x-win.el's old x-select-text.
(gui-select-text-alist, gui-selection-value-alist): Remove.
(x-select-request-type): Move from x-win.el.
(gui--selection-value-internal): New function, taken from x-win's
x-selection-value-internal.
(gui-selection-value): Rewrite, based on x-win.el's old x-selection-value.
(gui-set-selection-alist): Rename from gui-own-selection-alist and
extend it to handle a nil value as a "disown" request.
(gui-disown-selection-alist): Remove.
(xselect-convert-to-delete): Adjust accordingly.
(gui-set-selection): Simplify accordingly as well. Use dotimes.
* lisp/frame.el (gui-method): Use window-system rather than framep.
(gui-method-declare): The tty case is now nil rather than t.
(make-frame): Adjust accordingly.
* lisp/term/x-win.el (x-last-selected-text-primary)
(x-select-enable-primary): Remove (moved to select.el).
(x-select-request-type): Move to select.el.
(x-selection-value-internal, x--selection-value): Remove functions.
(gui-selection-value, gui-select-text): Remove moethods.
(gui-set-selection): Merge own and disown methods.
* lisp/startup.el (command-line): Adjust now that `gui-method' expects nil
for ttys.
* lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard)
(ns-selection-value): Remove functions.
(gui-select-text, gui-selection-value): Don't define method any more.
(gui-set-selection): Merge the old own and disown methods.
(gui-selection-exists-p, gui-get-selection): Adjust to new name of
underlying C primitive.
* lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop
test of gui-select-enable-clipboard, to make it usable as
a gui-get-selection method.
(gui-selection-exists-p): Adjust to new name of C primitive.
(gui-set-selection): Merge own and disown methods.
(gui-select-text, gui-selection-value): Delete methods.
(w16--select-text): Delete function.
* lisp/term/w32-win.el (w32--select-text, w32--get-selection-value):
Delete function (move functionality into w32--set-selection and
w32--get-selection).
(gui-select-text, gui-selection-value): Don't define methods.
(w32--set-selection, w32--get-selection, w32--selection-owner-p):
New functions.
(gui-get-selection, gui-selection-owner-p, gui-selection-exists-p):
Use them.
(gui-selection-exists-p): Adjust to new name of C primitive.
* src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
(Fns_own_selection_internal): Tighten scoping.
(Fns_selection_exists_p): Rename from Fx_selection_exists_p.
(Fns_get_selection): Rename from Fx_get_selection_internal.
(Fns_get_selection_internal, Fns_store_selection_internal):
Remove functions.
(syms_of_nsselect): Adjust accordingly.
* src/w16select.c (Fw16_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_win16select): Adjust accordingly.
* src/w32select.c (Fw32_selection_exists_p): Rename from
Fx_selection_exists_p.
(syms_of_w32select): Adjust accordingly.
2014-10-21 15:27:18 +00:00
|
|
|
|
(buffer-live-p (overlay-buffer data)))
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(symbolp data)
|
|
|
|
|
(integerp data)))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2022-07-09 01:07:07 +00:00
|
|
|
|
|
|
|
|
|
;; Minor mode to make losing ownership of PRIMARY behave more like
|
|
|
|
|
;; other X programs.
|
|
|
|
|
|
2022-07-11 11:36:01 +00:00
|
|
|
|
(defvar lost-selection-last-region-buffer nil
|
|
|
|
|
"The last buffer from which the region was selected.")
|
|
|
|
|
|
|
|
|
|
(defun lost-selection-post-select-region-function (_text)
|
|
|
|
|
"Handle the region being selected into PRIMARY.
|
|
|
|
|
If the current buffer is different from the last buffer,
|
|
|
|
|
deactivate the mark in every other buffer.
|
|
|
|
|
TEXT is ignored."
|
|
|
|
|
(when (not (eq lost-selection-last-region-buffer
|
|
|
|
|
(current-buffer)))
|
|
|
|
|
(dolist (buffer (buffer-list))
|
|
|
|
|
(unless (or (string-match-p "^ "
|
|
|
|
|
(buffer-name buffer))
|
|
|
|
|
(eq buffer (current-buffer)))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(deactivate-mark t))))
|
|
|
|
|
(setq lost-selection-last-region-buffer (current-buffer))))
|
|
|
|
|
|
2022-07-09 01:07:07 +00:00
|
|
|
|
(defun lost-selection-function (selection)
|
|
|
|
|
"Handle losing of ownership of SELECTION.
|
|
|
|
|
If SELECTION is `PRIMARY', deactivate the mark in every
|
|
|
|
|
non-temporary buffer."
|
|
|
|
|
(let ((select-active-regions nil))
|
|
|
|
|
(when (eq selection 'PRIMARY)
|
|
|
|
|
(dolist (buffer (buffer-list))
|
|
|
|
|
(unless (string-match-p "^ "
|
|
|
|
|
(buffer-name buffer))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(deactivate-mark t)))))))
|
|
|
|
|
|
|
|
|
|
(define-minor-mode lost-selection-mode
|
|
|
|
|
"Toggle `lost-selection-mode'.
|
|
|
|
|
|
|
|
|
|
When this is enabled, selecting some text in another program will
|
|
|
|
|
cause the mark to be deactivated in all buffers, mimicking the
|
2022-07-11 11:36:01 +00:00
|
|
|
|
behavior of most X Windows programs.
|
|
|
|
|
|
|
|
|
|
Selecting text in a buffer that ends up changing the primary
|
|
|
|
|
selection will also cause the mark to be deactivated in all other
|
|
|
|
|
buffers."
|
2022-07-09 01:07:07 +00:00
|
|
|
|
:global t
|
|
|
|
|
:group 'x
|
|
|
|
|
(if lost-selection-mode
|
2022-07-11 11:36:01 +00:00
|
|
|
|
(progn
|
|
|
|
|
(cond ((featurep 'x) (add-hook 'x-lost-selection-functions
|
|
|
|
|
#'lost-selection-function))
|
|
|
|
|
((featurep 'pgtk) (add-hook 'pgtk-lost-selection-functions
|
|
|
|
|
#'lost-selection-function))
|
|
|
|
|
((featurep 'haiku) (add-hook 'haiku-lost-selection-functions
|
|
|
|
|
#'lost-selection-function)))
|
|
|
|
|
(add-hook 'post-select-region-hook
|
|
|
|
|
#'lost-selection-post-select-region-function))
|
2022-07-09 01:07:07 +00:00
|
|
|
|
(cond ((featurep 'x) (remove-hook 'x-lost-selection-functions
|
|
|
|
|
#'lost-selection-function))
|
|
|
|
|
((featurep 'pgtk) (remove-hook 'pgtk-lost-selection-functions
|
|
|
|
|
#'lost-selection-function))
|
|
|
|
|
((featurep 'haiku) (remove-hook 'haiku-lost-selection-functions
|
2022-07-11 11:36:01 +00:00
|
|
|
|
#'lost-selection-function)))
|
|
|
|
|
(remove-hook 'post-select-region-hook
|
|
|
|
|
#'lost-selection-post-select-region-function)
|
|
|
|
|
(setq lost-selection-last-region-buffer nil)))
|
2022-07-09 01:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
2008-09-14 21:18:56 +00:00
|
|
|
|
;; Functions to convert the selection into various other selection types.
|
|
|
|
|
;; Every selection type that Emacs handles is implemented this way, except
|
|
|
|
|
;; for TIMESTAMP, which is a special case.
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(defun xselect--selection-bounds (value)
|
|
|
|
|
"Return bounds of X selection value VALUE.
|
|
|
|
|
The return value is a list (BEG END BUF) if VALUE is a cons of
|
|
|
|
|
two markers or an overlay. Otherwise, it is nil."
|
2009-07-15 01:25:32 +00:00
|
|
|
|
(cond ((bufferp value)
|
|
|
|
|
(with-current-buffer value
|
|
|
|
|
(when (mark t)
|
|
|
|
|
(list (mark t) (point) value))))
|
|
|
|
|
((and (consp value)
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(markerp (car value))
|
|
|
|
|
(markerp (cdr value)))
|
|
|
|
|
(when (and (marker-buffer (car value))
|
|
|
|
|
(buffer-name (marker-buffer (car value)))
|
|
|
|
|
(eq (marker-buffer (car value))
|
|
|
|
|
(marker-buffer (cdr value))))
|
|
|
|
|
(list (marker-position (car value))
|
|
|
|
|
(marker-position (cdr value))
|
|
|
|
|
(marker-buffer (car value)))))
|
|
|
|
|
((overlayp value)
|
|
|
|
|
(when (overlay-buffer value)
|
|
|
|
|
(list (overlay-start value)
|
|
|
|
|
(overlay-end value)
|
|
|
|
|
(overlay-buffer value))))))
|
|
|
|
|
|
|
|
|
|
(defun xselect--int-to-cons (n)
|
|
|
|
|
(cons (ash n -16) (logand n 65535)))
|
|
|
|
|
|
2022-05-28 08:48:49 +00:00
|
|
|
|
(defun xselect--encode-string (type str &optional can-modify
|
|
|
|
|
prefer-string-to-c-string)
|
2012-04-24 05:34:50 +00:00
|
|
|
|
(when str
|
|
|
|
|
;; If TYPE is nil, this is a local request; return STR as-is.
|
|
|
|
|
(if (null type)
|
|
|
|
|
str
|
|
|
|
|
;; Otherwise, encode STR.
|
|
|
|
|
(let ((coding (or next-selection-coding-system
|
|
|
|
|
selection-coding-system)))
|
2002-08-14 00:57:55 +00:00
|
|
|
|
(if coding
|
2007-11-18 09:12:14 +00:00
|
|
|
|
(setq coding (coding-system-base coding)))
|
2004-05-03 01:24:47 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
2004-05-03 21:46:00 +00:00
|
|
|
|
;; Suppress producing escape sequences for compositions.
|
2012-04-24 05:34:50 +00:00
|
|
|
|
;; But avoid modifying the string if it's a buffer name etc.
|
|
|
|
|
(unless can-modify (setq str (substring str 0)))
|
2004-05-03 01:24:47 +00:00
|
|
|
|
(remove-text-properties 0 (length str) '(composition nil) str)
|
2012-05-05 04:32:58 +00:00
|
|
|
|
;; For X selections, TEXT is a polymorphic target; choose
|
|
|
|
|
;; the actual type from `UTF8_STRING', `COMPOUND_TEXT',
|
|
|
|
|
;; `STRING', and `C_STRING'. On Nextstep, always use UTF-8
|
|
|
|
|
;; (see ns_string_to_pasteboard_internal in nsselect.m).
|
|
|
|
|
(when (eq type 'TEXT)
|
|
|
|
|
(cond
|
|
|
|
|
((featurep 'ns)
|
|
|
|
|
(setq type 'UTF8_STRING))
|
|
|
|
|
((not (multibyte-string-p str))
|
|
|
|
|
(setq type 'C_STRING))
|
|
|
|
|
(t
|
|
|
|
|
(let (non-latin-1 non-unicode eight-bit)
|
Remove redundant #' before lambda
* admin/unidata/unidata-gen.el (unidata-gen-table)
(unidata-gen-table-symbol, unidata-gen-table-integer)
(unidata-gen-table-numeric, unidata-gen-table-word-list)
(unidata-describe-decomposition):
* lisp/apropos.el (apropos-user-option):
* lisp/bookmark.el (bookmark-bmenu-search):
* lisp/composite.el (unicode-category-table):
* lisp/elec-pair.el (electric-pair--balance-info):
* lisp/electric.el (electric-quote-chars):
* lisp/emulation/cua-base.el (cua-rectangle-mark-key):
* lisp/epa-hook.el (epa-file-encrypt-to):
* lisp/faces.el (face-font-selection-order)
(face-font-family-alternatives, face-font-registry-alternatives)
(face-valid-attribute-values, tty-run-terminal-initialization):
* lisp/files.el (recover-file, file-expand-wildcards):
* lisp/frame.el (frames-on-display-list):
* lisp/help-at-pt.el (help-at-pt-display-when-idle):
* lisp/help-fns.el (help-fns--face-attributes):
* lisp/ido.el (ido-mode, ido-unc-hosts):
* lisp/isearch.el (isearch-highlight-regexp)
(isearch-highlight-lines-matching-regexp):
* lisp/language/indian.el (script-regexp-alist):
* lisp/language/lao.el:
* lisp/leim/quail/ipa.el (ipa-x-sampa-prepend-to-keymap-entry):
* lisp/mh-e/mh-folder.el (mh-process-commands):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer):
* lisp/ps-mule.el (ps-mule-end-job):
* lisp/ps-print.el (ps-color-scale, ps-background-pages)
(ps-background-text, ps-background-image, ps-background)
(ps-begin-job, ps-print-translation-table):
* lisp/recentf.el (recentf-sort-ascending)
(recentf-sort-descending, recentf-sort-basenames-ascending)
(recentf-sort-basenames-descending)
(recentf-sort-directories-ascending)
(recentf-sort-directories-descending):
* lisp/replace.el (occur-engine-add-prefix):
* lisp/select.el (xselect--encode-string):
* lisp/server.el (server-use-tcp):
* lisp/ses.el (ses-sort-column):
* lisp/sort.el (sort-columns):
* lisp/term/ns-win.el (window-system-initialization):
* lisp/tree-widget.el (tree-widget-image-formats):
* lisp/whitespace.el (whitespace-report-region): Remove redundant #'
before lambda.
2021-10-21 21:35:07 +00:00
|
|
|
|
(mapc (lambda (x)
|
|
|
|
|
(if (>= x #x100)
|
|
|
|
|
(if (< x #x110000)
|
|
|
|
|
(setq non-latin-1 t)
|
|
|
|
|
(if (< x #x3FFF80)
|
|
|
|
|
(setq non-unicode t)
|
|
|
|
|
(setq eight-bit t)))))
|
2012-05-05 04:32:58 +00:00
|
|
|
|
str)
|
2012-10-10 14:45:26 +00:00
|
|
|
|
(setq type (if (or non-unicode
|
|
|
|
|
(and
|
|
|
|
|
non-latin-1
|
|
|
|
|
;; If a coding is specified for
|
|
|
|
|
;; selection, and that is
|
|
|
|
|
;; compatible with COMPOUND_TEXT,
|
|
|
|
|
;; use it.
|
|
|
|
|
coding
|
|
|
|
|
(eq (coding-system-get coding :mime-charset)
|
|
|
|
|
'x-ctext)))
|
|
|
|
|
'COMPOUND_TEXT
|
2012-05-05 04:32:58 +00:00
|
|
|
|
(if non-latin-1 'UTF8_STRING
|
|
|
|
|
(if eight-bit 'C_STRING
|
|
|
|
|
'STRING))))))))
|
2008-04-21 02:02:01 +00:00
|
|
|
|
(cond
|
2022-03-16 09:03:19 +00:00
|
|
|
|
((or (eq type 'UTF8_STRING)
|
|
|
|
|
(eq type 'text/plain\;charset=utf-8))
|
2008-04-21 02:02:01 +00:00
|
|
|
|
(if (or (not coding)
|
|
|
|
|
(not (eq (coding-system-type coding) 'utf-8)))
|
|
|
|
|
(setq coding 'utf-8))
|
|
|
|
|
(setq str (encode-coding-string str coding)))
|
|
|
|
|
|
|
|
|
|
((eq type 'STRING)
|
|
|
|
|
(if (or (not coding)
|
|
|
|
|
(not (eq (coding-system-type coding) 'charset)))
|
|
|
|
|
(setq coding 'iso-8859-1))
|
|
|
|
|
(setq str (encode-coding-string str coding)))
|
|
|
|
|
|
2022-03-16 09:03:19 +00:00
|
|
|
|
((eq type 'text/plain)
|
|
|
|
|
(if (or (not coding)
|
|
|
|
|
(not (eq (coding-system-type coding) 'charset)))
|
|
|
|
|
(setq coding 'ascii))
|
|
|
|
|
(setq str (encode-coding-string str coding)))
|
|
|
|
|
|
2008-04-21 02:02:01 +00:00
|
|
|
|
((eq type 'COMPOUND_TEXT)
|
|
|
|
|
(if (or (not coding)
|
|
|
|
|
(not (eq (coding-system-type coding) 'iso-2022)))
|
|
|
|
|
(setq coding 'compound-text-with-extensions))
|
|
|
|
|
(setq str (encode-coding-string str coding)))
|
|
|
|
|
|
|
|
|
|
((eq type 'C_STRING)
|
2019-06-22 08:34:23 +00:00
|
|
|
|
;; According to ICCCM Protocol v2.0 (para 2.7.1), C_STRING
|
|
|
|
|
;; is a zero-terminated sequence of raw bytes that
|
|
|
|
|
;; shouldn't be interpreted as text in any encoding.
|
|
|
|
|
;; Therefore, if STR is unibyte (the normal case), we use
|
|
|
|
|
;; it as-is; otherwise we assume some of the characters
|
|
|
|
|
;; are eight-bit and ensure they are converted to their
|
|
|
|
|
;; single-byte representation.
|
|
|
|
|
(or (null (multibyte-string-p str))
|
2019-06-22 09:38:05 +00:00
|
|
|
|
(setq str (encode-coding-string str 'raw-text-unix))))
|
2008-04-21 02:02:01 +00:00
|
|
|
|
|
|
|
|
|
(t
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(error "Unknown selection type: %S" type)))))
|
2002-08-14 00:57:55 +00:00
|
|
|
|
|
2017-02-12 00:47:55 +00:00
|
|
|
|
;; Most programs are unable to handle NUL bytes in strings.
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 16:58:46 +00:00
|
|
|
|
(setq str (string-replace "\0" "\\0" str))
|
2017-02-12 00:47:55 +00:00
|
|
|
|
|
2002-08-14 00:57:55 +00:00
|
|
|
|
(setq next-selection-coding-system nil)
|
2022-05-28 08:48:49 +00:00
|
|
|
|
(cons (if (and prefer-string-to-c-string
|
|
|
|
|
(eq type 'C_STRING))
|
|
|
|
|
'STRING type)
|
|
|
|
|
str))))
|
2002-08-14 00:57:55 +00:00
|
|
|
|
|
2012-04-24 05:34:50 +00:00
|
|
|
|
(defun xselect-convert-to-string (_selection type value)
|
|
|
|
|
(let ((str (cond ((stringp value) value)
|
|
|
|
|
((setq value (xselect--selection-bounds value))
|
|
|
|
|
(with-current-buffer (nth 2 value)
|
2022-08-13 09:49:31 +00:00
|
|
|
|
(when (and (>= (nth 0 value) (point-min))
|
|
|
|
|
(<= (nth 1 value) (point-max)))
|
|
|
|
|
(buffer-substring (nth 0 value)
|
|
|
|
|
(nth 1 value))))))))
|
|
|
|
|
(when str
|
|
|
|
|
(xselect--encode-string type str t))))
|
2012-04-24 05:34:50 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-length (_selection _type value)
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(let ((len (cond ((stringp value)
|
|
|
|
|
(length value))
|
|
|
|
|
((setq value (xselect--selection-bounds value))
|
|
|
|
|
(abs (- (nth 0 value) (nth 1 value)))))))
|
|
|
|
|
(if len
|
|
|
|
|
(xselect--int-to-cons len))))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2022-06-07 05:49:41 +00:00
|
|
|
|
(defvar x-dnd-targets-list)
|
|
|
|
|
|
2022-03-18 05:17:19 +00:00
|
|
|
|
(defun xselect-convert-to-targets (selection _type value)
|
2022-03-24 09:32:10 +00:00
|
|
|
|
;; Return a vector of atoms, but remove duplicates first.
|
2022-06-07 05:49:41 +00:00
|
|
|
|
(if (eq selection 'XdndSelection)
|
|
|
|
|
;; This isn't required by the XDND protocol, and sure enough no
|
|
|
|
|
;; clients seem to dependent on it, but Emacs implements the
|
|
|
|
|
;; receiver side of the Motif drop protocol by looking at the
|
|
|
|
|
;; initiator selection's TARGETS target (which Motif provides)
|
|
|
|
|
;; instead of the target table on the drag window, so it seems
|
|
|
|
|
;; plausible for other clients to rely on that as well.
|
|
|
|
|
(apply #'vector (mapcar #'intern x-dnd-targets-list))
|
|
|
|
|
(apply #'vector
|
|
|
|
|
(delete-dups
|
|
|
|
|
`( TIMESTAMP MULTIPLE
|
|
|
|
|
. ,(delq '_EMACS_INTERNAL
|
|
|
|
|
(mapcar (lambda (conv)
|
|
|
|
|
(if (or (not (consp (cdr conv)))
|
|
|
|
|
(funcall (cadr conv) selection
|
|
|
|
|
(car conv) value))
|
|
|
|
|
(car conv)
|
|
|
|
|
'_EMACS_INTERNAL))
|
|
|
|
|
selection-converter-alist)))))))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-delete (selection _type _value)
|
2022-04-02 06:59:08 +00:00
|
|
|
|
;; This should be handled by the caller of `x-begin-drag'.
|
|
|
|
|
(unless (eq selection 'XdndSelection)
|
|
|
|
|
(gui-backend-set-selection selection nil))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
;; 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.
|
|
|
|
|
'NULL)
|
|
|
|
|
|
2022-04-01 01:50:58 +00:00
|
|
|
|
(defun xselect-convert-to-filename (selection _type value)
|
|
|
|
|
(if (not (eq selection 'XdndSelection))
|
|
|
|
|
(when (setq value (xselect--selection-bounds value))
|
|
|
|
|
(xselect--encode-string 'TEXT (buffer-file-name (nth 2 value))))
|
2022-06-03 11:43:06 +00:00
|
|
|
|
(if (and (stringp value)
|
|
|
|
|
(file-exists-p value))
|
2022-06-05 07:34:49 +00:00
|
|
|
|
;; Motif expects this to be STRING, but it treats the data as
|
|
|
|
|
;; a sequence of bytes instead of a Latin-1 string.
|
|
|
|
|
(cons 'STRING (encode-coding-string (expand-file-name value)
|
2022-06-05 13:16:09 +00:00
|
|
|
|
(or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system)))
|
2022-06-03 11:43:06 +00:00
|
|
|
|
(when (vectorp value)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(cl-loop for file across value
|
2022-06-05 07:34:49 +00:00
|
|
|
|
do (insert (expand-file-name file) "\0"))
|
2022-06-03 11:43:06 +00:00
|
|
|
|
;; Get rid of the last NULL byte.
|
|
|
|
|
(when (> (point) 1)
|
|
|
|
|
(delete-char -1))
|
|
|
|
|
;; Motif wants STRING.
|
2022-06-05 07:34:49 +00:00
|
|
|
|
(cons 'STRING (encode-coding-string (buffer-string)
|
2022-06-05 13:16:09 +00:00
|
|
|
|
(or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system))))))))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-charpos (_selection _type value)
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(when (setq value (xselect--selection-bounds value))
|
|
|
|
|
(let ((beg (1- (nth 0 value))) ; zero-based
|
|
|
|
|
(end (1- (nth 1 value))))
|
|
|
|
|
(cons 'SPAN (vector (xselect--int-to-cons (min beg end))
|
|
|
|
|
(xselect--int-to-cons (max beg end)))))))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-lineno (_selection _type value)
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(when (setq value (xselect--selection-bounds value))
|
|
|
|
|
(with-current-buffer (nth 2 value)
|
|
|
|
|
(let ((beg (line-number-at-pos (nth 0 value)))
|
|
|
|
|
(end (line-number-at-pos (nth 1 value))))
|
|
|
|
|
(cons 'SPAN (vector (xselect--int-to-cons (min beg end))
|
|
|
|
|
(xselect--int-to-cons (max beg end))))))))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-colno (_selection _type value)
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(when (setq value (xselect--selection-bounds value))
|
|
|
|
|
(with-current-buffer (nth 2 value)
|
|
|
|
|
(let ((beg (progn (goto-char (nth 0 value)) (current-column)))
|
|
|
|
|
(end (progn (goto-char (nth 1 value)) (current-column))))
|
|
|
|
|
(cons 'SPAN (vector (xselect--int-to-cons (min beg end))
|
|
|
|
|
(xselect--int-to-cons (max beg end))))))))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-os (_selection _type _size)
|
2012-04-24 05:34:50 +00:00
|
|
|
|
(xselect--encode-string 'TEXT (symbol-name system-type)))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-host (_selection _type _size)
|
2012-04-24 05:34:50 +00:00
|
|
|
|
(xselect--encode-string 'TEXT (system-name)))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-user (_selection _type _size)
|
2012-04-24 05:34:50 +00:00
|
|
|
|
(xselect--encode-string 'TEXT (user-full-name)))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-class (_selection _type _size)
|
2001-12-14 19:58:10 +00:00
|
|
|
|
"Convert selection to class.
|
|
|
|
|
This function returns the string \"Emacs\"."
|
1993-05-18 23:25:21 +00:00
|
|
|
|
"Emacs")
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
|
|
|
|
;; We do not try to determine the name Emacs was invoked with,
|
|
|
|
|
;; because it is not clean for a program's behavior to depend on that.
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-name (_selection _type _size)
|
2001-12-14 19:58:10 +00:00
|
|
|
|
"Convert selection to name.
|
|
|
|
|
This function returns the string \"emacs\"."
|
1993-03-17 17:19:16 +00:00
|
|
|
|
"emacs")
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-integer (_selection _type value)
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(and (integerp value)
|
2009-07-14 16:58:25 +00:00
|
|
|
|
(xselect--int-to-cons value)))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-atom (_selection _type value)
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(and (symbolp value) value))
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun xselect-convert-to-identity (_selection _type value) ; used internally
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(vector value))
|
|
|
|
|
|
2011-05-27 16:17:59 +00:00
|
|
|
|
;; Null target that tells clipboard managers we support SAVE_TARGETS
|
|
|
|
|
;; (see freedesktop.org Clipboard Manager spec).
|
|
|
|
|
(defun xselect-convert-to-save-targets (selection _type _value)
|
|
|
|
|
(when (eq selection 'CLIPBOARD)
|
|
|
|
|
'NULL))
|
|
|
|
|
|
2022-03-18 05:17:19 +00:00
|
|
|
|
(defun xselect-convert-to-username (_selection _type _value)
|
|
|
|
|
(user-real-login-name))
|
|
|
|
|
|
2023-05-03 12:02:01 +00:00
|
|
|
|
(defun xselect-convert-to-text-uri-list (selection _type value)
|
|
|
|
|
;; While `xselect-uri-list-available-p' ensures that this target
|
|
|
|
|
;; will not be reported in the TARGETS of non-drag-and-drop
|
|
|
|
|
;; selections, Firefox stupidly converts to it anyway. Check that
|
|
|
|
|
;; the conversion request is being made for the correct selection.
|
|
|
|
|
(and (eq selection 'XdndSelection)
|
|
|
|
|
(let ((string
|
|
|
|
|
(if (stringp value)
|
|
|
|
|
(xselect--encode-string 'TEXT
|
|
|
|
|
(concat (url-encode-url value) "\n"))
|
|
|
|
|
(when (vectorp value)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(cl-loop for tem across value
|
|
|
|
|
do (progn
|
|
|
|
|
(insert (url-encode-url tem))
|
|
|
|
|
(insert "\n")))
|
|
|
|
|
(xselect--encode-string 'TEXT (buffer-string)))))))
|
|
|
|
|
(cons 'text/uri-list (cdr string)))))
|
2022-03-18 05:17:19 +00:00
|
|
|
|
|
2022-04-01 01:50:58 +00:00
|
|
|
|
(defun xselect-convert-to-xm-file (selection _type value)
|
|
|
|
|
(when (and (stringp value)
|
|
|
|
|
(file-exists-p value)
|
|
|
|
|
(eq selection 'XdndSelection))
|
|
|
|
|
(xselect--encode-string 'C_STRING
|
|
|
|
|
(concat value [0]))))
|
|
|
|
|
|
2022-03-18 05:17:19 +00:00
|
|
|
|
(defun xselect-uri-list-available-p (selection _type value)
|
2022-07-29 06:31:26 +00:00
|
|
|
|
"Return non-nil if `text/uri-list' is a valid target for SELECTION.
|
|
|
|
|
Return nil otherwise.
|
2022-03-18 05:17:19 +00:00
|
|
|
|
VALUE is the local selection value of SELECTION."
|
|
|
|
|
(and (eq selection 'XdndSelection)
|
2022-06-01 08:25:53 +00:00
|
|
|
|
(or (stringp value)
|
|
|
|
|
(vectorp value))))
|
2022-03-18 05:17:19 +00:00
|
|
|
|
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(defun xselect-convert-xm-special (_selection _type _value)
|
|
|
|
|
"")
|
|
|
|
|
|
2022-05-28 08:48:49 +00:00
|
|
|
|
(defun xselect-dt-netfile-available-p (selection _type value)
|
2022-07-29 06:31:26 +00:00
|
|
|
|
"Return non-nil if `_DT_NETFILE' is a valid target for SELECTION.
|
|
|
|
|
Return nil otherwise.
|
2022-05-28 08:48:49 +00:00
|
|
|
|
VALUE is SELECTION's local selection value."
|
|
|
|
|
(and (eq selection 'XdndSelection)
|
|
|
|
|
(stringp value)
|
|
|
|
|
(file-exists-p value)
|
|
|
|
|
(not (file-remote-p value))))
|
|
|
|
|
|
2022-07-29 00:50:55 +00:00
|
|
|
|
(defun xselect-dnd-target-available-p (selection _type _value)
|
2022-07-29 06:31:26 +00:00
|
|
|
|
"Return non-nil if TYPE is a valid target for SELECTION.
|
|
|
|
|
Return nil otherwise.
|
2022-07-29 00:50:55 +00:00
|
|
|
|
VALUE is SELECTION's local selection value."
|
|
|
|
|
(eq selection 'XdndSelection))
|
|
|
|
|
|
2022-05-28 08:48:49 +00:00
|
|
|
|
(defun xselect-tt-net-file (file)
|
|
|
|
|
"Get the canonical ToolTalk filename for FILE.
|
|
|
|
|
FILE must be a local file, or otherwise the conversion will fail.
|
|
|
|
|
The string returned has three components: the hostname of the
|
|
|
|
|
machine where the file is, the real path, and the local path.
|
|
|
|
|
They are encoded into a string of the form
|
|
|
|
|
\"HOST=0-X,RPATH=X-Y,LPATH=Y-Z:DATA\", where X, Y, and Z are the
|
|
|
|
|
positions of the hostname, rpath and lpath inside DATA."
|
|
|
|
|
(let ((hostname (system-name))
|
|
|
|
|
(rpath file)
|
|
|
|
|
(lpath file))
|
|
|
|
|
(format "HOST=0-%d,RPATH=%d-%d,LPATH=%d-%d:%s%s%s"
|
|
|
|
|
(1- (length hostname)) (length hostname)
|
|
|
|
|
(1- (+ (length hostname) (length rpath)))
|
|
|
|
|
(+ (length hostname) (length rpath))
|
|
|
|
|
(1- (+ (length hostname) (length rpath)
|
|
|
|
|
(length lpath)))
|
|
|
|
|
hostname rpath lpath)))
|
|
|
|
|
|
|
|
|
|
(defun xselect-convert-to-dt-netfile (selection _type value)
|
|
|
|
|
"Convert SELECTION to a ToolTalk filename.
|
|
|
|
|
VALUE should be SELECTION's local value."
|
|
|
|
|
(when (and (eq selection 'XdndSelection)
|
|
|
|
|
(stringp value)
|
|
|
|
|
(file-exists-p value)
|
|
|
|
|
(not (file-remote-p value)))
|
2022-06-12 14:04:47 +00:00
|
|
|
|
(let ((name (encode-coding-string value
|
|
|
|
|
(or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system))))
|
|
|
|
|
(cons 'STRING
|
|
|
|
|
(encode-coding-string (xselect-tt-net-file name)
|
|
|
|
|
(or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system)
|
|
|
|
|
t)))))
|
2022-05-28 08:48:49 +00:00
|
|
|
|
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(setq selection-converter-alist
|
|
|
|
|
'((TEXT . xselect-convert-to-string)
|
1997-02-20 05:49:58 +00:00
|
|
|
|
(COMPOUND_TEXT . xselect-convert-to-string)
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(STRING . xselect-convert-to-string)
|
2002-08-14 00:57:55 +00:00
|
|
|
|
(UTF8_STRING . xselect-convert-to-string)
|
2022-03-16 09:03:19 +00:00
|
|
|
|
(text/plain . xselect-convert-to-string)
|
|
|
|
|
(text/plain\;charset=utf-8 . xselect-convert-to-string)
|
2022-05-28 08:48:49 +00:00
|
|
|
|
(text/uri-list . (xselect-uri-list-available-p
|
|
|
|
|
. xselect-convert-to-text-uri-list))
|
2022-07-29 00:50:55 +00:00
|
|
|
|
(text/x-xdnd-username . (xselect-dnd-target-available-p
|
|
|
|
|
. xselect-convert-to-username))
|
2022-05-28 08:48:49 +00:00
|
|
|
|
(FILE . (xselect-uri-list-available-p
|
|
|
|
|
. xselect-convert-to-xm-file))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
(TARGETS . xselect-convert-to-targets)
|
|
|
|
|
(LENGTH . xselect-convert-to-length)
|
|
|
|
|
(DELETE . xselect-convert-to-delete)
|
|
|
|
|
(FILE_NAME . xselect-convert-to-filename)
|
|
|
|
|
(CHARACTER_POSITION . xselect-convert-to-charpos)
|
|
|
|
|
(LINE_NUMBER . xselect-convert-to-lineno)
|
|
|
|
|
(COLUMN_NUMBER . xselect-convert-to-colno)
|
|
|
|
|
(OWNER_OS . xselect-convert-to-os)
|
|
|
|
|
(HOST_NAME . xselect-convert-to-host)
|
|
|
|
|
(USER . xselect-convert-to-user)
|
|
|
|
|
(CLASS . xselect-convert-to-class)
|
|
|
|
|
(NAME . xselect-convert-to-name)
|
|
|
|
|
(ATOM . xselect-convert-to-atom)
|
|
|
|
|
(INTEGER . xselect-convert-to-integer)
|
2011-05-27 16:17:59 +00:00
|
|
|
|
(SAVE_TARGETS . xselect-convert-to-save-targets)
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(_EMACS_INTERNAL . xselect-convert-to-identity)
|
2022-07-29 00:50:55 +00:00
|
|
|
|
(XmTRANSFER_SUCCESS . (xselect-dnd-target-available-p
|
|
|
|
|
. xselect-convert-xm-special))
|
|
|
|
|
(XmTRANSFER_FAILURE . (xselect-dnd-target-available-p
|
|
|
|
|
. xselect-convert-xm-special))
|
2022-06-08 02:40:20 +00:00
|
|
|
|
(_DT_NETFILE . (xselect-dt-netfile-available-p
|
|
|
|
|
. xselect-convert-to-dt-netfile))))
|
1993-03-17 17:19:16 +00:00
|
|
|
|
|
|
|
|
|
(provide 'select)
|
|
|
|
|
|
2001-07-15 19:53:53 +00:00
|
|
|
|
;;; select.el ends here
|