From 834ff3ea852ce5792d2427e1a697190db982f676 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 22 Jun 2022 01:54:55 +0200 Subject: [PATCH] fix(cli): autoloaded clis aliased to wrong commands I use a shortcut like this to autoload multiple (different) CLIs living in the same file: (defautoload! ((foo bar baz)) "file") However, this creates premature aliases between autoloaded CLIs. When 'baz' is invoked, instead of loading "file", it resolves to 'foo' first *then* loads it, causing 'foo' to be executed instead of 'baz'. This commit fixes that. Also, minor refactor: I removed the plist argument from a doom-cli-command-normalize call because it wasn't needed or useful to the consumer of its return value. Amend: d226946f59ec --- core/core-cli-lib.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/core-cli-lib.el b/core/core-cli-lib.el index ab81e60d9..227ee8090 100644 --- a/core/core-cli-lib.el +++ b/core/core-cli-lib.el @@ -1511,7 +1511,8 @@ ignored. :command alias :type type :docs docs - :alias (delq nil (cons type target)) + :autoload autoload + :alias (unless autoload (delq nil (cons type target))) :plist (append plist '(:hide t))) doom-cli--table)) (dolist (partial commands) @@ -1550,7 +1551,7 @@ WHEN specifies what version this command was rendered obsolete." (defmacro defautoload! (commandspec &optional path &rest plist) "Defer loading of PATHS until PREFIX is called." `(let* ((doom-cli--plist (append (list ,@plist) doom-cli--plist)) - (commandspec (doom-cli-command-normalize ',commandspec doom-cli--plist)) + (commandspec (doom-cli-command-normalize ',commandspec)) (commands (doom-cli--command-expand commandspec)) (path (or ,path (when-let* ((cmd (car commands))