summaryrefslogtreecommitdiff
path: root/doc/lispref
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-11-06 21:59:22 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-06 21:59:27 +0100
commit48ca3c99c8121007eef38d457ddc25158118a8d3 (patch)
tree8de1fa0946eab1330e6fc494a1edd0cb989229a6 /doc/lispref
parent5a4f98b0b6d503b1ce68bb29937a84acf3ef97da (diff)
downloademacs-48ca3c99c8121007eef38d457ddc25158118a8d3.tar.gz
emacs-48ca3c99c8121007eef38d457ddc25158118a8d3.tar.bz2
emacs-48ca3c99c8121007eef38d457ddc25158118a8d3.zip
Add a framework for yanking media into Emacs
* doc/emacs/killing.texi (Clipboard): Refer to it. * doc/lispref/frames.texi (Yanking Media): Document the mechanism. * lisp/yank-media.el: New file. * lisp/gnus/message.el (message-mode): Register a yank handler for images. (message-insert-screenshot): Factor out image code from here... (message--yank-media-image-handler): ... to here.
Diffstat (limited to 'doc/lispref')
-rw-r--r--doc/lispref/elisp.texi1
-rw-r--r--doc/lispref/frames.texi36
2 files changed, 37 insertions, 0 deletions
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 6057691239f..d0bfd8c9019 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -1123,6 +1123,7 @@ Frames
* Dialog Boxes:: Displaying a box to ask yes or no.
* Pointer Shape:: Specifying the shape of the mouse pointer.
* Window System Selections::Transferring text to and from other X clients.
+* Yanking Media:: Yanking things that aren't plain text.
* Drag and Drop:: Internals of Drag-and-Drop implementation.
* Color Names:: Getting the definitions of color names.
* Text Terminal Colors:: Defining colors for text terminals.
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 56ac7118135..a706dc76d25 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -105,6 +105,7 @@ window of another Emacs frame. @xref{Child Frames}.
* Dialog Boxes:: Displaying a box to ask yes or no.
* Pointer Shape:: Specifying the shape of the mouse pointer.
* Window System Selections:: Transferring text to and from other X clients.
+* Yanking Media:: Yanking things that aren't plain text.
* Drag and Drop:: Internals of Drag-and-Drop implementation.
* Color Names:: Getting the definitions of color names.
* Text Terminal Colors:: Defining colors for text terminals.
@@ -3923,6 +3924,41 @@ For backward compatibility, there are obsolete aliases
names of @code{gui-get-selection} and @code{gui-set-selection} before
Emacs 25.1.
+@node Yanking Media
+@subsection 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 register-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:
+
+@example
+(register-yank-media-handler 'text/html #'my-html-handler)
+(register-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.
+
@node Drag and Drop
@section Drag and Drop
@cindex drag and drop