Add (Recommended) after certain straight prompts

When a package's worktree is dirty (or its recipe was changed), straight
prompts you with options to deal with it. To make it easier for less git
savvy folks, the recommended option has been marked.
This commit is contained in:
Henrik Lissner 2020-01-08 22:07:34 -05:00
parent 4bd59f5ed9
commit 309e322037
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -138,6 +138,11 @@ missing) and shouldn't be deleted.")
(y-or-n-p (format! "%s" (or prompt "")))
(funcall orig-fn prompt)))
(defvar doom--straight-recommended-options
'("^Delete remote \"[^\"]+\", re-create it with correct "
"^Reset branch "
"^Abort merge$"))
(defadvice! doom--straight-fallback-to-tty-prompt-a (orig-fn prompt actions)
"Modifies straight to prompt on the terminal when in noninteractive sessions."
:around #'straight--popup-raw
@ -164,6 +169,9 @@ missing) and shouldn't be deleted.")
(cl-destructuring-bind (_key desc func) action
(when desc
(push func options)
(cl-loop for regexp in doom--straight-recommended-options
if (string-match-p regexp desc)
return (setq desc (concat desc " (Recommended)")))
(print! "%2s) %s" (length options) desc)))))
(terpri)
(let ((options (nreverse options))