From dc4e0f155654b07124ead42d962edc21b5bfee1b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 20 May 2018 00:07:06 +0200 Subject: [PATCH] Add doom-file-cookie-p to core-lib --- core/core-lib.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/core-lib.el b/core/core-lib.el index 08977c353..527188cdf 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -48,6 +48,16 @@ "Return EXP wrapped in a list, or as-is if already a list." (if (listp exp) exp (list exp))) +(defun doom-file-cookie-p (file) + "Returns the value of the ;;;###if predicate form in FILE." + (with-temp-buffer + (insert-file-contents-literally file nil 0 256) + (if (and (re-search-forward "^;;;###if " nil t) + (<= (line-number-at-pos) 3)) + (let ((load-file-name file)) + (eval (sexp-at-point))) + t))) + (defun doom-keyword-intern (str) "TODO" (intern (concat ":" str)))