emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 540e7298a9: Make dropping files on Motif programs work


From: Po Lu
Subject: master 540e7298a9: Make dropping files on Motif programs work
Date: Thu, 31 Mar 2022 21:51:11 -0400 (EDT)

branch: master
commit 540e7298a96e4e1668bd7f7b5540653391b3f534
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Make dropping files on Motif programs work
    
    * lisp/dired.el (dired-mouse-drag): Announce "FILE" and
    "FILE_NAME" as targets as well.
    * lisp/select.el (xselect-convert-to-filename): Handle
    XdndSelection specially.
    (xselect-convert-to-xm-file): New function.
    (selection-converter-alist): Add new converters.
---
 lisp/dired.el  |  4 ++--
 lisp/select.el | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 0b5f2cab41..0524ac16c2 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1749,8 +1749,8 @@ when Emacs exits or the user drags another file.")
                     (add-hook 'kill-emacs-hook
                               #'dired-remove-last-dragged-local-file))
                   (gui-backend-set-selection 'XdndSelection filename)
-                  (x-begin-drag '("text/uri-list"
-                                  "text/x-dnd-username")
+                  (x-begin-drag '("text/uri-list" "text/x-dnd-username"
+                                  "FILE_NAME" "FILE")
                                 (if (eq 'dired-mouse-drag-files 'link)
                                     'XdndActionLink
                                   'XdndActionCopy)
diff --git a/lisp/select.el b/lisp/select.el
index ee65678c69..c352a48261 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -567,9 +567,13 @@ two markers or an overlay.  Otherwise, it is nil."
   ;; done the conversion (and any side-effects) but have no value to return.
   'NULL)
 
-(defun xselect-convert-to-filename (_selection _type value)
-  (when (setq value (xselect--selection-bounds value))
-    (xselect--encode-string 'TEXT (buffer-file-name (nth 2 value)))))
+(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))))
+    (when (and (stringp value)
+               (file-exists-p value))
+      (xselect--encode-string 'C_STRING value))))
 
 (defun xselect-convert-to-charpos (_selection _type value)
   (when (setq value (xselect--selection-bounds value))
@@ -648,6 +652,13 @@ This function returns the string \"emacs\"."
              (concat "file://" (expand-file-name value)))
             "\n")))
 
+(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]))))
+
 (defun xselect-uri-list-available-p (selection _type value)
   "Return whether or not `text/uri-list' is a valid target for SELECTION.
 VALUE is the local selection value of SELECTION."
@@ -667,6 +678,7 @@ VALUE is the local selection value of SELECTION."
        (text/plain\;charset=utf-8 . xselect-convert-to-string)
         (text/uri-list . (xselect-uri-list-available-p . 
xselect-convert-to-text-uri-list))
         (text/x-xdnd-username . xselect-convert-to-username)
+        (FILE . (xselect-uri-list-available-p . xselect-convert-to-xm-file))
        (TARGETS . xselect-convert-to-targets)
        (LENGTH . xselect-convert-to-length)
        (DELETE . xselect-convert-to-delete)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]