Skip to content

Commit

Permalink
fix: restore minibuffer variables when enter minibuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
kiennq committed Mar 8, 2020
1 parent 0839819 commit de3f9d6
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions mini-modeline.el
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ Set this to the minimal value that doesn't cause truncation."
"Set buffer background for current buffer."
(when mini-modeline-color
(make-local-variable 'face-remapping-alist)
(add-to-list 'face-remapping-alist
`(default (:background ,mini-modeline-color)))))
(setf (alist-get 'default face-remapping-alist)
`((:background ,mini-modeline-color)))))

(defun mini-modeline--log (&rest args)
"Log message into message buffer with ARGS as same parameters in `message'."
Expand Down Expand Up @@ -289,6 +289,16 @@ BODY will be supplied with orig-func and args."
(setq mini-modeline--command-state 'end
echo-keystrokes mini-modeline--echo-keystrokes))

(defsubst mini-modeline--enter-minibuffer ()
"`minibuffer-setup-hook' of mini-modeline."
(when mini-modeline-enhance-visual
(mini-modeline--set-buffer-background))
(setq resize-mini-windows mini-modeline--orig-resize-mini-windows))

(defsubst mini-modeline--exit-minibuffer ()
"`minibuffer-exit-hook' of mini-modeline."
(setq resize-mini-windows nil))

(declare-function anzu--cons-mode-line "ext:anzu")
(declare-function anzu--reset-mode-line "ext:anzu")

Expand All @@ -309,7 +319,7 @@ BODY will be supplied with orig-func and args."
(if (display-graphic-p)
(setq mode-line-format " ")
(setq mode-line-format nil))
(if (and (minibufferp) mini-modeline-enhance-visual)
(if (and (minibufferp buf) mini-modeline-enhance-visual)
(mini-modeline--set-buffer-background)))))
(buffer-list))
;; Make the modeline in GUI a thin bar.
Expand All @@ -322,9 +332,10 @@ BODY will be supplied with orig-func and args."
(redisplay)
;; (add-hook 'pre-redisplay-functions #'mini-modeline-display)
(setq mini-modeline--timer (run-with-timer 0 0.1 #'mini-modeline-display))
(when mini-modeline-enhance-visual
(add-hook 'minibuffer-setup-hook #'mini-modeline--set-buffer-background))
(advice-add #'message :around #'mini-modeline--reroute-msg)

(add-hook 'minibuffer-setup-hook #'mini-modeline--enter-minibuffer)
(add-hook 'minibuffer-exit-hook #'mini-modeline--exit-minibuffer)
(add-hook 'pre-command-hook #'mini-modeline--pre-cmd)
(add-hook 'post-command-hook #'mini-modeline--post-cmd)

Expand Down Expand Up @@ -374,9 +385,10 @@ BODY will be supplied with orig-func and args."
;; (remove-hook 'pre-redisplay-functions #'mini-modeline-display)
(when (timerp (cancel-timer mini-modeline--timer)))
(mini-modeline-display 'clear)
(when mini-modeline-enhance-visual
(remove-hook 'minibuffer-setup-hook #'mini-modeline--set-buffer-background))
(advice-remove #'message #'mini-modeline--reroute-msg)

(remove-hook 'minibuffer-setup-hook #'mini-modeline--enter-minibuffer)
(remove-hook 'minibuffer-exit-hook #'mini-modeline--exit-minibuffer)
(remove-hook 'pre-command-hook #'mini-modeline--pre-cmd)
(remove-hook 'post-command-hook #'mini-modeline--post-cmd)

Expand Down

0 comments on commit de3f9d6

Please sign in to comment.