branch: externals/ement commit 565b9991705e5c0a26a24911e959384f80319f26 Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Fix: (ement-notify--log-to-buffer) Select log buffer's window Should work around EWOC bug similarly to how we do it elsewhere. Fixes #191. Thanks to Phil Sainty (@phil-s). --- README.org | 1 + ement-notify.el | 64 ++++++++++++++++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/README.org b/README.org index 7cbd2314bf..a6b6ec41ae 100644 --- a/README.org +++ b/README.org @@ -314,6 +314,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time + Clean up SSO server process after two minutes in case SSO login fails. + Don't stop syncing if an error is signaled while sending a notification. + Command ~ement-room-list-next-unread~ could enter an infinite loop. (Thanks to [[https://github.com/vizs][Visuwesh]] and ~@mrtnmrtn:matrix.org~.) ++ Events in notifications buffer could appear out-of-order. ([[https://github.com/alphapapa/ement.el/issues/191][#191]]. Thanks to [[https://github.com/phil-s][Phil Sainty]].) ** 0.10 diff --git a/ement-notify.el b/ement-notify.el index eedef263cd..ef26f7c06a 100644 --- a/ement-notify.el +++ b/ement-notify.el @@ -281,36 +281,40 @@ If ROOM has no existing buffer, do nothing." ;; just to be safe... (when (equal "m.room.message" (ement-event-type event)) (with-current-buffer (ement-notify--log-buffer buffer-name) - (let* ((ement-session session) - (ement-room room) - (ement-room-sender-in-left-margin nil) - (ement-room-message-format-spec "%o%O »%W %S> %B%R%t") - (new-node (ement-room--insert-event event)) - (inhibit-read-only t) - start end) - (ewoc-goto-node ement-ewoc new-node) - (setf start (point)) - (if-let (next-node (ewoc-next ement-ewoc new-node)) - (ewoc-goto-node ement-ewoc next-node) - (goto-char (point-max))) - (setf end (- (point) 2)) - (add-text-properties start end - (list 'button '(t) - 'category 'default-button - 'action #'ement-notify-button-action - 'session session - 'room room - 'event event)) - ;; Remove button face property. - (alter-text-property start end 'face - (lambda (face) - (pcase face - ('button nil) - ((pred listp) (remq 'button face)) - (_ face)))) - (when ement-notify-prism-background - (add-face-text-property start end (list :background (ement-notify--room-background-color room) - :extend t)))))))) + (save-window-excursion + (when-let ((buffer-window (get-buffer-window (current-buffer)))) + ;; Select the buffer's window to avoid EWOC bug. (See #191.) + (select-window buffer-window)) + (let* ((ement-session session) + (ement-room room) + (ement-room-sender-in-left-margin nil) + (ement-room-message-format-spec "%o%O »%W %S> %B%R%t") + (new-node (ement-room--insert-event event)) + (inhibit-read-only t) + start end) + (ewoc-goto-node ement-ewoc new-node) + (setf start (point)) + (if-let (next-node (ewoc-next ement-ewoc new-node)) + (ewoc-goto-node ement-ewoc next-node) + (goto-char (point-max))) + (setf end (- (point) 2)) + (add-text-properties start end + (list 'button '(t) + 'category 'default-button + 'action #'ement-notify-button-action + 'session session + 'room room + 'event event)) + ;; Remove button face property. + (alter-text-property start end 'face + (lambda (face) + (pcase face + ('button nil) + ((pred listp) (remq 'button face)) + (_ face)))) + (when ement-notify-prism-background + (add-face-text-property start end (list :background (ement-notify--room-background-color room) + :extend t))))))))) (defun ement-notify--log-buffer (name) "Return an Ement notifications buffer named NAME."