Merge signal-slot branch.
[riece] / lisp / riece-unread.el
index 1356385..b2b2a28 100644 (file)
@@ -35,6 +35,7 @@
 
 (require 'riece-message)
 (require 'riece-commands)
+(require 'riece-signal)
 
 (eval-when-compile (require 'riece-highlight))
 
                                     riece-unread-channels))
     (setq riece-unread-channels
          (cons (riece-message-target message) riece-unread-channels))
-    (riece-redisplay-buffers)))
+    (riece-emit-signal 'channel-list-changed)))
 
 (defun riece-unread-after-switch-to-channel-function (last)
   (setq riece-unread-channels
        (delete riece-current-channel
                riece-unread-channels)))
 
-(defun riece-unread-format-channel-list-line (index channel)
-  (if (riece-identity-member channel riece-unread-channels)
+(defun riece-unread-format-identity-for-channel-list-buffer (index identity)
+  (if (riece-identity-member identity riece-unread-channels)
       (concat (format "%2d:!" index)
-             (riece-format-identity channel)
-             "\n")))
+             (riece-format-identity identity))))
+
+(defun riece-unread-format-identity-for-channel-list-indicator (index identity)
+  (if (riece-identity-member identity riece-unread-channels)
+      (let ((string (riece-format-identity identity))
+           (start 0)
+           extent)
+       ;; Escape % -> %%.
+       (while (string-match "%" string start)
+         (setq start (1+ (match-end 0))
+               string (replace-match "%%" nil nil string)))
+       (list (format "%d:" index)
+             (riece-propertize-modeline-string
+              string 'face 'riece-channel-list-unread-face)))))
 
 (defun riece-unread-switch-to-channel ()
   (interactive)
            'riece-unread-after-display-message-function)
   (add-hook 'riece-after-switch-to-channel-functions
            'riece-unread-after-switch-to-channel-function)
-  (add-hook 'riece-format-channel-list-line-functions
-           'riece-unread-format-channel-list-line)
+  (add-hook 'riece-format-identity-for-channel-list-buffer-functions
+           'riece-unread-format-identity-for-channel-list-buffer)
+  (add-hook 'riece-format-identity-for-channel-list-indicator-functions
+           'riece-unread-format-identity-for-channel-list-indicator)
   (define-key riece-command-mode-map
     "\C-c\C-u" 'riece-unread-switch-to-channel)
   (define-key riece-dialogue-mode-map