From ba7b2d1770a276092cabe42dd2f86975cb4f59f9 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 24 Jan 2022 04:47:40 +0000 Subject: jao-minibufer: clean-ups --- lib/eos/jao-minibuffer.el | 81 +++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 55 deletions(-) (limited to 'lib') diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el index 8982011..2fade40 100644 --- a/lib/eos/jao-minibuffer.el +++ b/lib/eos/jao-minibuffer.el @@ -26,12 +26,10 @@ (defvar jao-minibuffer-info ()) (defvar jao-minibuffer-msg-info '("")) -(defvar jao-minibuffer-notification nil) (defvar jao-minibuffer-align-right-p t) (defvar jao-minibuffer-right-margin (if window-system "" " ")) (defvar jao-minibuffer-maximized-frames-p t) (defvar jao-minibuffer-frame-width nil) -(defvar jao-minibuffer-notification-timeout 5) (defvar jao-minibuffer-active-buffer-line-color "azure4") (defvar jao-minibuffer-inactive-buffer-line-color "grey25") @@ -42,10 +40,6 @@ (format (format "%%%ds" (if jao-minibuffer-align-right-p w (- w))) s) (substring s 0 w))) -(defun jao-minibuffer--current () - (with-current-buffer jao-minibuffer--name - (buffer-substring (point-min) (point-max)))) - (defun jao-minibuffer--width () (cond ((numberp jao-minibuffer-frame-width) jao-minibuffer-frame-width) (jao-minibuffer-maximized-frames-p (frame-width)) @@ -60,16 +54,12 @@ (reverse (or info jao-minibuffer-info))))) " ")) -(defun jao-minibuffer--aligned (&optional w currentp) - (let* ((msg (cond (currentp (jao-minibuffer--current)) - (jao-minibuffer-notification - (format-mode-line jao-minibuffer-notification)) - (t (jao-minibuffer--format-info)))) - (msg (if jao-minibuffer-align-right-p - (string-trim msg) - (string-trim-left msg))) +(defun jao-minibuffer--aligned (&optional 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))) - (when (not (string-empty-p msg)) + (unless (string-empty-p msg) (let* ((mw (jao-minibuffer--width)) (w (- mw (mod w mw) (length jao-minibuffer-right-margin) -1))) (if (> w 0) (jao-minibuffer--trim msg w) ""))))) @@ -101,10 +91,6 @@ (defun jao-minibuffer--set-message (msg) (when jao-minibuffer-mode (jao-minibuffer--format-msg (or msg "")))) -(defvar-local w3m-current-title nil) -(defvar-local eww-data nil) -(defvar-local jao-notmuch--tree-buffer nil) -(defvar circe-chat-target nil) (defvar exwm-class-name nil) (defvar jao-minibuffer--mode-line-position @@ -112,20 +98,17 @@ ("%n %2c %l " (:eval (format "%d" (line-number-at-pos (point-max))))))) +(defvar jao-minibuffer--mode-line-bid + '(:eval (cond ((derived-mode-p 'gnus-group-mode + 'gnus-article-mode + 'gnus-summary-mode) + mode-line-buffer-identification) + ((derived-mode-p 'circe-channel-mode) + (format "%s [%d]" (buffer-name) (length (circe-channel-nicks)))) + (t "%b")))) + (defvar jao-minibuffer--mode-line-format - `("%[" - (:propertize - (:eval (cond ((derived-mode-p 'gnus-group-mode - 'gnus-article-mode - 'gnus-summary-mode) - mode-line-buffer-identification) - ((derived-mode-p 'circe-channel-mode) - (format "%s [%d]" (buffer-name) (length (circe-channel-nicks)))) - (jao-notmuch--tree-buffer (buffer-name jao-notmuch--tree-buffer)) - ((not (null eww-data)) (plist-get eww-data :title)) - (t "%b"))) - face jao-themes-f00) - "%]" + `("%[" (:propertize ,jao-minibuffer--mode-line-bid face jao-themes-f00) "%]" (:propertize " (" face jao-themes-dimm) (:propertize mode-name face jao-themes-f00) (:propertize ("" minor-mode-alist) face jao-themes-f11) @@ -176,33 +159,21 @@ (jao-minibuffer-add-variable 'jao-minibuffer--mode-line-format order) (jao-minibuffer-adjust-mode-line-faces)) -;;;###autoload -(defun jao-minibuffer-turn-on () - (interactive) - (advice-add 'select-window :after #'jao-minibuffer-refresh) - (advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh) - (setq set-message-function #'jao-minibuffer--set-message) - (setq clear-message-function #'jao-minibuffer-refresh) - (jao-minibuffer-refresh)) - -;;;###autoload -(defun jao-minibuffer-turn-off () - (interactive) - (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 "")) - ;;;###autoload (define-minor-mode jao-minibuffer-mode "Show minibuffer status" - :global t - :lighter "" - :group 'jao + :global t :lighter "" :group 'jao (if jao-minibuffer-mode - (jao-minibuffer-turn-on) - (jao-minibuffer-turn-off))) + (progn (advice-add 'select-window :after #'jao-minibuffer-refresh) + (advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh) + (setq set-message-function #'jao-minibuffer--set-message) + (setq clear-message-function #'jao-minibuffer-refresh) + (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 ""))) ;;;###autoload (defun jao-minibuffer-refresh (&rest _ignore) -- cgit v1.2.3