Fix -- user list buffer not updating when parts are hidden.
[riece] / lisp / riece-handle.el
index 87a602a..fe1440a 100644 (file)
@@ -1,4 +1,4 @@
-;;; riece-handle.el --- basic message handlers
+;;; riece-handle.el --- basic message handlers -*- lexical-binding: t -*-
 ;; Copyright (C) 1998-2003 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
@@ -37,7 +37,7 @@
 (require 'riece-500)
 
 (defun riece-default-handle-numeric-reply
-  (client-prefix prefix number name string)
+  (client-prefix _prefix _number _name string)
   (riece-insert
    (list riece-dialogue-buffer riece-others-buffer)
    (concat client-prefix
                             (riece-make-identity (car targets)
                                                  riece-server-name)
                             message 'notice
-                            (riece-identity-equal-no-server
-                             user riece-real-nickname)))
+                            (if riece-real-nickname
+                                (riece-identity-equal-no-server
+                                 user riece-real-nickname))))
       ;; message from server
       (riece-insert-notice
        (list riece-dialogue-buffer riece-others-buffer)
        (concat (riece-concat-server-name message) "\n")))))
 
-(defun riece-handle-ping-message (prefix string)
+(defun riece-handle-ping-message (_prefix string)
   (riece-send-string (format "PONG :%s\r\n"
                             (if (eq (aref string 0) ?:)
                                 (substring string 1)
       (if (and riece-gather-channel-modes
               (riece-identity-equal-no-server user riece-real-nickname))
          (riece-send-string (format "MODE %s\r\n" (car channels))))
-      (let* ((channel-identity (riece-make-identity (car channels)
-                                                   riece-server-name))
-            (buffer (riece-channel-buffer channel-identity)))
-       (riece-insert-change
-        buffer
-        (format (riece-mcat "%s (%s) has joined %s\n")
-                (riece-format-identity user-identity t)
-                (riece-user-get-user-at-host user)
-                (riece-format-identity channel-identity t)))
-       (riece-insert-change
-        (if (and riece-channel-buffer-mode
-                 (not (eq buffer riece-channel-buffer)))
-            (list riece-dialogue-buffer riece-others-buffer)
-          riece-dialogue-buffer)
-        (concat
-         (riece-concat-server-name
-          (format (riece-mcat "%s (%s) has joined %s")
+      (unless (and (memq 'joins riece-hide-list)
+                  (not (riece-identity-equal-no-server
+                        user riece-real-nickname)))
+       (let* ((channel-identity (riece-make-identity (car channels)
+                                                     riece-server-name))
+              (buffer (riece-channel-buffer channel-identity)))
+         (riece-insert-change
+          buffer
+          (format (riece-mcat "%s (%s) has joined %s\n")
                   (riece-format-identity user-identity t)
                   (riece-user-get-user-at-host user)
                   (riece-format-identity channel-identity t)))
-         "\n")))
+         (riece-insert-change
+          (if (and riece-channel-buffer-mode
+                   (not (eq buffer riece-channel-buffer)))
+              (list riece-dialogue-buffer riece-others-buffer)
+            riece-dialogue-buffer)
+          (concat
+           (riece-concat-server-name
+            (format (riece-mcat "%s (%s) has joined %s")
+                    (riece-format-identity user-identity t)
+                    (riece-user-get-user-at-host user)
+                    (riece-format-identity channel-identity t)))
+           "\n"))))
       (setq channels (cdr channels)))))
 
 (defun riece-handle-part-message (prefix decoded)
         (channels (split-string (car parameters) ","))
         (user-identity (riece-make-identity user riece-server-name)))
     (while channels
-      (let* ((channel-identity (riece-make-identity (car channels)
-                                                   riece-server-name))
-            (buffer (riece-channel-buffer channel-identity))
+      (unless (and (memq 'parts riece-hide-list)
+                  (not (riece-identity-equal-no-server
+                        user riece-real-nickname)))
+       (let* ((channel-identity (riece-make-identity (car channels)
+                                                     riece-server-name))
+              (buffer (riece-channel-buffer channel-identity))
+              message)
+         (setq parameters (riece-split-parameters
+                           (riece-decoded-string-for-identity decoded
+                                                              channel-identity))
+               message (nth 1 parameters))
+         (riece-insert-change
+          buffer
+          (concat
+           (riece-concat-message
+            (format (riece-mcat "%s has left %s")
+                    (riece-format-identity user-identity t)
+                    (riece-format-identity channel-identity t))
             message)
-       (setq parameters (riece-split-parameters
-                         (riece-decoded-string-for-identity decoded
-                                                            channel-identity))
-             message (nth 1 parameters))
-       (riece-insert-change
-        buffer
-        (concat
-         (riece-concat-message
-          (format (riece-mcat "%s has left %s")
-                  (riece-format-identity user-identity t)
-                  (riece-format-identity channel-identity t))
-          message)
-         "\n"))
-       (riece-insert-change
-        (if (and riece-channel-buffer-mode
-                 (not (eq buffer riece-channel-buffer)))
-            (list riece-dialogue-buffer riece-others-buffer)
-          riece-dialogue-buffer)
-        (concat
-         (riece-concat-server-name
-          (riece-concat-message
-           (format (riece-mcat "%s has left %s")
-                   (riece-format-identity user-identity t)
-                   (riece-format-identity channel-identity t))
-           message))
-         "\n")))
+           "\n"))
+         (riece-insert-change
+          (if (and riece-channel-buffer-mode
+                   (not (eq buffer riece-channel-buffer)))
+              (list riece-dialogue-buffer riece-others-buffer)
+            riece-dialogue-buffer)
+          (concat
+           (riece-concat-server-name
+            (riece-concat-message
+             (format (riece-mcat "%s has left %s")
+                     (riece-format-identity user-identity t)
+                     (riece-format-identity channel-identity t))
+             message))
+           "\n"))))
       (riece-naming-assert-part user (car channels))
       (setq channels (cdr channels)))))
 
     (while pointer
       (riece-naming-assert-part user (car pointer))
       (setq pointer (cdr pointer)))
-    (let ((buffers
-          (delq nil (mapcar
-                     (lambda (channel)
-                       (riece-channel-buffer (riece-make-identity
-                                              channel riece-server-name)))
-                     channels))))
-      (riece-insert-change
-       buffers
-       (concat
-       (riece-concat-message
-        (format (riece-mcat "%s has left IRC")
-                (riece-format-identity user-identity t))
-        message)
-       "\n"))
-      (riece-insert-change
-       (if (and riece-channel-buffer-mode
-               (not (memq riece-channel-buffer buffers)))
-          (list riece-dialogue-buffer riece-others-buffer)
-        riece-dialogue-buffer)
-       (concat
-       (riece-concat-server-name
-        (riece-concat-message
-         (format (riece-mcat "%s has left IRC")
-                 (riece-format-identity user-identity t))
-         message))
-       "\n")))))
+    (unless (and (memq 'quits riece-hide-list)
+                (not (riece-identity-equal-no-server
+                      user riece-real-nickname)))
+      (let ((buffers
+            (delq nil (mapcar
+                       (lambda (channel)
+                         (riece-channel-buffer (riece-make-identity
+                                                channel riece-server-name)))
+                       channels))))
+       (riece-insert-change
+        buffers
+        (concat
+         (riece-concat-message
+          (format (riece-mcat "%s has left IRC")
+                  (riece-format-identity user-identity t))
+          message)
+         "\n"))
+       (riece-insert-change
+        (if (and riece-channel-buffer-mode
+                 (not (memq riece-channel-buffer buffers)))
+            (list riece-dialogue-buffer riece-others-buffer)
+          riece-dialogue-buffer)
+        (concat
+         (riece-concat-server-name
+          (riece-concat-message
+           (format (riece-mcat "%s has left IRC")
+                   (riece-format-identity user-identity t))
+           message))
+         "\n"))))))
 
 (defun riece-handle-kill-message (prefix string)
   (let* ((killer (riece-prefix-nickname prefix))