branch: scratch/rcirc-menu
commit cd4c07a7f3d502253d3914b689b7d1d5a6e35cd2
Author: Alex Schroeder <a...@gnu.org>
Commit: Alex Schroeder <a...@gnu.org>

    rcirc-menu.el: add catching up and updating
    
    c and C will now mark a buffer as read. Changes to the rcirc activity
    string will also update the menu buffer.
---
 packages/rcirc-menu/rcirc-menu.el | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/packages/rcirc-menu/rcirc-menu.el 
b/packages/rcirc-menu/rcirc-menu.el
index b490f39..6905130 100644
--- a/packages/rcirc-menu/rcirc-menu.el
+++ b/packages/rcirc-menu/rcirc-menu.el
@@ -66,6 +66,8 @@
     (define-key map (kbd "M-s a C-s")   'Buffer-menu-isearch-buffers)
     (define-key map (kbd "M-s a M-C-s") 'Buffer-menu-isearch-buffers-regexp)
     (define-key map (kbd "M-s a C-o") 'Buffer-menu-multi-occur)
+    (define-key map "c" 'rcirc-menu-catchup)
+    (define-key map "C" 'rcirc-menu-catchup-all)
 
     (define-key map [mouse-2] 'Buffer-menu-mouse-select)
     (define-key map [follow-link] 'mouse-face)
@@ -78,6 +80,13 @@
       '(menu-item "Refresh" revert-buffer
                 :help "Refresh the *Rcirc Menu* buffer contents"))
     (bindings--define-key menu-map [s0] menu-bar-separator)
+    (bindings--define-key menu-map [cata]
+      '(menu-item "Catch up All" rcirc-menu-catchup-all
+                :help "Mark all buffers as read"))
+    (bindings--define-key menu-map [cat]
+      '(menu-item "Catch up" rcirc-menu-catchup
+                :help "Mark this buffer as read"))
+    (bindings--define-key menu-map [s1] menu-bar-separator)
     (bindings--define-key menu-map [sel]
       '(menu-item "Select Marked" Buffer-menu-select
                 :help "Select this line's buffer; also display buffers marked 
with `>'"))
@@ -217,4 +226,31 @@ elements of ‘tabulated-list-entries’."
                     args))
   (apply '< args))
 
+(defun rcirc-menu-catchup ()
+  "Mark the current buffer as read, i.e. no activity."
+  (interactive)
+  (rcirc-clear-activity (Buffer-menu-buffer t))
+  (run-hooks 'tabulated-list-revert-hook)
+  (tabulated-list-print))
+
+(defun rcirc-menu-catchup-all ()
+  "Mark all the buffers as read, i.e. no activity."
+  (interactive)
+  (dolist (buf (buffer-list))
+    (with-current-buffer buf
+      (when rcirc-activity-types
+       (rcirc-clear-activity buf))))
+  (run-hooks 'tabulated-list-revert-hook)
+  ;; don't move point
+  (tabulated-list-print))
+
+(add-hook 'rcirc-update-activity-string-hook
+         'rcirc-menu-update)
+
+(defun rcirc-menu-update ()
+  "Update the Rcirc Menu buffer, if any."
+  (with-current-buffer (get-buffer-create "*Rcirc Menu*")
+    ;; this will move point
+    (tabulated-list-revert)))
+
 ;;; rcirc-menu.el ends here

Reply via email to