Change: (ement-room--insert-events) Follow new events

When window-point is at point-max, keep it there after inserting
events.
This commit is contained in:
Adam Porter 2021-07-27 02:22:37 -05:00
parent 89b7b28f89
commit 1c31756af5

View file

@ -410,10 +410,11 @@ timestamp headers into appropriate places while maintaining
point's position. If RETRO is non-nil, assume EVENTS are earlier point's position. If RETRO is non-nil, assume EVENTS are earlier
than any existing events, and only insert timestamp headers up to than any existing events, and only insert timestamp headers up to
the previously oldest event." the previously oldest event."
(let (buffer-window point-node orig-first-node) (let (buffer-window point-node orig-first-node point-max-p)
(when (get-buffer-window (current-buffer)) (when (get-buffer-window (current-buffer))
;; HACK: See below. ;; HACK: See below.
(setf buffer-window (get-buffer-window (current-buffer)))) (setf buffer-window (get-buffer-window (current-buffer))
point-max-p (= (point) (point-max))))
(when (and buffer-window retro) (when (and buffer-window retro)
(setf point-node (ewoc-locate ement-ewoc (window-start buffer-window)) (setf point-node (ewoc-locate ement-ewoc (window-start buffer-window))
orig-first-node (ewoc-nth ement-ewoc 0))) orig-first-node (ewoc-nth ement-ewoc 0)))
@ -441,11 +442,12 @@ the previously oldest event."
;; for a long time, as the time to do this in each buffer will increase with the ;; for a long time, as the time to do this in each buffer will increase with the
;; number of events. At least we only do it once per batch of events.) ;; number of events. At least we only do it once per batch of events.)
(ement-room--insert-ts-headers nil (when retro orig-first-node)) (ement-room--insert-ts-headers nil (when retro orig-first-node))
(when (and buffer-window retro) (when buffer-window
(with-selected-window buffer-window (cond (retro (with-selected-window buffer-window
(set-window-start nil (ewoc-location point-node)) (set-window-start buffer-window (ewoc-location point-node))
;; TODO: Experiment with this. ;; TODO: Experiment with this.
(forward-line -1))))) (forward-line -1)))
(point-max-p (set-window-point buffer-window (point-max)))))))
(declare-function ement--make-event "ement.el") (declare-function ement--make-event "ement.el")
(defun ement-room-retro-callback (room data) (defun ement-room-retro-callback (room data)