From eafebe1cb960ef05da7b48eaaf3d6aeb3ae71a3a Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Mon, 13 Dec 2021 21:17:45 +0100 Subject: [PATCH] Add simple function to directly render html from a file This is simpler than opening the file in a buffer and calling shr-render-buffer, with some buffer maneuvring afterwards. --- site-lisp/db-utils.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index ca51480..c540219 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -20,6 +20,7 @@ (require 'calc-forms) (require 'ert) (require 's) +(require 'shr) (autoload 'async-start "async") (autoload 'lispy-mode "lispy") @@ -454,6 +455,13 @@ Does not replace CRLF with CRCRLF, and so on." (file-exists-p (concat project "/.git")))) projectile-known-projects)))) +(defun db/shr-render-file (file) + "Display the HTML rending of the contents of FILE." + (interactive "f") + (unless (file-readable-p file) + (user-error "Cannot read file: %s" file)) + (shr-render-buffer (find-file-noselect file))) + ;; Base45 Decoding