summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/eos/jao-minibuffer.el26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el
index 44af185..93a1948 100644
--- a/lib/eos/jao-minibuffer.el
+++ b/lib/eos/jao-minibuffer.el
@@ -27,6 +27,7 @@
(defvar jao-minibuffer-info ())
(defvar jao-minibuffer-msg-info '(""))
(defvar jao-minibuffer-align-right t)
+(defvar jao-minibuffer-adaptive-alignment t)
(defvar jao-minibuffer-right-margin (if window-system 0 1))
(defvar jao-minibuffer-maximized-frames-p t)
(defvar jao-minibuffer-frame-width nil)
@@ -101,7 +102,9 @@
(msg (if (and msg pref)
(replace-regexp-in-string "\n" pref msg)
msg))
- (msg (if info (format "%s%s%s " info sep (or msg "")) msg)))
+ (left (if jao-minibuffer-align-right info (or msg "")))
+ (right (if jao-minibuffer-align-right (or msg "") info))
+ (msg (if info (format "%s%s%s" left sep right) msg)))
(jao-minibuffer--format-msg (or msg ""))))))
(defun jao-minibuffer--clear-message ()
@@ -115,26 +118,30 @@
(set list-name (remove v (symbol-value list-name)))
(add-to-ordered-list list-name v order)))
-;;;###autoload
+(defun jao-minibuffer--adjust-alignment (&rest _)
+ (when jao-minibuffer-adaptive-alignment
+ (setq jao-minibuffer-align-right
+ (< (or (car (window-absolute-pixel-edges)) 0)
+ (/ (or (cadr (assoc 'outer-size (frame-geometry))) 0) 2))))
+ (jao-minibuffer-refresh))
+
(defun jao-minibuffer-add-variable (variable-name &optional order)
(jao-minibuffer--add-variable 'jao-minibuffer-info variable-name order))
-;;;###autoload
(defun jao-minibuffer-add-msg-variable (variable-name &optional order)
(jao-minibuffer--add-variable 'jao-minibuffer-msg-info variable-name order))
-;;;###autoload
(defun jao-minibuffer-remove-variable (variable-name)
(let ((v `(:eval ,variable-name)))
(setq jao-minibuffer-info (remove v jao-minibuffer-info))
(setq jao-minibuffer-msg-info (remove v jao-minibuffer-msg-info))))
-;;;###autoload
(define-minor-mode jao-minibuffer-mode
"Show minibuffer status"
:global t :lighter "" :group 'jao
(if jao-minibuffer-mode
- (progn (advice-add 'select-window :after #'jao-minibuffer-refresh)
+ (progn ;; (advice-add 'select-window :after #'jao-minibuffer-refresh)
+ (advice-add 'select-window :after #'jao-minibuffer--adjust-alignment)
(advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh)
(setq clear-message-function #'jao-minibuffer--clear-message)
(jao-minibuffer-refresh))
@@ -143,7 +150,6 @@
(setq clear-message-function nil)
(jao-minibuffer--insert "")))
-;;;###autoload
(defun jao-minibuffer-refresh (&rest _ignore)
(interactive)
(when jao-minibuffer-mode
@@ -152,5 +158,11 @@
(jao-minibuffer--format-info jao-minibuffer-msg-info))))
(jao-minibuffer--insert (jao-minibuffer--format-msg (or msg ""))))))
+(defun jao-minibuffer-toggle-adaptive-alignment ()
+ (interactive)
+ (setq jao-minibuffer-adaptive-alignment
+ (not jao-minibuffer-adaptive-alignment))
+ (jao-minibuffer-refresh))
+
(provide 'jao-minibuffer)
;;; jao-minibuffer.el ends here