summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/eos/jao-minibuffer.el58
-rw-r--r--lib/eos/jao-mode-line.el33
-rw-r--r--lib/themes/jao-light-theme.el2
3 files changed, 49 insertions, 44 deletions
diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el
index 2e58f24..f77857e 100644
--- a/lib/eos/jao-minibuffer.el
+++ b/lib/eos/jao-minibuffer.el
@@ -26,8 +26,8 @@
(defvar jao-minibuffer-info ())
(defvar jao-minibuffer-msg-info '(""))
-(defvar jao-minibuffer-align-right-p t)
-(defvar jao-minibuffer-right-margin (if window-system "" " "))
+(defvar jao-minibuffer-align-right t)
+(defvar jao-minibuffer-right-margin (if window-system 0 2))
(defvar jao-minibuffer-maximized-frames-p t)
(defvar jao-minibuffer-frame-width nil)
(defvar jao-minibuffer-active-buffer-line-color "azure4")
@@ -37,7 +37,7 @@
(defun jao-minibuffer--trim (s w)
(if (<= (string-width (or s "")) w)
- (format (format "%%%ds" (if jao-minibuffer-align-right-p w (- w))) s)
+ (format (format "%%%ds" (if jao-minibuffer-align-right w (- w))) s)
(substring s 0 w)))
(defun jao-minibuffer--width ()
@@ -46,22 +46,19 @@
(t (min (frame-width) (window-width (minibuffer-window))))))
(defun jao-minibuffer--format-info (&optional info)
- (mapconcat 'string-trim
- (seq-filter (lambda (s) (not (string-blank-p s)))
- (mapcar 'format-mode-line
- (if jao-minibuffer-align-right-p
- (or info jao-minibuffer-info)
- (reverse (or info jao-minibuffer-info)))))
- " "))
-
-(defun jao-minibuffer--aligned (&optional w)
+ (let* ((info (or info jao-minibuffer-info))
+ (info (if jao-minibuffer-align-right info (reverse info))))
+ (mapconcat #'string-trim
+ (seq-remove #'string-blank-p (mapcar 'format-mode-line info))
+ " ")))
+
+(defun jao-minibuffer--aligned (w)
(let* ((msg (jao-minibuffer--format-info))
- (msg (cond (jao-minibuffer-align-right-p (string-trim msg))
- (t (string-trim-left msg))))
- (msg (propertize msg :minibuffer-message t)))
+ (msg (cond (jao-minibuffer-align-right (string-trim msg))
+ (t (string-trim-left msg)))))
(unless (string-empty-p msg)
- (let* ((mw (jao-minibuffer--width))
- (w (- mw (mod w mw) (string-width jao-minibuffer-right-margin) -1)))
+ (let ((msg (propertize msg :minibuffer-message t))
+ (w (- (jao-minibuffer--width) w jao-minibuffer-right-margin)))
(if (> w 0) (jao-minibuffer--trim msg w) "")))))
(defun jao-minibuffer--insert (msg)
@@ -72,19 +69,20 @@
(when hack (other-window 1) (other-window -1)))))
(defun jao-minibuffer--strip-prev (msg)
- (if-let* ((l (length msg))
- (n (text-property-any 0 l :minibuffer-message t msg)))
+ (if-let ((n (text-property-any 0 (length msg) :minibuffer-message t msg)))
(string-trim (substring msg 0 n))
msg))
+(defun jao-minibuffer--prefix (msgs)
+ (when-let (p (string-join (butlast msgs) "\n"))
+ (unless (string-blank-p p) (concat p "\n"))))
+
(defun jao-minibuffer--format-msg (msg)
(let* ((msgs (mapcar #'jao-minibuffer--strip-prev (split-string msg "\n")))
- (prefix (when-let (p (string-join (butlast msgs) "\n"))
- (unless (string-blank-p p) (concat p "\n"))))
+ (prefix (jao-minibuffer--prefix msgs))
(msg (car (last msgs)))
- (msg (if (string-blank-p msg) msg (concat msg " ")))
(w (string-width msg)))
- (if jao-minibuffer-align-right-p
+ (if jao-minibuffer-align-right
(concat prefix msg (jao-minibuffer--aligned w))
(concat prefix (jao-minibuffer--aligned (+ 3 w)) " " msg))))
@@ -107,6 +105,12 @@
(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-info))))
+
+;;;###autoload
(define-minor-mode jao-minibuffer-mode
"Show minibuffer status"
:global t :lighter "" :group 'jao
@@ -117,7 +121,6 @@
(jao-minibuffer-refresh))
(advice-remove 'select-window #'jao-minibuffer-refresh)
(advice-remove 'force-mode-line-update #'jao-minibuffer-refresh)
- (setq set-message-function nil)
(setq clear-message-function nil)
(jao-minibuffer--insert "")))
@@ -125,10 +128,9 @@
(defun jao-minibuffer-refresh (&rest _ignore)
(interactive)
(when jao-minibuffer-mode
- (let* ((jao-minibuffer-mode nil)
- (msg (jao-minibuffer--format-info jao-minibuffer-msg-info))
- (msg (jao-minibuffer--format-msg (or msg ""))))
- (jao-minibuffer--insert (or msg "")))))
+ (let ((jao-minibuffer-mode nil)
+ (msg (jao-minibuffer--format-info jao-minibuffer-msg-info)))
+ (jao-minibuffer--insert (jao-minibuffer--format-msg (or msg ""))))))
(provide 'jao-minibuffer)
;;; jao-minibuffer.el ends here
diff --git a/lib/eos/jao-mode-line.el b/lib/eos/jao-mode-line.el
index 8e86658..4ed7033 100644
--- a/lib/eos/jao-mode-line.el
+++ b/lib/eos/jao-mode-line.el
@@ -97,24 +97,28 @@
;;;; mode line in minibuffer
-(defvar jao-mode-line--original-modeline nil)
+(defvar jao-mode-line--old-format nil)
(defvar jao-mode-line--face nil)
(defvar jao-mode-line--inactive-face nil)
(defvar jao-mode-line--props
'(:box :height :background :foreground :overline :underline :extend))
-(defun jao-mode-line--extract-face (face)
- (let ((atts nil))
+(defun jao-mode-line--extract-face (inactive)
+ (let ((atts nil)
+ (face (if inactive 'mode-line-inactive 'mode-line)))
(dolist (a jao-mode-line--props)
(push (face-attribute face a) atts)
(push a atts))
- atts))
+ (set (if inactive 'jao-mode-line--inactive-face 'jao-mode-line--face) atts)))
+
+(defun jao-mode-line--revert-face (inactive)
+ (apply #'set-face-attribute (if inactive 'mode-line-inactive 'mode-line) nil
+ (if inactive jao-mode-line--inactive-face jao-mode-line--face)))
(defun jao-mode-line-adjust-faces ()
(let ((bg (frame-parameter nil 'background-color)))
- (setq jao-mode-line--face (jao-mode-line--extract-face 'mode-line))
- (setq jao-mode-line--inactive-face
- (jao-mode-line--extract-face 'mode-line-inactive))
+ (jao-mode-line--extract-face nil)
+ (jao-mode-line--extract-face t)
(set-face-attribute 'mode-line nil :box nil :height 1
:background bg :foreground bg
:overline jao-minibuffer-active-buffer-line-color
@@ -129,7 +133,7 @@
;;;###autoload
(defun jao-mode-line-add-to-minibuffer (&optional order)
(interactive)
- (setq jao-mode-line--original-modeline mode-line-format)
+ (setq jao-mode-line--old-format mode-line-format)
(setq-default mode-line-format '(" "))
(setq-default mode-line-position jao-mode-line--position)
(dolist (b (buffer-list))
@@ -140,14 +144,13 @@
;;;###autoload
(defun jao-mode-line-remove-from-minibuffer ()
(interactive)
- (apply #'set-face-attribute 'mode-line nil jao-mode-line--face)
- (apply #'set-face-attribute 'mode-line-inactive nil jao-mode-line--inactive-face)
- (setq-default mode-line-format jao-mode-line--original-modeline)
+ (jao-mode-line--revert-face nil)
+ (jao-mode-line--revert-face t)
+ (setq-default mode-line-format jao-mode-line--old-format)
(dolist (b (buffer-list))
- (with-current-buffer b (setq-local mode-line-format
- jao-mode-line--original-modeline)))
- (setq jao-minibuffer-info
- (remove '(:eval jao-mode-line--format) jao-minibuffer-info)))
+ (with-current-buffer b
+ (setq-local mode-line-format jao-mode-line--old-format)))
+ (jao-minibuffer-remove-variable 'jao-mode-line--format))
(provide 'jao-mode-line)
diff --git a/lib/themes/jao-light-theme.el b/lib/themes/jao-light-theme.el
index fe31bed..a9786ea 100644
--- a/lib/themes/jao-light-theme.el
+++ b/lib/themes/jao-light-theme.el
@@ -117,6 +117,6 @@
(widget-button (~ default) nit (ul "grey80"))))
;; (enable-theme 'jao-light)
-;; (jao-minibuffer-mode-line-adjust-faces)
+;; (jao-mode-line-adjust-faces)
(provide 'jao-light-theme)