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