* 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'.
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.
* 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.
Though not itself a regression, this bug was exposed by the support
for MULTIPLE selections, which is new to Emacs 24 (see Bug#11315).
* lisp/select.el (xselect--encode-string): New function, split from
xselect-convert-to-string.
(xselect-convert-to-string): Use it.
(xselect-convert-to-filename, xselect-convert-to-os)
(xselect-convert-to-host, xselect-convert-to-user): Ensure that
returned strings are properly encoded.
* lisp/select.el (xselect-convert-to-targets): Add MULTIPLE target to list.
(xselect-convert-to-save-targets): New function.
* src/xselect.c: Support for clipboard managers.
(Vselection_alist): Move to termhooks.h as terminal-local var.
(LOCAL_SELECTION): New macro.
(x_atom_to_symbol): Handle x_display_info_for_display fail case.
(symbol_to_x_atom): Remove gratuitous arg.
(x_handle_selection_request, lisp_data_to_selection_data)
(x_get_foreign_selection, Fx_register_dnd_atom): Callers changed.
(x_own_selection, x_get_local_selection, x_convert_selection): New
arg, specifying work frame. Use terminal-local Vselection_alist.
(some_frame_on_display): Delete unused function.
(Fx_own_selection_internal, Fx_get_selection_internal)
(Fx_disown_selection_internal, Fx_selection_owner_p)
(Fx_selection_exists_p): New optional frame arg.
(frame_for_x_selection, Fx_clipboard_manager_save): New functions.
(x_handle_selection_clear): Don't treat other terminals with the
same keyboard specially. Use the terminal-local Vselection_alist.
(x_clear_frame_selections): Use Frun_hook_with_args.
* src/termhooks.h (Vselection_alist): Make it terminal-local.
* src/terminal.c (create_terminal): Initialize it.
* src/xterm.c (x_term_init): Intern ATOM and CLIPBOARD_MANAGER atoms.
* src/xterm.h: Add support for those atoms.
(set-mark): Use deactivate-mark.
* info.el (Info-search): No need to check transient-mark-mode
before calling deactivate-mark.
* select.el (x-set-selection): Doc fix.
(x-valid-simple-selection-p): Allow buffer values.
(xselect--selection-bounds): Handle buffer values. Suggested by
David De La Harpe Golden.
* mouse.el (mouse-set-region, mouse-drag-track): Call
copy-region-as-kill before setting the mark, to let
select-active-regions work.
* simple.el (deactivate-mark): If select-active-regions is
non-nil, copy the selection data into a string.
(activate-mark): If select-active-regions is non-nil, set the
selection to the current buffer.
(set-mark): Update selection if select-active-regions is non-nil.
* select.el (x-valid-simple-selection-p): Allow buffer values.
(x-valid-simple-selection-p): Disallow selection data consisting
of a list or cons of integers, since that is not used.
(xselect--selection-bounds, xselect--int-to-cons): New functions.
(xselect-convert-to-string, xselect-convert-to-length)
(xselect-convert-to-filename, xselect-convert-to-charpos)
(xselect-convert-to-lineno, xselect-convert-to-colno): Use them.