summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-01-24 01:34:38 +0000
committerjao <jao@gnu.org>2022-01-24 02:01:10 +0000
commit87679ecdd18f3315a38c81178077bf52c456a1ba (patch)
treeb30ec5b11f4538363403e2e193bce9da9a229fbd /lib
parent797a98a2ee82ead7eef12c015373766f5b635b3d (diff)
downloadelibs-87679ecdd18f3315a38c81178077bf52c456a1ba.tar.gz
elibs-87679ecdd18f3315a38c81178077bf52c456a1ba.tar.bz2
jao-minibuffer: deal with multi-line msgs
Diffstat (limited to 'lib')
-rw-r--r--lib/eos/jao-minibuffer.el33
1 files changed, 12 insertions, 21 deletions
diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el
index 47aa3ea..dabd822 100644
--- a/lib/eos/jao-minibuffer.el
+++ b/lib/eos/jao-minibuffer.el
@@ -71,8 +71,7 @@
(msg (propertize msg :minibuffer-message t)))
(when (not (string-empty-p msg))
(let* ((mw (jao-minibuffer--width))
- (w (mod (or w (string-width (or (current-message) ""))) mw))
- (w (- mw w (length jao-minibuffer-right-margin))))
+ (w (- mw (mod w mw) (length jao-minibuffer-right-margin) -1)))
(if (> w 0) (jao-minibuffer--trim msg w) "")))))
(defun jao-minibuffer--insert (msg)
@@ -82,26 +81,18 @@
(insert msg)
(when hack (other-window 1) (other-window -1)))))
-(defun jao-minibuffer--format-msg (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 prefix msg (jao-minibuffer--aligned (string-width (or msg ""))))
- (concat prefix
- (jao-minibuffer--aligned (+ 3 (string-width (or msg ""))))
- " " msg))))
+ (defun jao-minibuffer--format-msg (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 (if (string-blank-p msg) msg (concat msg " "))))
+ (if jao-minibuffer-align-right-p
+ (concat prefix msg (jao-minibuffer--aligned (length msg)))
+ (concat prefix (jao-minibuffer--aligned (+ 3 (length msg))) " " msg))))
(defun jao-minibuffer--set-message (msg)
- (if (or (not jao-minibuffer-mode)
- (and msg
- (not (string-blank-p msg))
- (bound-and-true-p current-minibuffer-command)))
- msg
- (jao-minibuffer--format-msg msg)))
+ (when jao-minibuffer-mode (jao-minibuffer--format-msg (or msg ""))))
(defvar-local w3m-current-title nil)
(defvar-local eww-data nil)
@@ -183,7 +174,7 @@
(interactive)
(advice-add 'select-window :after #'jao-minibuffer-refresh)
(advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh)
- (setq set-message-function #'jao-minibuffer--format-msg)
+ (setq set-message-function #'jao-minibuffer--set-message)
(setq clear-message-function #'jao-minibuffer-refresh)
(jao-minibuffer-refresh))