summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-01-28 15:40:48 +0000
committerjao <jao@gnu.org>2021-01-28 15:40:48 +0000
commit2c156f324cfaaa486c3ddfa53beb304a8e5e704c (patch)
tree035b6b867fba5634f97d296eca494a3ce4b1e52a
parentfd22a13099db88c212cfc7daabf4b9dbe2edfd7e (diff)
downloadelibs-2c156f324cfaaa486c3ddfa53beb304a8e5e704c.tar.gz
elibs-2c156f324cfaaa486c3ddfa53beb304a8e5e704c.tar.bz2
minibuffer: string-width instead of length
-rw-r--r--eos/jao-minibuffer.el9
1 files changed, 5 insertions, 4 deletions
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