Simplify find hyperspec path using seq-find

This commit is contained in:
Marcus Kammer 2023-10-06 20:14:34 +02:00
parent 5c4a8fe4dc
commit d3ca754842

View file

@ -295,23 +295,12 @@
"~/sites/HyperSpec/")
"List of possible locations where the local HyperSpec could reside.")
(defun mk/find-dir (x)
"Recursively search for a valid directory from a list X of directories.
Returns the first valid directory, or nil if none found."
(cond ((null x) nil)
((file-directory-p (car x)) (car x))
(t (mk/find-dir (cdr x)))))
(defun mk/hyperspec-dir ()
"Finds and returns the URI of the local HyperSpec directory.
Uses `mk/hyperspec-dir-locations' to find the directory."
(let ((dir-prefix (if (eq system-type 'windows-nt)
"file:///" ; windows needs three slashes
"file://"))
(dir (mk/find-dir mk/hyperspec-dir-locations)))
(if dir
(concat dir-prefix (expand-file-name dir))
nil)))
(let ((dir-prefix (if (eq system-type 'windows-nt) "file:///" "file://"))
(dir (seq-find 'file-directory-p mk/hyperspec-dir-locations)))
(if dir (concat dir-prefix (expand-file-name dir)) nil)))
(setq common-lisp-hyperspec-root (mk/hyperspec-dir)))