fix(cli): defcli-obsolete!: don't rely on lexical-binding

Emacs requires '-*- lexical-binding: t -*-' to be prefixed with an elisp
line comment (two semicolons), but due to our shebang shenanigans (which
are, unfortunately, necessary) starting this line with a :;, Emacs
ignores the `lexical-binding: t` at the top, thereby executing bin/doom
without lexical binding.

Until a better workaround is found, our CLI framework will have to
adapt. Fortunately, this only affects bin/doom and not any arbitrary
doomscript.
This commit is contained in:
Henrik Lissner
2024-12-01 01:59:03 -05:00
parent abedb71f96
commit b9e436663b

View File

@ -1691,7 +1691,7 @@ ignored.
(cl-destructuring-bind (cl-destructuring-bind
(&whole plist &key (&whole plist &key
alias autoload _benchmark docs disable hide _group partial alias autoload _benchmark docs disable hide _group partial
_prefix) _prefix _obsolete)
(append (list ,@plist) doom-cli--group-plist) (append (list ,@plist) doom-cli--group-plist)
(unless disable (unless disable
(let* ((command (doom-cli-command-normalize (backquote ,commandspec) plist)) (let* ((command (doom-cli-command-normalize (backquote ,commandspec) plist))
@ -1753,13 +1753,17 @@ WHEN specifies what version this command was rendered obsolete."
`(let ((ncommand (doom-cli-command-normalize (backquote ,target) doom-cli--group-plist))) `(let ((ncommand (doom-cli-command-normalize (backquote ,target) doom-cli--group-plist)))
(defcli! ,commandspec (&context _context &cli cli &rest args) (defcli! ,commandspec (&context _context &cli cli &rest args)
:docs (format "An obsolete alias for '%s'." (doom-cli-command-string ncommand)) :docs (format "An obsolete alias for '%s'." (doom-cli-command-string ncommand))
:obsolete (cons ncommand ,when)
:hide t :hide t
(print! (warn "'%s' was deprecated in %s") (let* ((obsolete (plist-get (doom-cli-plist cli) :obsolete))
(doom-cli-command-string cli) (newcmd (car obsolete))
,when) (when (cdr obsolete)))
(print! (warn "It will eventually be removed; use '%s' instead.") (print! (warn "'%s' was deprecated in %s")
(doom-cli-command-string ncommand)) (doom-cli-command-string cli)
(call! ',target args)))) when)
(print! (warn "It will eventually be removed; use '%s' instead.")
(doom-cli-command-string newcmd))
(call! ',target args)))))
(defmacro defcli-stub! (commandspec &optional _argspec &rest body) (defmacro defcli-stub! (commandspec &optional _argspec &rest body)
"Define a stub CLI, which will throw an error if invoked. "Define a stub CLI, which will throw an error if invoked.