diff options
-rw-r--r-- | init.org | 8 | ||||
-rw-r--r-- | lib/eos/jao-minibuffer.el | 44 |
2 files changed, 33 insertions, 19 deletions
@@ -611,7 +611,8 @@ jao-minibuffer-inactive-buffer-line-color "grey65")) :commands (jao-minibuffer-add-variable jao-minibuffer-refresh - jao-minibuffer-add-mode-line)) + jao-minibuffer-add-mode-line + jao-minibuffer-mode)) (setq enable-recursive-minibuffers t) (require 'mb-depth) @@ -620,6 +621,7 @@ (setq minibuffer-eldef-shorten-default t) (minibuffer-electric-default-mode 1) + (jao-minibuffer-mode 1) (when jao-modeline-in-minibuffer-p (jao-minibuffer-add-mode-line 90)) #+end_src @@ -1138,7 +1140,7 @@ (other-window -1)) (defun jao--nth-window (n) - (let ((jao-minibuffer-enabled-p nil) + (let ((jao-minibuffer-mode nil) (ignore-window-parameters t)) (select-window (frame-first-window)) (other-window n)) @@ -1644,7 +1646,7 @@ ;; scrolling functions to force a redisplay by going to ;; another window. (defun jao--refresh (&rest _rest) - (let ((jao-minibuffer-enabled-p nil)) + (let ((jao-minibuffer-mode nil)) (other-window 1) (other-window -1))) (use-package doc-view diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el index 6445393..7e21db0 100644 --- a/lib/eos/jao-minibuffer.el +++ b/lib/eos/jao-minibuffer.el @@ -29,18 +29,16 @@ (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 nil) +(defvar jao-minibuffer-maximized-frames-p t) (defvar jao-minibuffer-frame-width nil) (defvar jao-minibuffer-notification-timeout 5) -(defvar jao-minibuffer-enabled-p t) (defvar jao-minibuffer-active-buffer-line-color "azure4") (defvar jao-minibuffer-inactive-buffer-line-color "grey25") (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." + "Return TEXT with padding on the left." (let* ((len (+ (string-pixel-width text) (string-pixel-width jao-minibuffer-right-margin))) (padding (propertize @@ -109,7 +107,7 @@ The padding pushes TEXT to the right edge of the mode-line." " " msg)))) (defun jao-minibuffer--set-message (msg) - (if (or (not jao-minibuffer-enabled-p) + (if (or (not jao-minibuffer-mode) (and msg (not (string-blank-p msg)) (bound-and-true-p current-minibuffer-command))) @@ -192,29 +190,43 @@ The padding pushes TEXT to the right edge of the mode-line." (jao-minibuffer-adjust-mode-line-faces)) ;;;###autoload -(defun jao-minibuffer-toggle () +(defun jao-minibuffer-turn-on () (interactive) - (setq jao-minibuffer-enabled-p (not jao-minibuffer-enabled-p)) - (if jao-minibuffer-enabled-p - (jao-minibuffer-refresh) - (jao-minibuffer--insert ""))) + (advice-add 'select-window :after #'jao-minibuffer-refresh) + (advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh) + (setq set-message-function #'jao-minibuffer--format-msg) + (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 + (if jao-minibuffer-mode + (jao-minibuffer-turn-on) + (jao-minibuffer-turn-off))) ;;;###autoload (defun jao-minibuffer-refresh (&rest _ignore) (interactive) - (when (and jao-minibuffer-enabled-p + (when (and jao-minibuffer-mode (not (bound-and-true-p current-minibuffer-command))) - (let* ((jao-minibuffer-enabled-p nil) + (let* ((jao-minibuffer-mode nil) (window-selection-change-functions nil) (msg (jao-minibuffer--format-info jao-minibuffer-msg-info)) (msg (jao-minibuffer--format-msg (or msg "")))) (jao-minibuffer--insert (or msg ""))))) -(setq set-message-function #'jao-minibuffer--format-msg) -(setq clear-message-function #'jao-minibuffer-refresh) ;; (add-hook 'window-selection-change-functions #'jao-minibuffer-refresh) -(advice-add 'select-window :after #'jao-minibuffer-refresh) -(advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh) (provide 'jao-minibuffer) ;;; jao-minibuffer.el ends here |