From 5d13d6ce9942dee8821cbde63c444352aec923dc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 22 May 2025 16:31:28 +0200 Subject: [PATCH] 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. --- lisp/lib/files.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/lib/files.el b/lisp/lib/files.el index 7f5389e85..efae2745e 100644 --- a/lisp/lib/files.el +++ b/lisp/lib/files.el @@ -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)