bin/doom: polish output

Reduces the amount of "noise" included in bin/doom's output.

Also fixes an issue where warnings during autoloads generation would
sneak into Doom's autoloads file, producing weird void-variable errors,
like

  (void-variable . rainbow-delimiters:)
  (void-variable . diredfl:)
  (void-variable . company:)
This commit is contained in:
Henrik Lissner 2021-05-23 21:40:01 -04:00
parent 54067455e7
commit 4b5cf7d46f
4 changed files with 45 additions and 37 deletions

View file

@ -106,7 +106,9 @@ Accepts 'ansi and 'text-properties. nil means don't render colors.")
;;;###autoload ;;;###autoload
(defun doom--print (output) (defun doom--print (output)
(unless (string-empty-p output) (unless (string-empty-p output)
(princ output) (if noninteractive
(send-string-to-terminal output)
(princ output))
(terpri) (terpri)
output)) output))
@ -254,12 +256,12 @@ DEST can be one or more of `standard-output', a buffer, a file"
(insert-char out)) (insert-char out))
(send-string-to-terminal (char-to-string out))))) (send-string-to-terminal (char-to-string out)))))
(letf! (defun message (msg &rest args) (letf! (defun message (msg &rest args)
(with-current-buffer log-buffer (print-group!
(print-group! (with-current-buffer log-buffer
(insert (doom--format (apply #'format msg args)) "\n"))) (insert (doom--format (apply #'format msg args)) "\n"))
(if doom-debug-p (when (or doom-debug-p (not inhibit-message))
(doom--print (doom--format (apply #'format msg args))) (doom--print (doom--format (apply #'format msg args)))))
(apply message msg args))) message)
(unwind-protect (unwind-protect
,(macroexp-progn body) ,(macroexp-progn body)
(with-current-buffer log-buffer (with-current-buffer log-buffer

View file

@ -106,18 +106,15 @@ original state.")
answer)) answer))
(funcall (nth answer options))))))))) (funcall (nth answer options)))))))))
(defadvice! doom--straight-respect-print-indent-a (args) (setq straight-arrow " > ")
"Indent straight progress messages to respect `doom-output-indent', so we (defadvice! doom--straight-respect-print-indent-a (string &rest objects)
don't have to pass whitespace to `straight-use-package's fourth argument "Same as `message' (which see for STRING and OBJECTS) normally.
everywhere we use it (and internally)." However, in batch mode, print to stdout instead of stderr."
:filter-args #'straight-use-package :override #'straight--output
(cl-destructuring-bind (let ((msg (apply #'format string objects)))
(melpa-style-recipe &optional no-clone no-build cause interactive) (save-match-data
args (when (string-match (format "^%s\\(.+\\)$" (regexp-quote straight-arrow)) msg)
(list melpa-style-recipe no-clone no-build (setq msg (match-string 1 msg))))
(if (and (not cause) (and (string-match-p "^\\(Cloning\\|\\(Reb\\|B\\)uilding\\) " msg)
(boundp 'doom-output-indent) (not (string-suffix-p "...done" msg))
(> doom-output-indent 0)) (doom--print (doom--format (concat "> " msg))))))
(make-string (1- (or doom-output-indent 1)) 32)
cause)
interactive)))

View file

@ -220,7 +220,7 @@ list remains lean."
with previous = 0 with previous = 0
while (not (zerop pending)) while (not (zerop pending))
if (/= previous pending) do if (/= previous pending) do
(print! (info "\033[KWaiting for %d async jobs...\033[1A" pending)) (print! (start "\033[KNatively compiling %d files...\033[1A" pending))
(setq previous pending) (setq previous pending)
else do else do
(let ((inhibit-message t)) (let ((inhibit-message t))

View file

@ -132,20 +132,29 @@ Environment variables:
(doom-cli-execute "help") (doom-cli-execute "help")
(let ((start-time (current-time))) (let ((start-time (current-time)))
(run-hooks 'doom-cli-pre-hook) (run-hooks 'doom-cli-pre-hook)
(when-let (result (apply #'doom-cli-execute command args)) (print! (start "Executing 'doom %s' %s")
(run-hooks 'doom-cli-post-hook) (string-join
(print! (success "Finished in %s") (cons (or (ignore-errors
(let* ((duration (float-time (time-subtract (current-time) before-init-time))) (doom-cli-name (doom-cli-get command)))
(hours (/ (truncate duration) 60 60)) command)
(minutes (- (/ (truncate duration) 60) (* hours 60))) args)
(seconds (- duration (* hours 60 60) (* minutes 60)))) " ")
(string-join (format-time-string "%Y-%m-%d %H:%M:%S"))
(delq (print-group!
nil (list (unless (zerop hours) (format "%dh" hours)) (when-let (result (apply #'doom-cli-execute command args))
(unless (zerop minutes) (format "%dm" minutes)) (run-hooks 'doom-cli-post-hook)
(format (if (> duration 60) "%ds" "%.4fs") (print! (success "Finished in %s")
seconds)))))) (let* ((duration (float-time (time-subtract (current-time) before-init-time)))
result)))))) (hours (/ (truncate duration) 60 60))
(minutes (- (/ (truncate duration) 60) (* hours 60)))
(seconds (- duration (* hours 60 60) (* minutes 60))))
(string-join
(delq
nil (list (unless (zerop hours) (format "%dh" hours))
(unless (zerop minutes) (format "%dm" minutes))
(format (if (> duration 60) "%ds" "%.4fs")
seconds))))))
result)))))))
;; TODO Not implemented yet ;; TODO Not implemented yet
(doom-cli-command-not-found-error (doom-cli-command-not-found-error
(print! (error "Command 'doom %s' not recognized") (string-join (cdr e) " ")) (print! (error "Command 'doom %s' not recognized") (string-join (cdr e) " "))