summaryrefslogtreecommitdiffhomepage
path: root/lib/eos
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-12-03 02:08:03 +0000
committerjao <jao@gnu.org>2021-12-03 02:09:02 +0000
commitcf828fc14c3fbef09f4f569482d820aa53f34ef7 (patch)
tree0f4721fe4b0707b01204c1bdf98fabd20c4cd4d3 /lib/eos
parente8d3192b63d2242bc7173ae0acfa8a0f4cddba31 (diff)
downloadelibs-cf828fc14c3fbef09f4f569482d820aa53f34ef7.tar.gz
elibs-cf828fc14c3fbef09f4f569482d820aa53f34ef7.tar.bz2
jao-minibuffer: better padding
Diffstat (limited to 'lib/eos')
-rw-r--r--lib/eos/jao-minibuffer.el19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el
index ec7fa8d..a6420c7 100644
--- a/lib/eos/jao-minibuffer.el
+++ b/lib/eos/jao-minibuffer.el
@@ -38,6 +38,15 @@
(defconst jao-minibuffer--name " *Minibuf-0*")
+(defun jao-minibuffer--text-with-padding (text)
+ "Return TEXT with padding on the left.
+The padding pushes TEXT to the right edge of the mode-line."
+ (let* ((len (- (string-pixel-width text) jao-minibuffer-right-margin))
+ (padding (propertize
+ "-" 'display
+ `(space :align-to (- (+ right right-margin) (,len))))))
+ (concat padding text)))
+
(defun jao-minibuffer--trim (s w)
(if (<= (string-width (or s "")) w)
(format (format "%%%ds" (if jao-minibuffer-align-right-p w (- w))) s)
@@ -71,10 +80,12 @@
(string-trim-left msg)))
(msg (propertize msg :minibuffer-message t)))
(when (not (string-empty-p msg))
- (let* ((mw (jao-minibuffer--width))
- (w (mod (or w (string-pixel-width (or (current-message) ""))) mw))
- (w (- mw w jao-minibuffer-right-margin)))
- (if (> w 0) (jao-minibuffer--trim msg w) "")))))
+ (if (and window-system jao-minibuffer-align-right-p)
+ (jao-minibuffer--text-with-padding msg)
+ (let* ((mw (jao-minibuffer--width))
+ (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) ""))))))
(defun jao-minibuffer--insert (msg)
(with-current-buffer jao-minibuffer--name