* Makefile.am: Export variables EMACS and XEMACS.
[elisp/liece.git] / lisp / liece-channel.el
index e340a23..aecc8ec 100644 (file)
   "Add MODE as char to CHNL."
   `(let ((modes (string-to-char-list (or (liece-channel-get-modes ,chnl)
                                         ""))))
-     (pushnew ,mode modes)
+     (or (memq ,mode modes)
+        (push ,mode modes))
      (put (intern (or ,chnl liece-current-channel) liece-obarray)
          'mode (mapconcat #'char-to-string modes ""))))
 
 (defmacro liece-channel-add-ban (pattern &optional chnl)
   "Add ban PATTERN as char to CHNL."
   `(let ((patterns (liece-channel-get-bans ,chnl)))
-     (add-to-list 'patterns ,pattern)
+     (or (string-list-member-ignore-case ,pattern patterns)
+        (push ,pattern patterns))
      (put (intern (or ,chnl liece-current-channel) liece-obarray)
          'ban patterns)))
 
 (defmacro liece-channel-add-exception (pattern &optional chnl)
   "Add exception PATTERN as char to CHNL."
   `(let ((patterns (liece-channel-get-exceptions ,chnl)))
-     (pushnew ,pattern patterns)
+     (or (string-list-member-ignore-case ,pattern patterns)
+        (push ,pattern patterns))
      (put (intern (or ,chnl liece-current-channel) liece-obarray)
          'exception patterns)))
 
 (defmacro liece-channel-add-invite (pattern &optional chnl)
   "Add invite PATTERN as char to CHNL."
   `(let ((patterns (liece-channel-get-invites ,chnl)))
-     (pushnew ,pattern patterns)
+     (or (string-list-member-ignore-case ,pattern patterns)
+        (push ,pattern patterns))
      (put (intern (or ,chnl liece-current-channel) liece-obarray)
          'invite patterns)))
 
@@ -362,7 +366,8 @@ If NOSW is non-nil do not switch to newly created channel."
   (let ((chnls (if (eq liece-command-buffer-mode 'chat)
                   liece-current-chat-partners
                 liece-current-channels))
-       (string ""))
+       (string "")
+       chnl)
     (with-current-buffer liece-channel-list-buffer
       (let ((n 1) buffer-read-only)
        (erase-buffer)
@@ -373,17 +378,18 @@ If NOSW is non-nil do not switch to newly created channel."
            (liece-channel-list-add-button n chnl))
          (incf n))))
     (if (string-equal string "")
-       (cond
-        ((eq liece-command-buffer-mode 'chat)
-         (setq liece-channels-indicator "No partner"
-               liece-current-chat-partner nil))
-        (t
-         (setq liece-channels-indicator "No channel"
-               liece-current-channel nil)))
+       (if (eq liece-command-buffer-mode 'chat)
+           (setq liece-channels-indicator "No partner")
+         (setq liece-channels-indicator "No channel"))
       (setq liece-channels-indicator (substring string 1)))
     (liece-set-channel-indicator)
-    (save-excursion
-      (run-hook-with-args 'liece-redisplay-buffer-functions chnl))
+    (setq chnl (if (eq liece-command-buffer-mode 'chat)
+                  liece-current-chat-partner
+                liece-current-channel))
+    (when chnl
+      (save-excursion
+       (run-hook-with-args 'liece-redisplay-buffer-functions chnl)))
+    (liece-redisplay-unread-mark)
     (liece-configure-windows)))
 
 (defsubst liece-channel-set-operator-1 (chnl user val)
@@ -502,9 +508,10 @@ If NOSW is non-nil do not switch to newly created channel."
         (cdr (string-assoc-ignore-case
               chnl liece-channel-buffer-alist)))
        (window (liece-get-buffer-window liece-channel-buffer)))
-    (and (liece-channel-unread-p chnl)
-        (setq liece-channel-unread-list
-              (delete chnl liece-channel-unread-list)))
+    (when (liece-channel-unread-p chnl)
+      (setq liece-channel-unread-list
+           (delete chnl liece-channel-unread-list))
+      (run-hook-with-args 'liece-channel-read-functions chnl))
     (and buffer window
         (with-current-buffer buffer
           (set-window-buffer window buffer)