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)