diff --git a/core/autoload/output.el b/core/autoload/output.el index 760c7318a..a7f93fb7b 100644 --- a/core/autoload/output.el +++ b/core/autoload/output.el @@ -106,7 +106,9 @@ Accepts 'ansi and 'text-properties. nil means don't render colors.") ;;;###autoload (defun doom--print (output) (unless (string-empty-p output) - (princ output) + (if noninteractive + (send-string-to-terminal output) + (princ output)) (terpri) output)) @@ -254,12 +256,12 @@ DEST can be one or more of `standard-output', a buffer, a file" (insert-char out)) (send-string-to-terminal (char-to-string out))))) (letf! (defun message (msg &rest args) - (with-current-buffer log-buffer - (print-group! - (insert (doom--format (apply #'format msg args)) "\n"))) - (if doom-debug-p - (doom--print (doom--format (apply #'format msg args))) - (apply message msg args))) + (print-group! + (with-current-buffer log-buffer + (insert (doom--format (apply #'format msg args)) "\n")) + (when (or doom-debug-p (not inhibit-message)) + (doom--print (doom--format (apply #'format msg args))))) + message) (unwind-protect ,(macroexp-progn body) (with-current-buffer log-buffer diff --git a/core/cli/lib/straight-hacks.el b/core/cli/lib/straight-hacks.el index 1aecbeeff..728d9f90d 100644 --- a/core/cli/lib/straight-hacks.el +++ b/core/cli/lib/straight-hacks.el @@ -106,18 +106,15 @@ original state.") answer)) (funcall (nth answer options))))))))) -(defadvice! doom--straight-respect-print-indent-a (args) - "Indent straight progress messages to respect `doom-output-indent', so we -don't have to pass whitespace to `straight-use-package's fourth argument -everywhere we use it (and internally)." - :filter-args #'straight-use-package - (cl-destructuring-bind - (melpa-style-recipe &optional no-clone no-build cause interactive) - args - (list melpa-style-recipe no-clone no-build - (if (and (not cause) - (boundp 'doom-output-indent) - (> doom-output-indent 0)) - (make-string (1- (or doom-output-indent 1)) 32) - cause) - interactive))) +(setq straight-arrow " > ") +(defadvice! doom--straight-respect-print-indent-a (string &rest objects) + "Same as `message' (which see for STRING and OBJECTS) normally. +However, in batch mode, print to stdout instead of stderr." + :override #'straight--output + (let ((msg (apply #'format string objects))) + (save-match-data + (when (string-match (format "^%s\\(.+\\)$" (regexp-quote straight-arrow)) msg) + (setq msg (match-string 1 msg)))) + (and (string-match-p "^\\(Cloning\\|\\(Reb\\|B\\)uilding\\) " msg) + (not (string-suffix-p "...done" msg)) + (doom--print (doom--format (concat "> " msg)))))) diff --git a/core/cli/packages.el b/core/cli/packages.el index d384f6375..730bac669 100644 --- a/core/cli/packages.el +++ b/core/cli/packages.el @@ -220,7 +220,7 @@ list remains lean." with previous = 0 while (not (zerop pending)) 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) else do (let ((inhibit-message t)) diff --git a/core/core-cli.el b/core/core-cli.el index c6bc0749d..9394ea455 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -132,20 +132,29 @@ Environment variables: (doom-cli-execute "help") (let ((start-time (current-time))) (run-hooks 'doom-cli-pre-hook) - (when-let (result (apply #'doom-cli-execute command args)) - (run-hooks 'doom-cli-post-hook) - (print! (success "Finished in %s") - (let* ((duration (float-time (time-subtract (current-time) before-init-time))) - (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)))))) + (print! (start "Executing 'doom %s' %s") + (string-join + (cons (or (ignore-errors + (doom-cli-name (doom-cli-get command))) + command) + args) + " ") + (format-time-string "%Y-%m-%d %H:%M:%S")) + (print-group! + (when-let (result (apply #'doom-cli-execute command args)) + (run-hooks 'doom-cli-post-hook) + (print! (success "Finished in %s") + (let* ((duration (float-time (time-subtract (current-time) before-init-time))) + (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 (doom-cli-command-not-found-error (print! (error "Command 'doom %s' not recognized") (string-join (cdr e) " "))