fix(lib): doom-file-cookie: what argument-less cookies return

Used to be that a ;;;###COOKIE with no argument would return NULL-VALUE.
No more, it will now return `t`.

Also corrects the docstring to properly reflect what this does.
This commit is contained in:
Henrik Lissner
2025-05-22 16:31:28 +02:00
parent 11b4b8d2e5
commit 5d13d6ce99

View File

@ -144,8 +144,7 @@ MATCH is a string regexp. Only entries that match it will be included."
;;;###autoload
(defun doom-file-cookie (file &optional cookie null-value)
"Returns the evaluated result of FORM in a ;;;###COOKIE FORM at the top of
FILE.
"Returns the quoted FORM in a ;;;###COOKIE FORM at the top of FILE.
If COOKIE doesn't exist, or cookie isn't within the first 256 bytes of FILE,
return NULL-VALUE."
@ -155,10 +154,12 @@ return NULL-VALUE."
(error "%S is unreadable" file))
(with-temp-buffer
(insert-file-contents file nil 0 256)
(if (re-search-forward (format "^;;;###%s " (regexp-quote (or cookie "if")))
nil t)
(sexp-at-point)
null-value)))
(if (not (re-search-forward (format "^;;;###%s" (regexp-quote (or cookie "if")))
nil t))
null-value
(skip-chars-forward " \t" (pos-eol))
(or (eolp)
(read (current-buffer))))))
;;;###autoload
(defun doom-file-cookie-p (file &optional cookie null-value)