hugo: use named-let to avoid hypothetical stack overflow

This commit is contained in:
MitchMarq42 2023-01-11 08:02:47 -09:00
parent 41313be8a6
commit 700d0da6b7

View File

@ -649,9 +649,10 @@ See https://emacs.stackexchange.com/questions/2538/how-to-define-additional-mode
(defun hugo-dir-above (dir) (defun hugo-dir-above (dir)
"Return path of Hugo project root above or at DIR. "Return path of Hugo project root above or at DIR.
Return nil if DIR is not in a hugo project at all." Return nil if DIR is not in a hugo project at all."
(named-let hda-internal ((dir dir))
(if (eq dir nil) nil (if (eq dir nil) nil
(if (file-exists-p (expand-file-name "config.toml" dir)) dir (if (file-exists-p (expand-file-name "config.toml" dir)) dir
(hugo-dir-above (file-name-directory (string-trim-right dir "/")))))) (hda-internal (file-name-directory (string-trim-right dir "/")))))))
(defun hugo-compile (dir) (defun hugo-compile (dir)
(let ((hugo-dir (hugo-dir-above dir))) (let ((hugo-dir (hugo-dir-above dir)))
(if hugo-dir (if hugo-dir