Major refactor of core-dispatcher
This commit is contained in:
parent
03022d09f9
commit
faf09288ce
1 changed files with 54 additions and 54 deletions
|
@ -63,15 +63,14 @@ omitted, show all available commands, their aliases and brief descriptions."
|
||||||
(apply #'doom--dispatch-help command desc (cdr args))
|
(apply #'doom--dispatch-help command desc (cdr args))
|
||||||
(funcall body (cdr args))))))
|
(funcall body (cdr args))))))
|
||||||
|
|
||||||
;; FIXME Clumsy way of registering commands, refactor!
|
(defmacro dispatcher! (command form &optional docstring)
|
||||||
(defmacro def-dispatcher! (command desc &rest body)
|
|
||||||
"Define a dispatcher command. COMMAND is a symbol or a list of symbols
|
"Define a dispatcher command. COMMAND is a symbol or a list of symbols
|
||||||
representing the aliases for this command. DESC is a string description. The
|
representing the aliases for this command. DESC is a string description. The
|
||||||
first line should be short (under 60 letters), as it will be displayed for
|
first line should be short (under 60 letters), as it will be displayed for
|
||||||
bin/doom help.
|
bin/doom help.
|
||||||
|
|
||||||
BODY will be run when this dispatcher is called."
|
BODY will be run when this dispatcher is called."
|
||||||
(declare (doc-string 2))
|
(declare (doc-string 3))
|
||||||
(let* ((command (doom-enlist command))
|
(let* ((command (doom-enlist command))
|
||||||
(cmd (car command))
|
(cmd (car command))
|
||||||
(aliases (cdr command)))
|
(aliases (cdr command)))
|
||||||
|
@ -80,9 +79,9 @@ BODY will be run when this dispatcher is called."
|
||||||
`(dolist (alias ',aliases)
|
`(dolist (alias ',aliases)
|
||||||
(map-put doom--dispatch-alias-alist alias ',cmd)))
|
(map-put doom--dispatch-alias-alist alias ',cmd)))
|
||||||
(map-put doom--dispatch-command-alist
|
(map-put doom--dispatch-command-alist
|
||||||
',cmd (list :desc ,desc
|
',cmd (list :desc ,docstring
|
||||||
;; FIXME Implicit args var; ew
|
;; FIXME Implicit args var; ew
|
||||||
:body (lambda (args) ,@body))))))
|
:body (lambda (args) ,form))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -90,7 +89,7 @@ BODY will be run when this dispatcher is called."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
;; Dummy dispatchers (no-op because they're handled especially)
|
;; Dummy dispatchers (no-op because they're handled especially)
|
||||||
(def-dispatcher! run
|
(dispatcher! run :noop
|
||||||
"Run Doom Emacs from bin/doom's parent directory.
|
"Run Doom Emacs from bin/doom's parent directory.
|
||||||
|
|
||||||
All arguments are passed on to Emacs (except for -p and -e).
|
All arguments are passed on to Emacs (except for -p and -e).
|
||||||
|
@ -102,14 +101,15 @@ WARNING: this command exists for convenience and testing. Doom will suffer
|
||||||
additional overhead for be started this way. For the best performance, it
|
additional overhead for be started this way. For the best performance, it
|
||||||
is best to run Doom out of ~/.emacs.d and ~/.doom.d.")
|
is best to run Doom out of ~/.emacs.d and ~/.doom.d.")
|
||||||
|
|
||||||
(def-dispatcher! (doctor doc)
|
(dispatcher! (doctor doc) :noop
|
||||||
"Checks for issues with your current Doom config.")
|
"Checks for issues with your current Doom config.")
|
||||||
|
|
||||||
(def-dispatcher! (help h)
|
(dispatcher! (help h) :noop
|
||||||
"Look up additional information about a command.")
|
"Look up additional information about a command.")
|
||||||
|
|
||||||
|
|
||||||
;; Real dispatchers
|
;; Real dispatchers
|
||||||
(def-dispatcher! (quickstart qs)
|
(dispatcher! (quickstart qs) (doom-quickstart)
|
||||||
"Quickly deploy a private module and Doom.
|
"Quickly deploy a private module and Doom.
|
||||||
|
|
||||||
This deploys a barebones config to ~/.doom.d. The destination can be changed
|
This deploys a barebones config to ~/.doom.d. The destination can be changed
|
||||||
|
@ -118,39 +118,28 @@ with the -p option, e.g.
|
||||||
doom -p ~/.config/doom quickstart
|
doom -p ~/.config/doom quickstart
|
||||||
|
|
||||||
This command will refuse to overwrite the private directory if it already
|
This command will refuse to overwrite the private directory if it already
|
||||||
exists."
|
exists.")
|
||||||
(doom//quickstart))
|
|
||||||
|
|
||||||
(def-dispatcher! (install i)
|
(dispatcher! (install i) (doom--do 'doom-packages-install)
|
||||||
"Installs requested plugins that aren't installed."
|
"Installs requested plugins that aren't installed.")
|
||||||
(doom//reload-doom-autoloads)
|
|
||||||
(when (doom//packages-install doom-auto-accept)
|
|
||||||
(doom//reload-package-autoloads)))
|
|
||||||
|
|
||||||
(def-dispatcher! (update u)
|
(dispatcher! (update u) (doom--do 'doom-packages-update)
|
||||||
"Checks for and updates outdated plugins."
|
"Installs requested plugins that aren't installed.")
|
||||||
(doom//reload-doom-autoloads)
|
|
||||||
(when (doom//packages-update doom-auto-accept)
|
|
||||||
(doom//reload-package-autoloads)))
|
|
||||||
|
|
||||||
(def-dispatcher! (autoremove r)
|
(dispatcher! (autoremove r) (doom--do 'doom-packages-autoremove)
|
||||||
"Removes orphaned plugins."
|
"Installs requested plugins that aren't installed.")
|
||||||
(doom//reload-doom-autoloads)
|
|
||||||
(when (doom//packages-autoremove doom-auto-accept)
|
|
||||||
(doom//reload-package-autoloads)))
|
|
||||||
|
|
||||||
(def-dispatcher! (autoloads a)
|
(dispatcher! (autoloads a) (doom-reload-autoloads nil 'force)
|
||||||
"Regenerates Doom's autoloads file.
|
"Regenerates Doom's autoloads file.
|
||||||
|
|
||||||
This file tells Emacs where to find your module's autoloaded functions and
|
This file tells Emacs where to find your module's autoloaded functions and
|
||||||
plugins."
|
plugins.")
|
||||||
(doom//reload-autoloads nil 'force))
|
|
||||||
|
|
||||||
(def-dispatcher! (upgrade up)
|
|
||||||
"Checks out the latest Doom on this branch."
|
|
||||||
(doom//upgrade))
|
|
||||||
|
|
||||||
(def-dispatcher! (compile c)
|
(dispatcher! (upgrade up) (doom-upgrade)
|
||||||
|
"Checks out the latest Doom on this branch.")
|
||||||
|
|
||||||
|
(dispatcher! (compile c) (doom-byte-compile args)
|
||||||
"Byte-compiles your config or selected modules.
|
"Byte-compiles your config or selected modules.
|
||||||
|
|
||||||
compile [TARGETS...]
|
compile [TARGETS...]
|
||||||
|
@ -159,31 +148,38 @@ plugins."
|
||||||
|
|
||||||
Accepts :core, :private and :plugins as special arguments, indicating you want
|
Accepts :core, :private and :plugins as special arguments, indicating you want
|
||||||
to byte-compile Doom's core files, your private config or your ELPA plugins,
|
to byte-compile Doom's core files, your private config or your ELPA plugins,
|
||||||
respectively."
|
respectively.")
|
||||||
(doom//byte-compile args))
|
|
||||||
|
|
||||||
(def-dispatcher! (recompile rc)
|
(dispatcher! (compile c) (doom-byte-compile args)
|
||||||
"Re-byte-compiles outdated *.elc files."
|
"Byte-compiles your config or selected modules.
|
||||||
(doom//byte-compile args 'recompile))
|
|
||||||
|
|
||||||
(def-dispatcher! clean
|
compile [TARGETS...]
|
||||||
"Delete all *.elc files."
|
compile :core :private lang/python
|
||||||
(doom//clean-byte-compiled-files))
|
compile feature lang
|
||||||
|
|
||||||
(def-dispatcher! test
|
Accepts :core, :private and :plugins as special arguments, indicating you want
|
||||||
"Run Doom unit tests."
|
to byte-compile Doom's core files, your private config or your ELPA plugins,
|
||||||
(require 'core-tests)
|
respectively.")
|
||||||
(doom//run-tests args))
|
|
||||||
|
|
||||||
(def-dispatcher! info
|
(dispatcher! (recompile rc) (doom-byte-compile args 'recompile)
|
||||||
"Output system info in markdown for bug reports."
|
"Re-byte-compiles outdated *.elc files.")
|
||||||
(doom/info))
|
|
||||||
|
|
||||||
(def-dispatcher! (version v)
|
(dispatcher! clean (doom-clean-byte-compiled-files)
|
||||||
"Reports the version of Doom and Emacs."
|
"Delete all *.elc files.")
|
||||||
(doom/version))
|
|
||||||
|
|
||||||
(def-dispatcher! (refresh re)
|
|
||||||
|
(dispatcher! test
|
||||||
|
(progn (require 'core-tests)
|
||||||
|
(doom-run-tests args))
|
||||||
|
"Run Doom unit tests.")
|
||||||
|
|
||||||
|
(dispatcher! info (doom/info)
|
||||||
|
"Output system info in markdown for bug reports.")
|
||||||
|
|
||||||
|
(dispatcher! (version v) (doom/version)
|
||||||
|
"Reports the version of Doom and Emacs.")
|
||||||
|
|
||||||
|
(dispatcher! (refresh re) (doom-refresh)
|
||||||
"Refresh Doom. Same as autoremove+install+autoloads.
|
"Refresh Doom. Same as autoremove+install+autoloads.
|
||||||
|
|
||||||
This is the equivalent of running autoremove, install, autoloads, then
|
This is the equivalent of running autoremove, install, autoloads, then
|
||||||
|
@ -192,8 +188,7 @@ recompile. Run this whenever you:
|
||||||
1. Modify your `doom!' block,
|
1. Modify your `doom!' block,
|
||||||
2. Add or remove `package!' blocks to your config,
|
2. Add or remove `package!' blocks to your config,
|
||||||
3. Add or remove autoloaded functions in module autoloaded files.
|
3. Add or remove autoloaded functions in module autoloaded files.
|
||||||
4. Update Doom outside of Doom (e.g. with git)"
|
4. Update Doom outside of Doom (e.g. with git)")
|
||||||
(doom//refresh))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -334,6 +329,11 @@ it exists."
|
||||||
(ignore-errors (delete-file (byte-compile-dest-file file)))
|
(ignore-errors (delete-file (byte-compile-dest-file file)))
|
||||||
(message "Deleted old %s" (file-name-nondirectory file))))
|
(message "Deleted old %s" (file-name-nondirectory file))))
|
||||||
|
|
||||||
|
(defun doom--do (fn)
|
||||||
|
(doom-reload-doom-autoloads)
|
||||||
|
(when (funcall fn doom-auto-accept)
|
||||||
|
(doom-reload-package-autoloads)))
|
||||||
|
|
||||||
(defun doom--server-load (file)
|
(defun doom--server-load (file)
|
||||||
(require 'server)
|
(require 'server)
|
||||||
(when (server-running-p)
|
(when (server-running-p)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue