From b804a2f34f23d78f54b8c8c21e7ebdb9f57a824c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 16 Sep 2022 10:31:55 +0200 Subject: [PATCH] refactor(lib): convert cli/autoloads.el to lib --- bin/doom | 108 ++++++++++++++++----------------- lisp/doom-cli.el | 2 +- lisp/{cli => lib}/autoloads.el | 7 ++- 3 files changed, 59 insertions(+), 58 deletions(-) rename lisp/{cli => lib}/autoloads.el (98%) diff --git a/bin/doom b/bin/doom index 4523d1ae8..c928dd297 100755 --- a/bin/doom +++ b/bin/doom @@ -245,70 +245,66 @@ SEE ALSO: ;; There are a lot of CLIs, and some have expensive initialization, so best we ;; load them lazily. -(let ((dir (doom-path doom-core-dir "cli"))) - ;; Library for generating autoloads files for Doom modules & packages. - (load! "autoloads" dir) +(defcli-group! + :prefix 'doom + ;; Import this for implicit 'X help' commands for your script: + (defcli-alias! ((help h)) (:root :help)) + ;; And suggest its use when errors occur. + (add-to-list 'doom-help-commands "%p h[elp] %c") - (defcli-group! - :prefix 'doom - ;; Import this for implicit 'X help' commands for your script: - (defcli-alias! ((help h)) (:root :help)) - ;; And suggest its use when errors occur. - (add-to-list 'doom-help-commands "%p h[elp] %c") + (defcli-group! "Config Management" + :docs "Commands for maintaining your Doom Emacs configuration." + (defcli-autoload! ((sync s))) + (defcli-autoload! ((profiles profile))) + (defcli-autoload! ((upgrade up))) + (defcli-autoload! (env)) + (defcli-autoload! ((build b purge p rollback)) "packages") + (defcli-autoload! ((install i))) + (defcli-autoload! ((compile c))) + (defcli-autoload! (clean) "compile") - (defcli-group! "Config Management" - :docs "Commands for maintaining your Doom Emacs configuration." - (defcli-autoload! ((sync s))) - (defcli-autoload! ((profiles profile))) - (defcli-autoload! ((upgrade up))) - (defcli-autoload! (env)) - (defcli-autoload! ((build b purge p rollback)) "packages") - (defcli-autoload! ((install i))) - (defcli-autoload! ((compile c))) - (defcli-autoload! (clean) "compile") + ;; TODO Post-3.0 commands + ;; (load! "gc" dir) + ;; (load! "module" dir) + ;; (load! "nuke" dir) + ;; (load! "package" dir) + ;; (load! "profile" dir) + ;; (defcli-obsolete! ((compile c)) (sync "--compile") "v3.0.0") + ;; (defcli-obsolete! ((build b)) (sync "--rebuild") "v3.0.0") + ) - ;; TODO Post-3.0 commands - ;; (load! "gc" dir) - ;; (load! "module" dir) - ;; (load! "nuke" dir) - ;; (load! "package" dir) - ;; (load! "profile" dir) - ;; (defcli-obsolete! ((compile c)) (sync "--compile") "v3.0.0") - ;; (defcli-obsolete! ((build b)) (sync "--rebuild") "v3.0.0") - ) + (defcli-group! "Diagnostics" + :docs "Commands for troubleshooting and debugging Doom." + (defcli-autoload! ((doctor doc))) + (defcli-autoload! (info)) + (defcli-alias! ((version v)) (:root :version))) - (defcli-group! "Diagnostics" - :docs "Commands for troubleshooting and debugging Doom." - (defcli-autoload! ((doctor doc))) - (defcli-autoload! (info)) - (defcli-alias! ((version v)) (:root :version))) + (defcli-group! "Development" + :docs "Commands for developing or launching Doom." + (defcli-autoload! (ci)) + (defcli-autoload! (make)) + (defcli-autoload! (run)) - (defcli-group! "Development" - :docs "Commands for developing or launching Doom." - (defcli-autoload! (ci)) - (defcli-autoload! (make)) - (defcli-autoload! (run)) + ;; FIXME Test framework + ;; (load! "test" dir) + ) - ;; FIXME Test framework - ;; (load! "test" dir) - ) + (let ((cli-file "cli")) + (defcli-group! "Module commands" + (dolist (key (doom-module-list)) + (when-let (path (doom-module-expand-path (car key) (cdr key) cli-file)) + (defcli-group! :prefix (format "+%s" (cdr key)) + (doom-load path t))))) - (let ((cli-file "cli")) - (defcli-group! "Module commands" - (dolist (key (doom-module-list)) - (when-let (path (doom-module-expand-path (car key) (cdr key) cli-file)) - (defcli-group! :prefix (format "+%s" (cdr key)) - (doom-load path t))))) + (load! cli-file doom-user-dir t)) - (load! cli-file doom-user-dir t)) - - ;; Allow per-project Doom settings in .doom files. - (let (doomrc) - (cond - ((setq doomrc (getenv "DOOMRC")) - (load! doomrc)) - ((setq doomrc (locate-dominating-file default-directory ".doomrc")) - (load! ".doomrc" doomrc)))))) + ;; Allow per-project Doom settings in .doom files. + (let (doomrc) + (cond + ((setq doomrc (getenv "DOOMRC")) + (load! doomrc)) + ((setq doomrc (locate-dominating-file default-directory ".doomrc")) + (load! ".doomrc" doomrc))))) ;; diff --git a/lisp/doom-cli.el b/lisp/doom-cli.el index 54af724b9..49077ba0c 100644 --- a/lisp/doom-cli.el +++ b/lisp/doom-cli.el @@ -69,7 +69,7 @@ (doom-require 'doom-lib 'plist) (doom-require 'doom-lib 'files) (doom-require 'doom-lib 'print) - ;; (doom-require 'doom-lib 'autoloads) + (doom-require 'doom-lib 'autoloads) ;; Ensure straight and core packages are ready to go for CLI commands. (require 'doom-modules) diff --git a/lisp/cli/autoloads.el b/lisp/lib/autoloads.el similarity index 98% rename from lisp/cli/autoloads.el rename to lisp/lib/autoloads.el index fba0b3da0..7dfc17fff 100644 --- a/lisp/cli/autoloads.el +++ b/lisp/lib/autoloads.el @@ -1,4 +1,6 @@ -;;; lisp/cli/autoloads.el -*- lexical-binding: t; -*- +;;; lisp/lib/autoloads.el -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: (defvar doom-autoloads-excluded-packages () "Which packages to exclude from Doom's autoloads files. @@ -192,3 +194,6 @@ non-nil, treat FILES as pre-generated autoload files instead." (not literal)) autoloads)) (end-of-file)))))))) + +(provide 'doom-lib '(autoloads)) +;;; autoloads.el end here