diff options
Diffstat (limited to 'lib/eos')
-rw-r--r-- | lib/eos/jao-minibuffer.el | 19 |
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 |