emacs-diffs
[Top][All Lists]
Advanced

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

master 6044efe76e: Fix file name selection conversion on Haiku


From: Po Lu
Subject: master 6044efe76e: Fix file name selection conversion on Haiku
Date: Fri, 29 Apr 2022 00:22:53 -0400 (EDT)

branch: master
commit 6044efe76e8baec4395449675f4ad662183f2f85
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix file name selection conversion on Haiku
    
    * lisp/term/haiku-win.el (haiku-normal-selection-encoders):
    Register new encoder.
    (haiku-select-encode-file-name): New function.
---
 lisp/term/haiku-win.el | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el
index 403c737c11..0921079246 100644
--- a/lisp/term/haiku-win.el
+++ b/lisp/term/haiku-win.el
@@ -65,7 +65,8 @@ the type of DATA inside the system message (see the doc 
string of
 `haiku-drag-message' for more details).")
 
 (defvar haiku-normal-selection-encoders '(haiku-select-encode-xstring
-                                          haiku-select-encode-utf-8-string)
+                                          haiku-select-encode-utf-8-string
+                                          haiku-select-encode-file-name)
   "List of functions which act as selection encoders.
 These functions accept two arguments SELECTION and VALUE, and
 return an association appropriate for a serialized system
@@ -226,6 +227,13 @@ VALUE will be encoded as UTF-8 and stored under the type
     (list "text/plain" 1296649541
           (encode-coding-string value 'utf-8-unix))))
 
+(defun haiku-select-encode-file-name (_selection value)
+  "Convert VALUE to a system message association.
+This takes the file name of VALUE's buffer (if it is an overlay
+or a pair of markers) and turns it into a file system reference."
+  (when (setq value (xselect--selection-bounds value))
+    (list "refs" 'ref (buffer-file-name (nth 2 value)))))
+
 (cl-defmethod gui-backend-get-selection (type data-type
                                               &context (window-system haiku))
   (if (eq data-type 'TARGETS)
@@ -297,8 +305,7 @@ VALUE will be encoded as UTF-8 and stored under the type
         (message "Don't know how to drop any of: %s"
                  (mapcar #'car string)))))))
 
-(define-key special-event-map [drag-n-drop]
-            'haiku-drag-and-drop)
+(define-key special-event-map [drag-n-drop] 'haiku-drag-and-drop)
 
 (defvaralias 'haiku-use-system-tooltips 'use-system-tooltips)
 



reply via email to

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