[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bb49532 3/3: Support yank-media in html-mode
From: |
Lars Ingebrigtsen |
Subject: |
master bb49532 3/3: Support yank-media in html-mode |
Date: |
Sat, 6 Nov 2021 17:45:15 -0400 (EDT) |
branch: master
commit bb495329e7da5026c115f6c2a28d877a8b84c4f3
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Support yank-media in html-mode
* lisp/textmodes/sgml-mode.el (html-mode--html-yank-handler): New
function.
(html-mode): Handle text/html.
---
etc/NEWS | 3 +++
lisp/textmodes/sgml-mode.el | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index c913319..0d615b3 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 22a90ca..c9d43b6 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-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"
"A regular expression matching a head line to be added to the menu.