Add :if, :when, :unless & :cond support to doom! macro
Now you can conditionally enable/disable modules.
This commit is contained in:
parent
321b797046
commit
e6201ca952
3 changed files with 56 additions and 12 deletions
|
@ -229,8 +229,6 @@ For example, :nvi will map to (list 'normal 'visual 'insert). See
|
|||
(put :mode 'lisp-indent-function 'defun)
|
||||
(put :prefix 'lisp-indent-function 'defun)
|
||||
(put :prefix-map 'lisp-indent-function 'defun)
|
||||
(put :unless 'lisp-indent-function 'defun)
|
||||
(put :when 'lisp-indent-function 'defun)
|
||||
|
||||
;; specials
|
||||
(defvar doom--map-forms nil)
|
||||
|
|
|
@ -322,6 +322,10 @@ This value is cached. If REFRESH-P, then don't use the cached value."
|
|||
;;
|
||||
;;; Module config macros
|
||||
|
||||
(put :if 'lisp-indent-function 2)
|
||||
(put :when 'lisp-indent-function 'defun)
|
||||
(put :unless 'lisp-indent-function 'defun)
|
||||
|
||||
(defmacro doom! (&rest modules)
|
||||
"Bootstraps DOOM Emacs and its modules.
|
||||
|
||||
|
@ -353,17 +357,29 @@ for a list of all recognized module trees. Order defines precedence (from most
|
|||
to least)."
|
||||
(unless (keywordp (car modules))
|
||||
(setq modules (eval modules t)))
|
||||
(unless doom-modules
|
||||
(setq doom-modules
|
||||
(make-hash-table :test 'equal
|
||||
:size (if modules (length modules) 150)
|
||||
:rehash-threshold 1.0)))
|
||||
(let ((inhibit-message doom-inhibit-module-warnings)
|
||||
(let ((doom-modules
|
||||
(make-hash-table :test 'equal
|
||||
:size (if modules (length modules) 150)
|
||||
:rehash-threshold 1.0))
|
||||
(inhibit-message doom-inhibit-module-warnings)
|
||||
category m)
|
||||
(while modules
|
||||
(setq m (pop modules))
|
||||
(cond ((keywordp m) (setq category m))
|
||||
((not category) (error "No module category specified for %s" m))
|
||||
((and (listp m)
|
||||
(keywordp (car m)))
|
||||
(pcase (car m)
|
||||
(:cond
|
||||
(cl-loop for (cond . mods) in (cdr m)
|
||||
if (eval cond t)
|
||||
return (prependq! modules mods)))
|
||||
(:if (if (eval (cadr m) t)
|
||||
(push (caddr m) modules)
|
||||
(prependq! modules (cdddr m))))
|
||||
(fn (if (or (eval (cadr m) t)
|
||||
(eq fn :unless))
|
||||
(prependq! modules (cddr m))))))
|
||||
((catch 'doom-modules
|
||||
(let* ((module (if (listp m) (car m) m))
|
||||
(flags (if (listp m) (cdr m))))
|
||||
|
@ -387,10 +403,10 @@ to least)."
|
|||
(throw 'doom-modules t))))
|
||||
(if-let (path (doom-module-locate-path category module))
|
||||
(doom-module-set category module :flags flags :path path)
|
||||
(message "WARNING Couldn't find the %s %s module" category module))))))))
|
||||
(when noninteractive
|
||||
(setq doom-inhibit-module-warnings t))
|
||||
`(setq doom-modules ',doom-modules))
|
||||
(message "WARNING Couldn't find the %s %s module" category module)))))))
|
||||
(when noninteractive
|
||||
(setq doom-inhibit-module-warnings t))
|
||||
`(setq doom-modules ',doom-modules)))
|
||||
|
||||
(defvar doom-disabled-packages)
|
||||
(define-obsolete-function-alias 'def-package! 'use-package!) ; DEPRECATED
|
||||
|
|
30
docs/api.org
30
docs/api.org
|
@ -82,6 +82,36 @@ It is integrated into Helpful, in Doom.
|
|||
:background "red" :weight bold)))
|
||||
#+END_SRC
|
||||
|
||||
* doom!
|
||||
#+BEGIN_SRC elisp :eval no
|
||||
(doom! :completion
|
||||
company
|
||||
ivy
|
||||
;;helm
|
||||
|
||||
:tools
|
||||
(:if IS-MAC macos)
|
||||
docker
|
||||
lsp
|
||||
|
||||
:lang
|
||||
(cc +lsp)
|
||||
(:cond ((string= system-name "work-pc")
|
||||
python
|
||||
rust
|
||||
web)
|
||||
((string= system-name "writing-pc")
|
||||
(org +dragndrop)
|
||||
ruby))
|
||||
(:if IS-LINUX
|
||||
(web +lsp)
|
||||
web)
|
||||
|
||||
:config
|
||||
literate
|
||||
(default +bindings +smartparens))
|
||||
#+END_SRC
|
||||
|
||||
* file-exists-p!
|
||||
#+BEGIN_SRC elisp
|
||||
(file-exists-p! "init.el" doom-emacs-dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue