]> git.eshelyaron.com Git - emacs.git/commitdiff
Support yank-media in html-mode
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 6 Nov 2021 21:45:05 +0000 (22:45 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 6 Nov 2021 21:45:05 +0000 (22:45 +0100)
* lisp/textmodes/sgml-mode.el (html-mode--html-yank-handler): New
function.
(html-mode): Handle text/html.

etc/NEWS
lisp/textmodes/sgml-mode.el

index c9133195e9de61eab21ec31c23d488325276e144..0d615b3793b5f0f5bdf815d2abfba0822a934b27 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -219,6 +219,9 @@ If non-nil, 'C-c C-a' will put attached files at the end of the message.
 ---
 *** Message Mode now supports image yanking.
 
+---
+*** HTML Mode now supports text/html yanking.
+
 ** Gnus
 
 +++
index 22a90ca9cfbc83f9a2944509cdb4a1ef12f99c91..c9d43b6ef865eb3677ae8f43ba5cf1ce2e7d4d5e 100644 (file)
@@ -2415,6 +2415,7 @@ To work around that, do:
     (setq-local css-id-list-function #'html-current-buffer-ids))
 
   (setq imenu-create-index-function 'html-imenu-index)
+  (register-yank-media-handler 'text/html #'html-mode--html-yank-handler)
 
   (setq-local sgml-empty-tags
              ;; From HTML-4.01's loose.dtd, parsed with
@@ -2430,6 +2431,11 @@ To work around that, do:
   ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
   )
 
+(defun html-mode--html-yank-handler (_type html)
+  (save-restriction
+    (insert html)
+    (sgml-pretty-print (point-min) (point-max))))
+
 (defvar html-imenu-regexp
   "\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"
   "A regular expression matching a head line to be added to the menu.