aboutsummaryrefslogtreecommitdiff
path: root/modules/dirvish-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-10 13:42:11 -0500
committerCraig Jennings <c@cjennings.net>2026-05-10 13:42:11 -0500
commitcffdf3b92a97b1af3aedec624a9fb43db1c60ef8 (patch)
treec0b9c8ccc02d45282135f650c4b4941c80fdfdb7 /modules/dirvish-config.el
parent09f3349af22c932a01f0788787cee9ab4f3c38a7 (diff)
downloaddotemacs-cffdf3b92a97b1af3aedec624a9fb43db1c60ef8.tar.gz
dotemacs-cffdf3b92a97b1af3aedec624a9fb43db1c60ef8.zip
refactor(dirvish): extract cj/--html-file-p; match HTML case-insensitively
`cj/dirvish-open-html-in-eww' inlined a `string-match-p' against `\.html?\=' to decide whether to hand a file to eww. The check was case-sensitive, so `.HTML' fell through to the "Not an HTML file" message even though every browser treats it as HTML. Lift the predicate into `cj/--html-file-p' and bind `case-fold-search' to t so uppercase and mixed-case extensions match. The trailing-`\=' anchor stays so files like `html-thing.org' still don't match. Seven Normal/Boundary/Error tests cover lowercase `.html', `.htm', uppercase `.HTML', mixed-case `.Html', embedded `html' (no match), non-html extensions (no match), and no-extension files (no match).
Diffstat (limited to 'modules/dirvish-config.el')
-rw-r--r--modules/dirvish-config.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el
index 86ecfd2d..ad2227e8 100644
--- a/modules/dirvish-config.el
+++ b/modules/dirvish-config.el
@@ -161,11 +161,20 @@ Filters for audio files, prompts for the playlist name, and saves the resulting
;;; --------------------------- Dired Open HTML In EWW --------------------------
+(defun cj/--html-file-p (file)
+ "Return non-nil when FILE has a `.html' or `.htm' extension.
+
+Match is case-insensitive (`.HTML' counts) and anchored at end so
+embedded `html' in the middle of a name doesn't match. Pure helper
+used by `cj/dirvish-open-html-in-eww'."
+ (let ((case-fold-search t))
+ (and (string-match-p "\\.html?\\'" file) t)))
+
(defun cj/dirvish-open-html-in-eww ()
"Open HTML file at point in dired/dirvish using eww."
(interactive)
(let ((file (dired-get-file-for-visit)))
- (if (string-match-p "\\.html?\\'" file)
+ (if (cj/--html-file-p file)
(eww-open-file file)
(message "Not an HTML file: %s" file))))