From: Po Lu Date: Wed, 1 Jun 2022 08:39:26 +0000 (+0000) Subject: Adjust last change to Haiku as well X-Git-Tag: emacs-29.0.90~1910^2~295^2~23 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=495c93d015534d6c8b6940623c5cbb0b2b493b2e;p=emacs.git Adjust last change to Haiku as well * lisp/term/haiku-win.el (haiku-dnd-selection-converters): Add text/uri-list. (haiku-dnd-convert-text-uri-list): New function. (x-begin-drag): Handle alternative data specified in selection local values. --- diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el index a8cc1da731a..2a31dd38c81 100644 --- a/lisp/term/haiku-win.el +++ b/lisp/term/haiku-win.el @@ -52,7 +52,8 @@ "The local value of the special `XdndSelection' selection.") (defvar haiku-dnd-selection-converters '((STRING . haiku-dnd-convert-string) - (FILE_NAME . haiku-dnd-convert-file-name)) + (FILE_NAME . haiku-dnd-convert-file-name) + (text/uri-list . haiku-dnd-convert-text-uri-list)) "Alist of X selection types to functions that act as selection converters. The functions should accept a single argument VALUE, describing the value of the drag-and-drop selection, and return a list of @@ -148,6 +149,19 @@ VALUE as a unibyte string, or nil if VALUE was not a string." (file-exists-p value)) (list "refs" (propertize (expand-file-name value) 'type 'ref)))) +(defun haiku-dnd-convert-text-uri-list (value) + "Convert VALUE to a list of URLs." + (cond + ((stringp value) (list "text/uri-list" + (concat (url-encode-url value) "\n"))) + ((vectorp value) (list "text/uri-list" + (with-temp-buffer + (cl-loop for tem across value + do (progn + (insert (url-encode-url tem)) + (insert "\n"))) + (buffer-string)))))) + (declare-function x-open-connection "haikufns.c") (declare-function x-handle-args "common-win") (declare-function haiku-selection-data "haikuselect.c") @@ -341,12 +355,17 @@ take effect on menu items until the menu bar is updated again." (mouse-highlight nil) (haiku-signal-invalid-refs nil)) (dolist (target targets) - (let ((selection-converter (cdr (assoc (intern target) - haiku-dnd-selection-converters)))) + (let* ((target-atom (intern target)) + (selection-converter (cdr (assoc target-atom + haiku-dnd-selection-converters)))) (when selection-converter (let ((selection-result (funcall selection-converter - haiku-dnd-selection-value))) + (if (stringp haiku-dnd-selection-value) + (or (get-text-property 0 target-atom + haiku-dnd-selection-value) + haiku-dnd-selection-value) + haiku-dnd-selection-value)))) (when selection-result (let ((field (cdr (assoc (car selection-result) message)))) (unless (cadr field)