aboutsummaryrefslogtreecommitdiff
path: root/modules/help-utils.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-24 08:46:04 -0500
committerCraig Jennings <c@cjennings.net>2026-07-24 08:46:04 -0500
commitd9ab1074991ee3c4c680024b14d6de0475560380 (patch)
tree00b9459181efaececd8da2c065c69ac92b0a8bc2 /modules/help-utils.el
parent7e5aa31731a6d6446055729fb7597d549ff637f4 (diff)
downloaddotemacs-d9ab1074991ee3c4c680024b14d6de0475560380.tar.gz
dotemacs-d9ab1074991ee3c4c680024b14d6de0475560380.zip
fix: correct four wrong behaviors and drop three dead code paths
- yt-dlp downloads claimed completion when tsp had merely queued them. - A fresh machine opened org links in EWW, not Chrome. - ArchWiki search raised a raw error instead of the install hint. - The pre-commit hook kept running when its cd failed. - Removed a second device-grouping implementation nothing called. - Removed a redundant epub advice that ran on every file visit. - Removed a buffer-burying clause naming a mode Emacs doesn't define. - Moved the Hugo bindings onto the custom prefix map. - The ArchWiki docs path is now a variable, making it testable.
Diffstat (limited to 'modules/help-utils.el')
-rw-r--r--modules/help-utils.el42
1 files changed, 29 insertions, 13 deletions
diff --git a/modules/help-utils.el b/modules/help-utils.el
index 9792841a..2709ac45 100644
--- a/modules/help-utils.el
+++ b/modules/help-utils.el
@@ -65,24 +65,40 @@
;; on Arch: yay (or whatever your AUR package manager is) -S arch-wiki-docs
;; browse the arch wiki topics offline
+(defvar cj/arch-wiki-html-dir "/usr/share/doc/arch-wiki/html/en"
+ "Directory holding the offline ArchWiki HTML copies.
+Populated by the arch-wiki-docs package on Arch systems.")
+
+(defun cj/--arch-wiki-topics (dir)
+ "Return an alist of (BASENAME . FULLPATH) for ArchWiki topics under DIR.
+
+Returns nil when DIR does not exist rather than signaling. This is the
+whole point of the helper: `directory-files' raises file-missing on an
+absent directory, and the caller's \"is arch-wiki-docs installed?\" hint
+sat below that call, so on the one machine state the hint was written for
+it could never be reached."
+ (when (file-directory-p dir)
+ (mapcar (lambda (f) (cons (file-name-base f) f))
+ (directory-files dir t "\\.html\\'"))))
+
(defun cj/local-arch-wiki-search ()
"Prompt for an ArchWiki topic and open its local HTML copy in EWW.
-Looks for “*.html” files under \"/usr/share/doc/arch-wiki/html/en\",
-lets you complete on their basenames, and displays the chosen file
-with `eww-browse-url'. If no file is found, reminds you to install
+Looks for “*.html” files under `cj/arch-wiki-html-dir', lets you complete
+on their basenames, and displays the chosen file with `eww-browse-url'.
+If the directory is missing or empty, reminds you to install
arch-wiki-docs."
(interactive)
- (let* ((dir "/usr/share/doc/arch-wiki/html/en")
- (full-filenames (directory-files dir t "\\.html\\'"))
- (basenames (mapcar 'file-name-base full-filenames))
- (chosen (completing-read "Choose an ArchWiki Topic: " basenames)))
- (if (member chosen basenames)
- (let* ((idx (cl-position chosen basenames :test 'equal))
- (fullname (nth idx full-filenames))
- (url (concat "file://" fullname)))
- (eww-browse-url url))
- (message "File not found! Is arch-wiki-docs installed?"))))
+ (let ((topics (cj/--arch-wiki-topics cj/arch-wiki-html-dir)))
+ (if (null topics)
+ (message "No ArchWiki topics in %s. Is arch-wiki-docs installed?"
+ cj/arch-wiki-html-dir)
+ (let* ((chosen (completing-read "Choose an ArchWiki Topic: "
+ (mapcar #'car topics)))
+ (fullname (cdr (assoc chosen topics))))
+ (if fullname
+ (eww-browse-url (concat "file://" fullname))
+ (message "No ArchWiki topic named %s" chosen))))))
(keymap-global-set "C-h A" #'cj/local-arch-wiki-search)
(provide 'help-utils)