From 1ab8dac872dc1d891b55235085b674c3b3378b6c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 24 Apr 2019 18:07:37 -0400 Subject: [PATCH] Fix arg-less color functions in print!/format! --- core/autoload/message.el | 12 +++++++----- core/core-cli.el | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/autoload/message.el b/core/autoload/message.el index b460b4340..358272aac 100644 --- a/core/autoload/message.el +++ b/core/autoload/message.el @@ -68,23 +68,25 @@ Accepts 'ansi and 'text-properties. nil means don't render colors.") In a noninteractive session, this wraps the result in ansi color codes. Otherwise, it maps colors to a term-color-* face." - (let ((code (car (cdr (assq style doom-ansi-alist))))) + (let ((code (car (cdr (assq style doom-ansi-alist)))) + (message (if args (apply #'format text args) text))) (pcase doom-message-backend (`ansi (format "\e[%dm%s\e[%dm" (car (cdr (assq style doom-ansi-alist))) - (apply #'format text args) 0)) + message 0)) (`text-properties (require 'term) ; piggyback on term's color faces (propertize - (apply #'format text args) 'face + message + 'face (append (get-text-property 0 'face text) (cond ((>= code 40) `(:background ,(caddr (assq style doom-ansi-alist)))) ((>= code 30) `(:foreground ,(face-foreground (caddr (assq style doom-ansi-alist))))) ((cddr (assq style doom-ansi-alist))))))) - (_ (apply #'format text args))))) + (_ message)))) (defun doom--short-color-replace (forms) "Replace color-name functions with calls to `doom-color-apply'." @@ -121,7 +123,7 @@ Can be colored using (color ...) blocks: (print! \"Hello %s\" (bold (blue \"How are you?\"))) (print! \"Hello %s\" (red \"World\")) - (print! (green \"Great %s!\") \"success\") + (print! (green \"Great %s!\" \"success\")) Uses faces in interactive sessions and ANSI codes otherwise." `(progn (princ (format! ,message ,@args)) diff --git a/core/core-cli.el b/core/core-cli.el index 8885a7ea6..86da98fe2 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -39,7 +39,7 @@ commands like `doom-packages-install', `doom-packages-update' and omitted, show all available commands, their aliases and brief descriptions." (if command (princ (doom--dispatch-format desc)) - (print! (bold "%-10s\t%s\t%s") "Command:" "Alias" "Description") + (print! (bold "%-10s\t%s\t%s" "Command:" "Alias" "Description")) (dolist (spec (cl-sort doom--dispatch-command-alist #'string-lessp :key #'car)) (cl-destructuring-bind (command &key desc _body) spec