From 151f9acc22d55180b765070d03e5d92c7c3cd7f1 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 30 May 2022 02:16:39 -0500 Subject: [PATCH] Change: (ement-taxy-next-unread) Use ement--room-unread-p --- ement-taxy.el | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/ement-taxy.el b/ement-taxy.el index d6c93fb..424016d 100644 --- a/ement-taxy.el +++ b/ement-taxy.el @@ -556,28 +556,19 @@ left." (interactive) (unless (button-at (point)) (call-interactively #'forward-button)) - (cl-labels ((room-unread-p - () (pcase-let* ((`[,room ,_session] (oref (magit-current-section) value)) - ((cl-struct ement-room unread-notifications local) room) - ((map notification_count highlight_count) unread-notifications) - ((map buffer) local)) - ;; For now, we test both unread count and whether the buffer is - ;; modified; later, we might do only the former (still to be worked - ;; out how canonical notifications are handled). - (or (and (buffer-live-p buffer) (buffer-modified-p buffer)) - (and unread-notifications - (or (not (zerop notification_count)) - (not (zerop highlight_count)))))))) - (unless (cl-loop with starting-line = (line-number-at-pos) - if (room-unread-p) - do (progn - (goto-char (button-end (button-at (point)))) - (push-button (1- (point))) - (cl-return t)) - else do (call-interactively #'forward-button) - while (> (line-number-at-pos) starting-line)) - ;; No more unread rooms. - (message "No more unread rooms")))) + (unless (cl-loop with starting-line = (line-number-at-pos) + for value = (oref (magit-current-section) value) + for room = (elt value 0) + for session = (elt value 1) + if (ement--room-unread-p room session) + do (progn + (goto-char (button-end (button-at (point)))) + (push-button (1- (point))) + (cl-return t)) + else do (call-interactively #'forward-button) + while (> (line-number-at-pos) starting-line)) + ;; No more unread rooms. + (message "No more unread rooms"))) (define-derived-mode ement-taxy-mode magit-section-mode "Ement-Taxy" :global nil