* riece-highlight.el (riece-channel-list-mark-current-channel):
authorueno <ueno>
Tue, 26 Aug 2003 06:35:06 +0000 (06:35 +0000)
committerueno <ueno>
Tue, 26 Aug 2003 06:35:06 +0000 (06:35 +0000)
New function.

* riece-display.el (riece-channel-list-changed): New variable.
(riece-update-channel-list-buffer): Check riece-channel-list-changed.
(riece-update-channel-list-indicator): Ditto.

lisp/ChangeLog
lisp/riece-display.el
lisp/riece-highlight.el

index 79a6b03..30e444c 100644 (file)
@@ -1,5 +1,14 @@
 2003-08-26  Daiki Ueno  <ueno@unixuser.org>
 
+       * riece-highlight.el (riece-channel-list-mark-current-channel):
+       New function.
+
+       * riece-display.el (riece-channel-list-changed): New variable.
+       (riece-update-channel-list-buffer): Check riece-channel-list-changed.
+       (riece-update-channel-list-indicator): Ditto.
+
+2003-08-26  Daiki Ueno  <ueno@unixuser.org>
+
        * riece-options.el (riece-addons): Enable riece-unread by default.
 
        * riece-highlight.el (riece-channel-list-current-face): New variable.
index 2f22561..e72fe27 100644 (file)
@@ -37,6 +37,8 @@
     riece-update-short-channel-indicator
     riece-update-channel-list-indicator))
 
+(defvar riece-channel-list-changed nil)
+
 (defun riece-update-user-list-buffer ()
   (save-excursion
     (set-buffer riece-user-list-buffer)
            (setq users (cdr users))))))))
 
 (defun riece-update-channel-list-buffer ()
-  (save-excursion
-    (set-buffer riece-channel-list-buffer)
-    (let ((inhibit-read-only t)
-         buffer-read-only
-         (index 1)
-         (channels riece-current-channels))
-      (erase-buffer)
-      (while channels
-       (if (car channels)
-           (let ((point (point)))
-             (insert (format "%2d:%c%s\n" index
-                             (if (riece-identity-equal
-                                  (car channels)
-                                  riece-current-channel)
-                                 ?*
-                               ?\ )
-                             (riece-format-identity (car channels))))
-             (put-text-property point (point) 'riece-identity
-                                (car channels))))
-       (setq index (1+ index)
-             channels (cdr channels))))))
+  (if riece-channel-list-changed
+      (save-excursion
+       (set-buffer riece-channel-list-buffer)
+       (let ((inhibit-read-only t)
+             buffer-read-only
+             (index 1)
+             (channels riece-current-channels))
+         (erase-buffer)
+         (while channels
+           (if (car channels)
+               (let ((point (point)))
+                 (insert (format "%2d: %s\n" index
+                                 (riece-format-identity (car channels))))
+                 (put-text-property point (point) 'riece-identity
+                                    (car channels))))
+           (setq index (1+ index)
+                 channels (cdr channels))))
+       (setq riece-channel-list-changed nil))))
 
 (defun riece-update-channel-indicator ()
   (setq riece-channel-indicator
          "None")))
 
 (defun riece-update-channel-list-indicator ()
-  (if (and riece-current-channels
-          ;; There is at least one channel.
-          (delq nil (copy-sequence riece-current-channels)))
-      (let ((index 1))
-       (setq riece-channel-list-indicator
-             (mapconcat
-              #'identity
-              (delq nil
-                    (mapcar
-                     (lambda (channel)
-                       (prog1 (if channel
-                                  (format "%d:%s" index
-                                          (riece-format-identity channel)))
-                         (setq index (1+ index))))
-                     riece-current-channels))
-              ",")))
-    (setq riece-channel-list-indicator "No channel")))
+  (if riece-channel-list-changed
+      (if (and riece-current-channels
+              ;; There is at least one channel.
+              (delq nil (copy-sequence riece-current-channels)))
+         (let ((index 1))
+           (setq riece-channel-list-indicator
+                 (mapconcat
+                  #'identity
+                  (delq nil
+                        (mapcar
+                         (lambda (channel)
+                           (prog1
+                               (if channel
+                                   (format "%d:%s" index
+                                           (riece-format-identity channel)))
+                             (setq index (1+ index))))
+                         riece-current-channels))
+                  ",")))
+       (setq riece-channel-list-indicator "No channel"))))
 
 (defun riece-update-status-indicators ()
   (if riece-current-channel
              (if channel
                  (riece-parse-identity channel)))
            riece-default-channel-binding)))
-    (riece-channel-buffer-create identity)))
+    (riece-channel-buffer-create identity)
+    (setq riece-channel-list-changed t)))
 
 (defun riece-switch-to-nearest-channel (pointer)
   (let ((start riece-current-channels)
     (if pointer
        (setcar pointer nil))
     (if (riece-identity-equal identity riece-current-channel)
-       (riece-switch-to-nearest-channel pointer))))
+       (riece-switch-to-nearest-channel pointer))
+    (setq riece-channel-list-changed t)))
 
 (defun riece-redisplay-buffers (&optional force)
   (riece-update-buffers)
index a01575f..f6a50f3 100644 (file)
     (if (looking-at riece-prefix-regexp)
        (put-text-property (match-beginning 1) (match-end 1) 'invisible t))))
 
+(defun riece-channel-list-mark-current-channel ()
+  (if (and riece-channel-list-buffer-mode
+          riece-current-channel)
+      (save-excursion
+       (set-buffer riece-channel-list-buffer)
+       (let ((inhibit-read-only t)
+             buffer-read-only)
+         (goto-char (point-min))
+         (if (re-search-forward "^\\( ?[0-9]+:\\)\\*" nil t)
+             (replace-match "\\1 "))
+         (goto-char (point-min))
+         (if (re-search-forward
+              (concat
+               "^\\( ?[0-9]+:\\).\\("
+               (regexp-quote (riece-format-identity riece-current-channel))
+               "\\)$") nil t)
+             (replace-match "\\1*\\2"))))))
+
 (defun riece-channel-list-turn-on-font-lock ()
   (make-local-variable 'font-lock-defaults)
   (setq font-lock-defaults '(riece-channel-list-font-lock-keywords t))
            'riece-dialogue-schedule-turn-on-font-lock)
   (put 'riece-channel-list-mode 'font-lock-defaults
        '(riece-channel-list-font-lock-keywords t))
+  (add-hook 'riece-channel-switch-hook
+           'riece-channel-list-mark-current-channel)
   (add-hook 'riece-after-load-startup-hook
            'riece-channel-list-schedule-turn-on-font-lock))