From 2c156f324cfaaa486c3ddfa53beb304a8e5e704c Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 28 Jan 2021 15:40:48 +0000 Subject: minibuffer: string-width instead of length --- eos/jao-minibuffer.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'eos') diff --git a/eos/jao-minibuffer.el b/eos/jao-minibuffer.el index 3294d4b..91662bf 100644 --- a/eos/jao-minibuffer.el +++ b/eos/jao-minibuffer.el @@ -36,7 +36,7 @@ (defconst jao-minibuffer--name " *Minibuf-0*") (defun jao-minibuffer--trim (s w) - (if (<= (length s) w) + (if (<= (string-width (or s "")) w) (format (format "%%%ds" (if jao-minibuffer-align-right-p w (- w))) s) (substring s 0 w))) @@ -69,7 +69,7 @@ (msg (propertize msg :minibuffer-message t))) (when (not (string-empty-p msg)) (let* ((mw (jao-minibuffer--width)) - (w (mod (or w (length (current-message))) mw)) + (w (mod (or w (string-width (or (current-message) ""))) mw)) (w (- mw w jao-minibuffer-right-margin))) (if (> w 0) (jao-minibuffer--trim msg w) ""))))) @@ -79,8 +79,9 @@ (let* ((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 (length msg) t)) - (concat (jao-minibuffer--aligned (+ 3 (length msg)) t) " " msg))))) + (concat msg (jao-minibuffer--aligned (string-width (or msg "")) t)) + (concat (jao-minibuffer--aligned (+ 3 (string-width (or msg ""))) t) + " " msg))))) (defun jao-minibuffer--insert (msg) (with-current-buffer jao-minibuffer--name -- cgit v1.2.3