Skip to content

Commit

Permalink
enh: rewrite echo area only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
AmaiKinono committed Dec 21, 2020
1 parent 7dcd0ab commit 9c316e8
Showing 1 changed file with 20 additions and 16 deletions.
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 (string= (car modeline-content)
(car 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

0 comments on commit 9c316e8

Please sign in to comment.