diff --git a/lisp/doom-lib.el b/lisp/doom-lib.el index 3caca2e7e..d1d8485b7 100644 --- a/lisp/doom-lib.el +++ b/lisp/doom-lib.el @@ -1,6 +1,22 @@ -;;; doom-lib.el -*- lexical-binding: t; -*- +;;; doom-lib.el --- Doom's core standard library -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: -(require 'cl-lib) +(defmacro doom-log (output &rest args) + "Log a message in *Messages*. + +Does not emit the message in the echo area. This is a macro instead of a +function to prevent the potentially expensive execution of its arguments when +debug mode is off." + (declare (debug t)) + `(when (or init-file-debug noninteractive) + (let ((inhibit-message (not init-file-debug))) + (message + "%s" (propertize + (format (concat "* [%.06f] " ,output) + (float-time (time-subtract (current-time) before-init-time)) + ,@args) + 'face 'font-lock-doc-face))))) ;; diff --git a/lisp/lib/print.el b/lisp/lib/print.el index 6cae5a49b..74cee4ad8 100644 --- a/lisp/lib/print.el +++ b/lisp/lib/print.el @@ -167,38 +167,6 @@ Returns OUTPUT." (if newline (terpri stream)) output))) -;;;###autoload -(progn - ;; Autoload whole definition, so its buried uses don't pull in this whole file - ;; with them at expansion time. - (defmacro doom-log (output &rest args) - "Log a message in *Messages*. - -Does not emit the message in the echo area. This is a macro instead of a -function to prevent the potentially expensive execution of its arguments when -debug mode is off." - `(when (or init-file-debug noninteractive) - (let ((inhibit-message t)) - (message - "%s" (propertize - (doom-print--format - (format - "* [%s] %s" - ,(let ((time `(format "%.06f" (float-time (time-subtract (current-time) before-init-time))))) - (cond (noninteractive time) - ((bound-and-true-p doom--current-module) - (format "[:%s %s] " - (doom-keyword-name (car doom--current-module)) - (cdr doom--current-module))) - ((when-let (file (ignore-errors (file!))) - (format "[%s] " - (file-relative-name - file (expand-file-name "../" (file-name-directory file)))))) - (time))) - ,output) - ,@args) - 'face 'font-lock-doc-face)))))) - ;;;###autoload (defmacro format! (message &rest args) "An alternative to `format' that understands (color ...) and converts them