[Top][All Lists]

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

Re: `M-x yank-media'

From: Lars Ingebrigtsen
Subject: Re: `M-x yank-media'
Date: Mon, 08 Nov 2021 05:55:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Richard Stallman <rms@gnu.org> writes:

> It sounds exciting -- could you say a little more about how
> it behaves?

>From the manual:

@node Yanking Media
@section Yanking Media

  If you choose, for instance, ``Copy Image'' in a web browser, that
image is put onto the clipboard, and Emacs can access it via
@code{gui-get-selection}.  But in general, inserting image data into
an arbitrary buffer isn't very useful---you can't really do much with
it by default.

  So Emacs has a system to let modes register handlers for these
``complicated'' selections.

@defun yank-media-handler types handler
@var{types} can be a @acronym{MIME} media type symbol, a regexp to
match these, or a list of these symbols and regexps.  For instance:

(yank-media-handler 'text/html #'my-html-handler)
(yank-media-handler "image/.*" #'my-image-handler)
@end example

A mode can register as many handlers as required.

  The @var{handler} function is called with two parameters: The
@acronym{MIME} media type symbol and the data (as a string).  The
handler should then insert the object into the buffer, or save it, or
do whatever is appropriate for the mode.
@end defun

  The @code{yank-media} command will consult the registered handlers in
the current buffer, compare that with the available media types on the
clipboard, and then pass on the matching selection to the handler (if
any).  If there's more than one matching selection, the user is
queried first.

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

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