From: Lars Ingebrigtsen Date: Sat, 6 Nov 2021 21:45:05 +0000 (+0100) Subject: Support yank-media in html-mode X-Git-Tag: emacs-29.0.90~3671^2~165 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bb495329e7da5026c115f6c2a28d877a8b84c4f3;p=emacs.git Support yank-media in html-mode * lisp/textmodes/sgml-mode.el (html-mode--html-yank-handler): New function. (html-mode): Handle text/html. --- diff --git a/etc/NEWS b/etc/NEWS index c9133195e9d..0d615b3793b 100644 --- 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 +++ diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 22a90ca9cfb..c9d43b6ef86 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -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-*]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)" "A regular expression matching a head line to be added to the menu.