diff --git a/core/core-lib.el b/core/core-lib.el index 35e09fa9b..792aa8932 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -51,6 +51,7 @@ Returns (file-exists-p \"/an/absolute/path\")))) This is used by `associate!', `file-exists-p!' and `project-file-exists-p!'." + (declare (pure t) (side-effect-free t)) (cond ((stringp spec) `(file-exists-p ,(if (file-name-absolute-p spec) @@ -72,6 +73,7 @@ This is used by `associate!', `file-exists-p!' and `project-file-exists-p!'." (t spec))) (defun doom--resolve-hook-forms (hooks) + (declare (pure t) (side-effect-free t)) (cl-loop with quoted-p = (eq (car-safe hooks) 'quote) for hook in (doom-enlist (doom-unquote hooks)) if (eq (car-safe hook) 'quote) @@ -97,24 +99,26 @@ This is used by `associate!', `file-exists-p!' and `project-file-exists-p!'." (defun doom-unquote (exp) "Return EXP unquoted." + (declare (pure t) (side-effect-free t)) (while (memq (car-safe exp) '(quote function)) (setq exp (cadr exp))) exp) (defun doom-enlist (exp) "Return EXP wrapped in a list, or as-is if already a list." + (declare (pure t) (side-effect-free t)) (if (listp exp) exp (list exp))) (defun doom-keyword-intern (str) "Converts STR (a string) into a keyword (`keywordp')." - (or (stringp str) - (signal 'wrong-type-argument (list 'stringp str))) + (declare (pure t) (side-effect-free t)) + (cl-check-type str string) (intern (concat ":" str))) (defun doom-keyword-name (keyword) "Returns the string name of KEYWORD (`keywordp') minus the leading colon." - (or (keywordp keyword) - (signal 'wrong-type-argument (list 'keywordp keyword))) + (declare (pure t) (side-effect-free t)) + (cl-check-type :test keyword) (substring (symbol-name keyword) 1)) (cl-defun doom-files-in @@ -199,17 +203,17 @@ MATCH is a string regexp. Only entries that match it will be included." ;; Macros ;; -(defmacro FILE! () +(defun FILE! () "Return the emacs lisp file this macro is called from." - `(cond ((bound-and-true-p byte-compile-current-file)) - ((stringp (car-safe current-load-list)) (car current-load-list)) - (load-file-name) - (buffer-file-name))) + (cond ((bound-and-true-p byte-compile-current-file)) + (load-file-name) + (buffer-file-name) + ((stringp (car-safe current-load-list)) (car current-load-list)))) -(defmacro DIR! () +(defun DIR! () "Returns the directory of the emacs lisp file this macro is called from." - `(let ((file (FILE!))) - (and file (file-name-directory file)))) + (let ((file (FILE!))) + (and file (file-name-directory file)))) (defmacro λ! (&rest body) "A shortcut for inline interactive lambdas." diff --git a/core/core-modules.el b/core/core-modules.el index e3d496770..14d388334 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -51,12 +51,14 @@ non-nil." (defun doom-module-p (category module) "Returns t if CATEGORY MODULE is enabled (ie. present in `doom-modules')." + (declare (pure t) (side-effect-free t)) (and (hash-table-p doom-modules) (gethash (cons category module) doom-modules) t)) (defun doom-module-get (category module &optional property) "Returns the plist for CATEGORY MODULE. Gets PROPERTY, specifically, if set." + (declare (pure t) (side-effect-free t)) (when-let* ((plist (gethash (cons category module) doom-modules))) (if property (plist-get plist property) @@ -102,7 +104,8 @@ MODULE (symbol). If the category isn't enabled this will always return nil. For finding disabled modules use `doom-module-locate-path'." - (let ((path (doom-module-get category module :path))) + (let ((path (doom-module-get category module :path)) + file-name-handler-alist) (if file (expand-file-name file path) path))) @@ -119,7 +122,8 @@ This doesn't require modules to be enabled. For enabled modules us (setq category (substring (symbol-name category) 1))) (when (and module (symbolp module)) (setq module (symbol-name module))) - (cl-loop for default-directory in doom-modules-dirs + (cl-loop with file-name-handler-alist = nil + for default-directory in doom-modules-dirs for path = (concat category "/" module "/" file) if (file-exists-p path) return (expand-file-name path))) @@ -139,6 +143,7 @@ This doesn't require modules to be enabled. For enabled modules us (defun doom-module-load-path (&optional all-p) "Return a list of absolute file paths to activated modules. If ALL-P is non-nil, return paths of possible modules, activated or otherwise." + (declare (pure t) (side-effect-free t)) (append (if all-p (doom-files-in doom-modules-dirs :type 'dirs @@ -370,8 +375,8 @@ omitted. eg. (featurep! +flag1)" module (car module-pair) submodule (cdr module-pair)))) (if flag - (and (memq flag (doom-module-get module submodule :flags)) t) - (doom-module-p module submodule))) + `(and (memq ',flag (doom-module-get ,module ',submodule :flags)) t) + `(doom-module-p ,module ',submodule))) ;;