summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-11-09 04:41:14 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-09 04:41:14 +0100
commite96e6a1ba5983d3a679443f5338518df17a75cce (patch)
tree666d30e09ec851114830c02ece4da884d645206e
parent3fd0e7fba6fed9f7e5e30d2d31102b210291993a (diff)
downloademacs-e96e6a1ba5983d3a679443f5338518df17a75cce.tar.gz
emacs-e96e6a1ba5983d3a679443f5338518df17a75cce.tar.bz2
emacs-e96e6a1ba5983d3a679443f5338518df17a75cce.zip
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.
-rw-r--r--lisp/yank-media.el31
1 files changed, 19 insertions, 12 deletions
diff --git a/lisp/yank-media.el b/lisp/yank-media.el
index 38a56684de9..decab3b3625 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