diff options
| author | Po Lu | 2023-10-23 11:11:30 +0000 |
|---|---|---|
| committer | Po Lu | 2023-10-23 11:16:07 +0000 |
| commit | baf14aa16accc97db32723d13fb65a5e8ead4d47 (patch) | |
| tree | 346f14421571316ccdc2bcbe9bd9a3f62b1ab3cc | |
| parent | 7e87b145fc0babb1cf7fcd00d381d6a70bdbcf6d (diff) | |
| download | emacs-baf14aa16accc97db32723d13fb65a5e8ead4d47.tar.gz emacs-baf14aa16accc97db32723d13fb65a5e8ead4d47.zip | |
Rewrite Yank Media node in the Emacs Lisp manual
* doc/lispref/frames.texi (Other Selections): Introduce a
reference to Accessing Selections, then rewrite for clarity and
to stop mentioning MIME types by name, for selection data types
are not confined to those.
| -rw-r--r-- | doc/lispref/frames.texi | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 5203e2ae7da..d840f281849 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi | |||
| @@ -4668,43 +4668,38 @@ set string data, as on MS-Windows. | |||
| 4668 | @node Yanking Media | 4668 | @node Yanking Media |
| 4669 | @section Yanking Media | 4669 | @section Yanking Media |
| 4670 | 4670 | ||
| 4671 | If you choose, for instance, ``Copy Image'' in a web browser, that | 4671 | Data saved within window system selections is not restricted to |
| 4672 | image is put onto the clipboard, and Emacs can access it via | 4672 | plain text. It is possible for selection data to encompass images or |
| 4673 | @code{gui-get-selection}. But in general, inserting image data into | 4673 | other binary data of the like, as well as rich text content instanced |
| 4674 | an arbitrary buffer isn't very useful---you can't really do much with | 4674 | by HTML, and also PostScript. Since the selection data types incident |
| 4675 | it by default. | 4675 | to this data are at variance with those for plain text, the insertion |
| 4676 | 4676 | of such data is facilitated by a set of functions dubbed | |
| 4677 | So Emacs has a system to let modes register handlers for these | 4677 | @dfn{yank-media handlers}, which are registered by each major mode |
| 4678 | ``complicated'' selections. | 4678 | undertaking its insertion and called where warranted upon the |
| 4679 | execution of the @code{yank-media} command. | ||
| 4679 | 4680 | ||
| 4680 | @defun yank-media-handler types handler | 4681 | @defun yank-media-handler types handler |
| 4681 | @var{types} can be a @acronym{MIME} media type symbol, a regexp to | 4682 | Register a yank-media handler which applies to the current buffer. |
| 4682 | match these, or a list of these symbols and regexps. For instance: | 4683 | |
| 4684 | @var{types} can be a symbol designating a selection data type | ||
| 4685 | (@pxref{Accessing Selections}), a regexp against which such types are | ||
| 4686 | matched, or a list of these symbols and regexps. For instance: | ||
| 4683 | 4687 | ||
| 4684 | @example | 4688 | @example |
| 4685 | (yank-media-handler 'text/html #'my-html-handler) | 4689 | (yank-media-handler 'text/html #'my-html-handler) |
| 4686 | (yank-media-handler "image/.*" #'my-image-handler) | 4690 | (yank-media-handler "image/.*" #'my-image-handler) |
| 4687 | @end example | 4691 | @end example |
| 4688 | 4692 | ||
| 4689 | A mode can register as many handlers as required. | 4693 | When a selection offers a data type matching @var{types}, the function |
| 4690 | 4694 | @var{handler} is called to insert its data, with the symbol | |
| 4691 | The @var{handler} function is called with two parameters: The | 4695 | designating the matching selection data type, and the data returned by |
| 4692 | @acronym{MIME} media type symbol and the data (as a string). The | 4696 | @code{gui-get-selection}. |
| 4693 | handler should then insert the object into the buffer, or save it, or | ||
| 4694 | do whatever is appropriate for the mode. | ||
| 4695 | @end defun | 4697 | @end defun |
| 4696 | 4698 | ||
| 4697 | The @code{yank-media} command will consult the registered handlers in | 4699 | The @code{yank-media-types} command presents a list of selection data |
| 4698 | the current buffer, compare that with the available media types on the | 4700 | types that are currently available, which is useful when implementing |
| 4699 | clipboard, and then pass on the matching selection to the handler (if | 4701 | yank-media handlers; for programs generally offer an eclectic and |
| 4700 | any). If there's more than one matching selection, the user is | 4702 | seldom consistent medley of data types. |
| 4701 | queried first. | ||
| 4702 | |||
| 4703 | The @code{yank-media-types} command can be used to explore the | ||
| 4704 | clipboard/primary selection. It lists all the media types that are | ||
| 4705 | currently available, and can be handy when creating handlers---to see | ||
| 4706 | what data is actually available. Some applications put a surprising | ||
| 4707 | amount of different data types on the clipboard. | ||
| 4708 | 4703 | ||
| 4709 | @node Drag and Drop | 4704 | @node Drag and Drop |
| 4710 | @section Drag and Drop | 4705 | @section Drag and Drop |