From b9e436663bc33161e354f217c8face3ab7228993 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 1 Dec 2024 01:59:03 -0500 Subject: [PATCH] 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. --- lisp/doom-cli.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lisp/doom-cli.el b/lisp/doom-cli.el index 7894766f3..05108803d 100644 --- a/lisp/doom-cli.el +++ b/lisp/doom-cli.el @@ -1691,7 +1691,7 @@ ignored. (cl-destructuring-bind (&whole plist &key alias autoload _benchmark docs disable hide _group partial - _prefix) + _prefix _obsolete) (append (list ,@plist) doom-cli--group-plist) (unless disable (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))) (defcli! ,commandspec (&context _context &cli cli &rest args) :docs (format "An obsolete alias for '%s'." (doom-cli-command-string ncommand)) + :obsolete (cons ncommand ,when) :hide t - (print! (warn "'%s' was deprecated in %s") - (doom-cli-command-string cli) - ,when) - (print! (warn "It will eventually be removed; use '%s' instead.") - (doom-cli-command-string ncommand)) - (call! ',target args)))) + (let* ((obsolete (plist-get (doom-cli-plist cli) :obsolete)) + (newcmd (car obsolete)) + (when (cdr obsolete))) + (print! (warn "'%s' was deprecated in %s") + (doom-cli-command-string cli) + 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) "Define a stub CLI, which will throw an error if invoked.