💥 Change first arg of load! macro
load!'s first argument is no longer a symbol (that will cause void-variable errors now) to save on unnecessary interning and simplify compile-time logic. It accepts any valid form that evaluates to a string now. If you use load!, you need to change its argument to a string! e.g. (load! +my-module) => (load! "+my-module")
This commit is contained in:
parent
bdee28609a
commit
1a452b6842
14 changed files with 48 additions and 56 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;; core/autoload/packages.el -*- lexical-binding: t; -*-
|
;;; core/autoload/packages.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(load! cache)
|
(load! "cache")
|
||||||
|
|
||||||
;;; Private functions
|
;;; Private functions
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
;; Eagerly load these libraries because this module may be loaded in a session
|
;; Eagerly load these libraries because this module may be loaded in a session
|
||||||
;; that hasn't been fully initialized (where autoloads files haven't been
|
;; that hasn't been fully initialized (where autoloads files haven't been
|
||||||
;; generated or `load-path' populated).
|
;; generated or `load-path' populated).
|
||||||
(load! autoload/packages)
|
(load! "autoload/packages")
|
||||||
(load! autoload/modules)
|
(load! "autoload/modules")
|
||||||
(load! autoload/debug)
|
(load! "autoload/debug")
|
||||||
(load! autoload/message)
|
(load! "autoload/message")
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -175,7 +175,7 @@ respectively."
|
||||||
|
|
||||||
(def-dispatcher! test
|
(def-dispatcher! test
|
||||||
"Run Doom unit tests."
|
"Run Doom unit tests."
|
||||||
(load! autoload/test)
|
(load! "autoload/test")
|
||||||
(doom//run-tests args))
|
(doom//run-tests args))
|
||||||
|
|
||||||
(def-dispatcher! info
|
(def-dispatcher! info
|
||||||
|
|
|
@ -566,12 +566,12 @@ Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
||||||
for a list of all recognized module trees. Order defines precedence (from most
|
for a list of all recognized module trees. Order defines precedence (from most
|
||||||
to least)."
|
to least)."
|
||||||
(let ((doom-modules (doom-module-table (or modules t)))
|
(let ((doom-modules (doom-module-table (or modules t)))
|
||||||
init-forms config-forms file-name-handler-alist)
|
init-forms config-forms)
|
||||||
(maphash (lambda (key value)
|
(maphash (lambda (key plist)
|
||||||
(let ((path (plist-get value :path)))
|
(let ((path (plist-get plist :path)))
|
||||||
(push `(let ((doom--current-module ',key)) (load! init ,path t))
|
(push `(let ((doom--current-module ',key)) (load! "init" ,path t))
|
||||||
init-forms)
|
init-forms)
|
||||||
(push `(let ((doom--current-module ',key)) (load! config ,path t))
|
(push `(let ((doom--current-module ',key)) (load! "config" ,path t))
|
||||||
config-forms)))
|
config-forms)))
|
||||||
doom-modules)
|
doom-modules)
|
||||||
`(let (file-name-handler-alist)
|
`(let (file-name-handler-alist)
|
||||||
|
@ -629,34 +629,26 @@ to have them return non-nil (or exploit that to overwrite Doom's config)."
|
||||||
,@body)))
|
,@body)))
|
||||||
((error "'%s' isn't a valid hook for def-package-hook!" when))))
|
((error "'%s' isn't a valid hook for def-package-hook!" when))))
|
||||||
|
|
||||||
(defmacro load! (filesym &optional path noerror)
|
(defmacro load! (filename &optional path noerror)
|
||||||
"Load a file relative to the current executing file (`load-file-name').
|
"Load a file relative to the current executing file (`load-file-name').
|
||||||
|
|
||||||
FILESYM is either a symbol or string representing the file to load. PATH is
|
FILENAME is either a symbol or string representing the file to load. PATH is
|
||||||
where to look for the file (a string representing a directory path). If omitted,
|
where to look for the file (a string representing a directory path). If omitted,
|
||||||
the lookup is relative to `load-file-name', `byte-compile-current-file' or
|
the lookup is relative to `load-file-name', `byte-compile-current-file' or
|
||||||
`buffer-file-name' (in that order).
|
`buffer-file-name' (in that order).
|
||||||
|
|
||||||
If NOERROR is non-nil, don't throw an error if the file doesn't exist."
|
If NOERROR is non-nil, don't throw an error if the file doesn't exist."
|
||||||
(or (symbolp filesym)
|
(unless path
|
||||||
(signal 'wrong-type-argument (list 'symbolp filesym)))
|
(setq path (or (and (bound-and-true-p byte-compile-current-file)
|
||||||
(let ((path (or (when path
|
(file-name-directory byte-compile-current-file))
|
||||||
(cond ((stringp path) path)
|
(and load-file-name (file-name-directory load-file-name))
|
||||||
((symbolp path) (symbol-value path))
|
(and buffer-file-name
|
||||||
((listp path) (eval path t))))
|
(file-name-directory buffer-file-name))
|
||||||
(and (bound-and-true-p byte-compile-current-file)
|
(error "Could not detect path to look for '%s' in" filename))))
|
||||||
(file-name-directory byte-compile-current-file))
|
`(load ,(if path
|
||||||
(and load-file-name (file-name-directory load-file-name))
|
`(expand-file-name ,filename ,path)
|
||||||
(and buffer-file-name
|
filename)
|
||||||
(file-name-directory buffer-file-name))
|
,noerror ,(not doom-debug-mode)))
|
||||||
(error "Could not detect path to look for '%s' in" filesym)))
|
|
||||||
(filename (symbol-name filesym)))
|
|
||||||
(let ((file (expand-file-name (concat filename ".el") path)))
|
|
||||||
(if (file-exists-p file)
|
|
||||||
`(load ,(file-name-sans-extension file) ,noerror
|
|
||||||
,(not doom-debug-mode))
|
|
||||||
(unless noerror
|
|
||||||
(error "Could not load file '%s' from '%s'" file path))))))
|
|
||||||
|
|
||||||
(defmacro require! (module submodule &optional reload-p &rest plist)
|
(defmacro require! (module submodule &optional reload-p &rest plist)
|
||||||
"Loads the module specified by MODULE (a property) and SUBMODULE (a symbol).
|
"Loads the module specified by MODULE (a property) and SUBMODULE (a symbol).
|
||||||
|
@ -671,9 +663,9 @@ The module is only loaded once. If RELOAD-P is non-nil, load it again."
|
||||||
(if (file-directory-p module-path)
|
(if (file-directory-p module-path)
|
||||||
`(condition-case-unless-debug ex
|
`(condition-case-unless-debug ex
|
||||||
(let ((doom--current-module ',(cons module submodule)))
|
(let ((doom--current-module ',(cons module submodule)))
|
||||||
(load! init ,module-path :noerror)
|
(load! "init" ,module-path :noerror)
|
||||||
(let ((doom--stage 'config))
|
(let ((doom--stage 'config))
|
||||||
(load! config ,module-path :noerror)))
|
(load! "config" ,module-path :noerror)))
|
||||||
('error
|
('error
|
||||||
(lwarn 'doom-modules :error
|
(lwarn 'doom-modules :error
|
||||||
"%s in '%s %s' -> %s"
|
"%s in '%s %s' -> %s"
|
||||||
|
@ -796,7 +788,7 @@ loads MODULE SUBMODULE's packages.el file."
|
||||||
(flags ,flags))
|
(flags ,flags))
|
||||||
(when flags
|
(when flags
|
||||||
(doom-module-put ,module ',submodule :flags flags))
|
(doom-module-put ,module ',submodule :flags flags))
|
||||||
(load! packages ,(doom-module-locate-path module submodule) t)))
|
(load! "packages" ,(doom-module-locate-path module submodule) t)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -174,4 +174,4 @@ default/fallback account."
|
||||||
;; Sub-modules
|
;; Sub-modules
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(if (featurep! +gmail) (load! +gmail))
|
(if (featurep! +gmail) (load! "+gmail"))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;; config/default/config.el -*- lexical-binding: t; -*-
|
;;; config/default/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(if (featurep! +bindings) (load! +bindings))
|
(if (featurep! +bindings) (load! "+bindings"))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
(when (featurep 'evil)
|
(when (featurep 'evil)
|
||||||
(when (featurep! +evil-commands)
|
(when (featurep! +evil-commands)
|
||||||
(load! +evil-commands))
|
(load! "+evil-commands"))
|
||||||
|
|
||||||
(when (featurep! +bindings)
|
(when (featurep! +bindings)
|
||||||
(defvar +default-repeat-forward-key ";")
|
(defvar +default-repeat-forward-key ";")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;;; feature/version-control/config.el -*- lexical-binding: t; -*-
|
;;; feature/version-control/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(load! +git)
|
(load! "+git")
|
||||||
;; TODO (load! +hg)
|
;; TODO (load! "+hg")
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(setq vc-make-backup-files nil)
|
(setq vc-make-backup-files nil)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;;; lang/haskell/config.el -*- lexical-binding: t; -*-
|
;;; lang/haskell/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(cond ((featurep! +intero) (load! +intero))
|
(cond ((featurep! +intero) (load! "+intero"))
|
||||||
((featurep! +dante) (load! +dante)))
|
((featurep! +dante) (load! "+dante")))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
(add-hook 'java-mode-hook #'rainbow-delimiters-mode)
|
(add-hook 'java-mode-hook #'rainbow-delimiters-mode)
|
||||||
|
|
||||||
(cond ((featurep! +meghanada) (load! +meghanada))
|
(cond ((featurep! +meghanada) (load! "+meghanada"))
|
||||||
;; TODO lang/java +lsp (lsp-java?)
|
;; TODO lang/java +lsp (lsp-java?)
|
||||||
;; ((featurep! +lsp) (load! +lsp))
|
;; ((featurep! +lsp) (load! "+lsp"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@
|
||||||
:match "/screeps\\(?:-ai\\)?/.+$"
|
:match "/screeps\\(?:-ai\\)?/.+$"
|
||||||
:modes (+javascript-npm-mode)
|
:modes (+javascript-npm-mode)
|
||||||
:add-hooks (+javascript|init-screeps-mode)
|
:add-hooks (+javascript|init-screeps-mode)
|
||||||
:on-load (load! +screeps))
|
:on-load (load! "+screeps"))
|
||||||
|
|
||||||
(def-project-mode! +javascript-gulp-mode
|
(def-project-mode! +javascript-gulp-mode
|
||||||
:files "gulpfile.js")
|
:files "gulpfile.js")
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
(after! tex-site
|
(after! tex-site
|
||||||
;; Set some varibles to fontify common LaTeX commands.
|
;; Set some varibles to fontify common LaTeX commands.
|
||||||
(load! +fontification)
|
(load! "+fontification")
|
||||||
(setq ;; Enable parse on load.
|
(setq ;; Enable parse on load.
|
||||||
TeX-parse-self t
|
TeX-parse-self t
|
||||||
;; When running TeX, just save, don't ask
|
;; When running TeX, just save, don't ask
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
"The directory where org files are kept.")
|
"The directory where org files are kept.")
|
||||||
|
|
||||||
;; Sub-modules
|
;; Sub-modules
|
||||||
(if (featurep! +attach) (load! +attach))
|
(if (featurep! +attach) (load! "+attach"))
|
||||||
(if (featurep! +babel) (load! +babel))
|
(if (featurep! +babel) (load! "+babel"))
|
||||||
(if (featurep! +capture) (load! +capture))
|
(if (featurep! +capture) (load! "+capture"))
|
||||||
(if (featurep! +export) (load! +export))
|
(if (featurep! +export) (load! "+export"))
|
||||||
(if (featurep! +present) (load! +present))
|
(if (featurep! +present) (load! "+present"))
|
||||||
;; TODO (if (featurep! +publish) (load! +publish))
|
;; TODO (if (featurep! +publish) (load! "+publish"))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;;; lang/web/config.el -*- lexical-binding: t; -*-
|
;;; lang/web/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(load! +html)
|
(load! "+html")
|
||||||
(load! +css)
|
(load! "+css")
|
||||||
|
|
||||||
|
|
||||||
(def-package! web-beautify
|
(def-package! web-beautify
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;; -*- no-byte-compile: t; -*-
|
;; -*- no-byte-compile: t; -*-
|
||||||
;;; tools/password-store/test/autoload-pass.el
|
;;; tools/password-store/test/autoload-pass.el
|
||||||
|
|
||||||
(load! ../autoload)
|
(load! "../autoload")
|
||||||
|
|
||||||
(defmacro with-passwords!! (buffer-args &rest body)
|
(defmacro with-passwords!! (buffer-args &rest body)
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
|
|
|
@ -160,4 +160,4 @@ deleted.")
|
||||||
;; Hacks
|
;; Hacks
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(load! +hacks)
|
(load! "+hacks")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue