From e9ab9070d3171ae3dcc43b3a25da0c01ee6393c8 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 22 Jun 2021 00:40:01 +0100 Subject: jao-minibuffer: better multiline messages --- lib/eos/jao-minibuffer.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/eos') diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el index 212d738..4528aa7 100644 --- a/lib/eos/jao-minibuffer.el +++ b/lib/eos/jao-minibuffer.el @@ -82,11 +82,16 @@ (insert msg))) (defun jao-minibuffer--format-msg (msg) - (let* ((msg (string-trim (replace-regexp-in-string "\n" " " msg))) + (let* ((msgs (split-string msg "\n")) + (prefix (when-let (p (string-join (butlast msgs) "\n")) + (unless (string-blank-p p) (concat p "\n")))) + (msg (car (last msgs))) + (msg (string-trim (replace-regexp-in-string "\n" " " msg))) (msg (if (string-blank-p msg) msg (concat msg " ")))) (if jao-minibuffer-align-right-p - (concat msg (jao-minibuffer--aligned (string-width (or msg "")))) - (concat (jao-minibuffer--aligned (+ 3 (string-width (or msg "")))) + (concat prefix msg (jao-minibuffer--aligned (string-width (or msg "")))) + (concat prefix + (jao-minibuffer--aligned (+ 3 (string-width (or msg "")))) " " msg)))) (defun jao-minibuffer--set-message (msg) -- cgit v1.2.3