From 4ec9311b65f343ceb9efd6709908a6e5ee44b6d7 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 25 Aug 2025 09:53:24 +1000 Subject: [emacs] Add html view mode --- emacs/.emacs.d/init/ycp-markup.el | 5 +++++ emacs/.emacs.d/lisp/my/my-markup.el | 17 +++++++++++++++++ emacs/.emacs.d/lisp/nov.el | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/init/ycp-markup.el b/emacs/.emacs.d/init/ycp-markup.el index 4922d6e..c5f874f 100644 --- a/emacs/.emacs.d/init/ycp-markup.el +++ b/emacs/.emacs.d/init/ycp-markup.el @@ -139,5 +139,10 @@ (my-keybind mhtml-mode-map "C-c C-v" #'my-html-render)) +(my-package my-markup + (:delay 15) + (add-to-list 'auto-mode-alist '("\\.html\\'" . htmlv-mode)) + ) + (provide 'ycp-markup) ;;; ycp-markup.el ends here diff --git a/emacs/.emacs.d/lisp/my/my-markup.el b/emacs/.emacs.d/lisp/my/my-markup.el index 52ba9e0..ceb3dcf 100644 --- a/emacs/.emacs.d/lisp/my/my-markup.el +++ b/emacs/.emacs.d/lisp/my/my-markup.el @@ -72,5 +72,22 @@ (call-interactively 'shr-render-buffer) (view-mode)))) +(defvar-keymap htmlv-mode-map + ;; :parent view-mode-map + "." #'htmlv-reopen-as-html + ) + +(define-derived-mode htmlv-mode view-mode "HTML View" + "Major mode for viewing HTML documents." + (let ((inhibit-read-only t)) + (shr-render-region (point-min) (point-max))) + (set-buffer-modified-p nil) + (goto-char (point-min))) + +(defun htmlv-reopen-as-html () + (interactive) + (with-current-buffer (find-file-literally buffer-file-name) + (mhtml-mode))) + (provide 'my-markup) ;;; my-markup.el ends here diff --git a/emacs/.emacs.d/lisp/nov.el b/emacs/.emacs.d/lisp/nov.el index c0d30da..7f5c215 160000 --- a/emacs/.emacs.d/lisp/nov.el +++ b/emacs/.emacs.d/lisp/nov.el @@ -1 +1 @@ -Subproject commit c0d30da504fb0b68d8c28ff61a5e0095acda7f5f +Subproject commit 7f5c215a3d6b75fc1cbbc62e46ee014cbe2f3f12 -- cgit v1.2.3