Function: yank-media-types
yank-media-types is an interactive and byte-compiled function defined
in yank-media.el.gz.
Signature
(yank-media-types &optional ALL)
Documentation
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.
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.
Probably introduced at or before Emacs version 29.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/yank-media.el.gz
(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.
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))
(when-let* ((data-types (gui-get-selection type 'TARGETS)))
(when (vectorp data-types)
(seq-do (lambda (data-type)
(unless (memq data-type '( TARGETS MULTIPLE
DELETE SAVE_TARGETS))
(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
(user-error "No elements in the primary selection or the clipboard"))
(let ((spec
(completing-read
"Yank type: "
(mapcar (lambda (e)
(format "%s:%s" (downcase (symbol-name (cadr e)))
(car e)))
elements)
nil t)))
(dolist (elem elements)
(when (equal (format "%s:%s" (downcase (symbol-name (cadr elem)))
(car elem))
spec)
(insert (yank-media-types--format (car elem) (nth 2 elem))))))))