branch: externals/rcirc-menu commit 0a5a1130ba3ab815afdd1131639c08d5f5ad4d27 Author: Alex Schroeder <a...@gnu.org> Commit: Alex Schroeder <a...@gnu.org>
rcirc-menu.el: fontify activity column --- rcirc-menu.el | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/rcirc-menu.el b/rcirc-menu.el index e875c3e..0d801ed 100644 --- a/rcirc-menu.el +++ b/rcirc-menu.el @@ -194,9 +194,7 @@ In Rcirc Menu mode, the following commands are defined: (or rcirc-target "") ;; "Target" (with-current-buffer rcirc-server-buffer rcirc-server-name) ;; "Server" - (mapconcat (lambda (s) (if s (symbol-name s) "yes")) - rcirc-activity-types - ", "))) ;; "Activity" + (rcirc-menu-activity))) ;; "Activity" entries)))) (setq tabulated-list-entries (nreverse entries))) (tabulated-list-init-header)) @@ -216,16 +214,43 @@ elements of ‘tabulated-list-entries’." (defun rcirc-menu-sort-activity (&rest args) "Sort by activity. ARGS is a list of two elements having the same form as the -elements of ‘tabulated-list-entries’." +elements of ‘tabulated-list-entries’. At this point, we only have +the comma-separated string produced by `rcirc-menu-activity' in +the vector. The alternative is to simply visit the buffers and +examine `rcirc-activity-types'." + (setq args (mapcar (lambda (v) + (let ((buf (car v))) + (with-current-buffer buf + (cond ((memq 'nick rcirc-activity-types) 1) + ((memq 'keyword rcirc-activity-types) 2) + (rcirc-activity-types 3) + (t 4))))) + args)) + (apply '< args)) + +(defun rcirc-menu-sort-activity-symbols (&rest args) + "Sort by activity symbols. +ARGS are symbols from `rcirc-activity-types'." (setq args (mapcar (lambda (v) - (let ((s (aref (cadr v) 4))) - (cond ((string-match "nick" s) 1) - ((string-match "key" s) 2) - ((string-match "yes" s) 3) - (t 4)))) + (cond ((eq v 'nick) 1) + ((eq v 'keyword) 2) + ((not v) 3) + (t 4))) args)) (apply '< args)) +(defun rcirc-menu-activity () + "Return string describing activity in the current buffer." + (mapconcat (lambda (s) + (cond ((eq s 'nick) + (rcirc-facify "nick" 'rcirc-track-nick)) + ((eq s 'keyword) + (rcirc-facify "keyword" 'rcirc-track-keyword)) + (t "yes"))) + (sort (copy-sequence rcirc-activity-types) + 'rcirc-menu-sort-activity-symbols) + ", ")) + (defun rcirc-menu-catchup () "Mark the current buffer or the marked buffers as read. This resets their activity."