emacs-diffs
[Top][All Lists]
Advanced

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

master e96e6a1: Allow yank-media-types to also show the unsupported data


From: Lars Ingebrigtsen
Subject: master e96e6a1: Allow yank-media-types to also show the unsupported data types
Date: Mon, 8 Nov 2021 22:41:21 -0500 (EST)

branch: master
commit e96e6a1ba5983d3a679443f5338518df17a75cce
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Allow yank-media-types to also show the unsupported data types
    
    * lisp/yank-media.el (yank-media-types): Make the prefix include
    data types not supported by the backend, too.
---
 lisp/yank-media.el | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/lisp/yank-media.el b/lisp/yank-media.el
index 38a5668..decab3b 100644
--- a/lisp/yank-media.el
+++ b/lisp/yank-media.el
@@ -100,13 +100,19 @@ data (a string)."
     (setf (alist-get type yank-media--registered-handlers nil nil #'equal)
           handler)))
 
-(defun yank-media-types ()
+(defun yank-media-types (&optional all)
   "Yank any element present in the primary selection or the clipboard.
 This is primarily meant as a debugging tool -- many of the
 elements (like images) will be inserted as raw data into the
 current buffer.  See `yank-media' instead for a command that
-inserts images as images."
-  (interactive)
+inserts images as images.
+
+By default, data types that aren't supported by
+`gui-get-selection' (i.e., that returns nothing if you actually
+try to look at the selection) are not included by this command.
+If ALL (interactively, the prefix), also include these
+non-supported selection data types."
+  (interactive "P")
   (let ((elements nil))
     ;; First gather all the data.
     (dolist (type '(PRIMARY CLIPBOARD))
@@ -115,15 +121,16 @@ inserts images as images."
           (seq-do (lambda (data-type)
                     (unless (memq data-type '( TARGETS MULTIPLE
                                                DELETE SAVE_TARGETS))
-                      (when-let ((data (gui-get-selection type data-type)))
-                        ;; Remove duplicates -- the data in PRIMARY and
-                        ;; CLIPBOARD are sometimes (mostly) identical,
-                        ;; and sometimes not.
-                        (let ((old (assq data-type elements)))
-                          (when (or (not old)
-                                    (not (equal (nth 2 old) data)))
-                            (push (list data-type type data)
-                                  elements))))))
+                      (let ((data (gui-get-selection type data-type)))
+                        (when (or data all)
+                          ;; Remove duplicates -- the data in PRIMARY and
+                          ;; CLIPBOARD are sometimes (mostly) identical,
+                          ;; and sometimes not.
+                          (let ((old (assq data-type elements)))
+                            (when (or (not old)
+                                      (not (equal (nth 2 old) data)))
+                              (push (list data-type type data)
+                                    elements)))))))
                   data-types))))
     ;; Then query the user.
     (unless elements



reply via email to

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