Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh: rewrite echo area only when needed #50

Merged
merged 1 commit into from
Jul 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions mini-modeline.el
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ When ARG is:
(let ((truncate-lines mini-modeline-truncate-p)
(inhibit-read-only t)
(inhibit-redisplay t)
(buffer-undo-list t))
(buffer-undo-list t)
modeline-content)
(when (or (memq arg '(force clear))
(mini-modeline--overduep mini-modeline--last-update
mini-modeline-update-interval))
Expand All @@ -205,8 +206,8 @@ When ARG is:
(setq mini-modeline--msg nil))
;; Showing mini-modeline
(if (eq arg 'clear)
(setq mini-modeline--cache nil)
(setq mini-modeline--cache
(setq modeline-content nil)
(setq modeline-content
(mini-modeline--multi-lr-render
(if mini-modeline--msg
(format-mode-line '(:eval (mini-modeline-msg)))
Expand All @@ -215,19 +216,22 @@ When ARG is:
(setq mini-modeline--last-update (current-time)))

;; write to minibuffer
(erase-buffer)
(when mini-modeline--cache
(let ((height-delta (- (cdr mini-modeline--cache)
(window-height (minibuffer-window mini-modeline-frame))))
;; ; let mini-modeline take control of mini-buffer size
(resize-mini-windows t))
(when (or (> height-delta 0)
;; this is to prevent window flashing for consecutive multi-line message
(mini-modeline--overduep mini-modeline--last-change-size
mini-modeline-echo-duration))
(window-resize (minibuffer-window mini-modeline-frame) height-delta)
(setq mini-modeline--last-change-size (current-time)))
(insert (car mini-modeline--cache)))))))))
(unless (equal modeline-content
mini-modeline--cache)
(setq mini-modeline--cache modeline-content)
(erase-buffer)
(when mini-modeline--cache
(let ((height-delta (- (cdr mini-modeline--cache)
(window-height (minibuffer-window mini-modeline-frame))))
;; ; let mini-modeline take control of mini-buffer size
(resize-mini-windows t))
(when (or (> height-delta 0)
;; this is to prevent window flashing for consecutive multi-line message
(mini-modeline--overduep mini-modeline--last-change-size
mini-modeline-echo-duration))
(window-resize (minibuffer-window mini-modeline-frame) height-delta)
(setq mini-modeline--last-change-size (current-time)))
(insert (car mini-modeline--cache))))))))))
((error debug)
(mini-modeline--log "mini-modeline: %s\n" err)))))

Expand Down