diff options
author | Po Lu <luangruo@yahoo.com> | 2022-06-01 16:25:53 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-06-01 16:25:53 +0800 |
commit | f5fadbbfec8c8f5d66fe0169c92096743102990e (patch) | |
tree | a6ff21acff44d0c0d26922bbdf9b69c1ca676703 /lisp/select.el | |
parent | a3d3fef2bc60f05f30350ef1cc0bb66e8f7010c7 (diff) | |
download | emacs-f5fadbbfec8c8f5d66fe0169c92096743102990e.tar.gz |
Clean up text/uri-list mess inside the Dired drag-and-drop code
* doc/lispref/frames.texi (Window System Selections):
* etc/NEWS: Document new changes to `gui-get-selection'.
* lisp/dired.el (dired-mouse-drag): Specify text/uri-list value
explicitly.
* lisp/select.el (gui-set-selection): Update doc string.
(xselect-convert-to-text-uri-list): Update to handle either a
single URL (as a string) or a vector of URLs, instead of file
names.
(xselect-uri-list-available-p): Likewise.
* src/xselect.c (x_get_local_selection): Look in tem's text
properties (if it is a string) for a local value before using
tem itself.
Diffstat (limited to 'lisp/select.el')
-rw-r--r-- | lisp/select.el | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/lisp/select.el b/lisp/select.el index dbe9633517f..01e002db709 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -401,11 +401,16 @@ 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. -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. +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'. The data may also be a vector of valid non-vector selection values. @@ -692,18 +697,15 @@ This function returns the string \"emacs\"." (user-real-login-name)) (defun xselect-convert-to-text-uri-list (_selection _type value) - (when (and (stringp value) - (file-exists-p value)) - (concat (url-encode-url - ;; Uncomment the following code code in a better world where - ;; people write correct code that adds the hostname to the URI. - ;; Since most programs don't implement this properly, we omit the - ;; hostname so that copying files actually works. Most properly - ;; written programs will look at WM_CLIENT_MACHINE to determine - ;; the hostname anyway. (format "file://%s%s\n" (system-name) - ;; (expand-file-name value)) - (concat "file://" (expand-file-name value))) - "\n"))) + (if (stringp value) + (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"))) + (buffer-string))))) (defun xselect-convert-to-xm-file (selection _type value) (when (and (stringp value) @@ -716,8 +718,8 @@ This function returns the string \"emacs\"." "Return whether or not `text/uri-list' is a valid target for SELECTION. VALUE is the local selection value of SELECTION." (and (eq selection 'XdndSelection) - (stringp value) - (file-exists-p value))) + (or (stringp value) + (vectorp value)))) (defun xselect-convert-xm-special (_selection _type _value) "") |