Emacs: Add function to surround region with HTML tag.

This commit is contained in:
tastytea 2021-03-10 14:22:40 +01:00
parent 5ad5efc049
commit b11721fdb3

View File

@ -16,10 +16,20 @@
(use-package web-mode
:custom
(web-mode-markup-indent-offset 2) ; Default indentation level.
:config (defun my/html-surround-with-tag (beg end)
"Surround region with HTML tag."
(interactive "*r")
(if (region-active-p)
(let ((tag (completing-read "Tag: " '("em" "strong"))))
(insert (concat "<" tag ">"
(delete-and-extract-region beg end)
"</" tag ">")))
(message "No active region")))
:mode (("\\.[ps]?html?$" . web-mode)
("\\.tmpl$" . web-mode) ; Gitea templates.
("\\.php$" . web-mode))
:hook (web-mode . (lambda () (set-fill-column 120))))
:hook (web-mode . (lambda () (set-fill-column 120)))
:bind ("C-c C-M-h" . my/html-surround-with-tag))
;; Read EPUB ebooks.
(use-package nov