Refactor interactiove bin/doom commands #1220
This commit is contained in:
parent
bb9cbfecc9
commit
ca9a2c8c17
2 changed files with 14 additions and 19 deletions
|
@ -7,8 +7,8 @@
|
||||||
(doom-auto-accept yes)
|
(doom-auto-accept yes)
|
||||||
(buf (get-buffer-create " *bin/doom*"))
|
(buf (get-buffer-create " *bin/doom*"))
|
||||||
(wconf (current-window-configuration))
|
(wconf (current-window-configuration))
|
||||||
(noninteractive t)
|
|
||||||
(ignore-window-parameters t)
|
(ignore-window-parameters t)
|
||||||
|
(noninteractive t)
|
||||||
(standard-output
|
(standard-output
|
||||||
(lambda (char)
|
(lambda (char)
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
|
@ -16,19 +16,17 @@
|
||||||
(when (memq char '(?\n ?\r))
|
(when (memq char '(?\n ?\r))
|
||||||
(ansi-color-apply-on-region (line-beginning-position -1) (line-end-position))
|
(ansi-color-apply-on-region (line-beginning-position -1) (line-end-position))
|
||||||
(redisplay))))))
|
(redisplay))))))
|
||||||
(delete-other-windows)
|
(doom-initialize t)
|
||||||
(switch-to-buffer buf)
|
(setq doom-modules (doom-modules))
|
||||||
(redisplay)
|
(doom-initialize-modules t)
|
||||||
(cl-letf (((symbol-function 'message)
|
(doom-initialize-packages t)
|
||||||
(lambda (message &rest args)
|
(with-current-buffer (switch-to-buffer buf)
|
||||||
(princ (apply #'format message args))
|
(erase-buffer)
|
||||||
(terpri))))
|
(require 'package)
|
||||||
(doom-dispatch command nil))
|
(redisplay)
|
||||||
(print! (green "Done!"))
|
(doom-dispatch command nil)
|
||||||
(redisplay)
|
(print! (green "\nDone!"))))
|
||||||
(when (y-or-n-p "Return to your work?")
|
(message (format! (green "Done!"))))
|
||||||
(set-window-configuration wconf)
|
|
||||||
(kill-buffer buf))))
|
|
||||||
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
|
@ -87,8 +87,5 @@ Can be colored using (color ...) blocks:
|
||||||
(print! (green \"Great %s!\") \"success\")
|
(print! (green \"Great %s!\") \"success\")
|
||||||
|
|
||||||
Uses faces in interactive sessions and ANSI codes otherwise."
|
Uses faces in interactive sessions and ANSI codes otherwise."
|
||||||
`(if (not noninteractive)
|
`(progn (princ (format! ,message ,@args))
|
||||||
(message (format! ,message ,@args))
|
(terpri)))
|
||||||
;; princ prints to stdout, message to stderr
|
|
||||||
(princ (format! ,message ,@args))
|
|
||||||
(terpri)))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue