* riece-signal.el (riece-connect-signal): Fixed doc.
authorueno <ueno>
Tue, 18 May 2004 03:46:17 +0000 (03:46 +0000)
committerueno <ueno>
Tue, 18 May 2004 03:46:17 +0000 (03:46 +0000)
(riece-disconnect-signal): New function.

* riece-ignore.el (riece-ignore-discard-message): New user option.
(riece-ignored-user-list): Renamed from riece-ignored-user.
(riece-ignore-by-user): Support unignore.

lisp/ChangeLog
lisp/riece-ignore.el
lisp/riece-signal.el

index 1293002..d86b58a 100644 (file)
@@ -1,5 +1,14 @@
 2004-05-18  Daiki Ueno  <ueno@unixuser.org>
 
+       * riece-signal.el (riece-connect-signal): Fixed doc.
+       (riece-disconnect-signal): New function.
+
+       * riece-ignore.el (riece-ignore-discard-message): New user option.
+       (riece-ignored-user-list): Renamed from riece-ignored-user.
+       (riece-ignore-by-user): Support unignore.
+
+2004-05-18  Daiki Ueno  <ueno@unixuser.org>
+
        * riece-url.el (riece-url-regexp): Accept ";".
 
        * riece-ignore.el: New add-on.
index c8a6383..32c36bb 100644 (file)
 (require 'riece-identity)
 (require 'riece-message)
 
-(defvar riece-ignored-user nil)
+(defgroup riece-ignore nil
+  "Ignore messages in IRC buffers."
+  :group 'riece)
 
-(defun riece-ignore-by-user (user)
+(defcustom riece-ignore-discard-message t
+  "If non-nil, messages from ignored user are completely discarded.
+Otherwise, they are left there but not visible."
+  :group 'riece-ignore
+  :type 'boolean)
+
+(defvar riece-ignored-user-list nil)
+
+(defun riece-ignore-user-rename-signal-function (signal handback)
+  (let ((pointer (riece-identity-member (car (riece-signal-args signal))
+                                       riece-ignored-user-list)))
+    (if pointer
+       (setcar pointer (nth 1 (riece-signal-args signal))))))
+
+(defun riece-ignore-by-user (user toggle)
   (interactive
    (let ((completion-ignore-case t))
-     (list (riece-completing-read-identity
-           "User: "
-           (riece-get-users-on-server (riece-current-server-name))))))
-  (setq riece-ignored-user (cons user riece-ignored-user))
-  (riece-connect-signal
-   'user-renamed
-   (lambda (signal handback)
-     (let ((pointer (riece-identity-member (car (riece-signal-args signal))
-                                          riece-ignored-user)))
-       (if pointer
-          (setcar pointer (nth 1 (riece-signal-args signal))))))))
+     (list (if current-prefix-arg
+              (riece-completing-read-identity
+               "Unignore user: "
+               riece-ignored-user-list)
+            (riece-completing-read-identity
+             "Ignore user: "
+             (riece-get-users-on-server (riece-current-server-name))
+             (lambda (user)
+               (not (riece-identity-member
+                     (riece-parse-identity user)
+                     riece-ignored-user-list)))))
+          (not current-prefix-arg))))
+  (if toggle
+      (progn
+       (setq riece-ignored-user-list (cons user riece-ignored-user-list))
+       (riece-connect-signal
+        'user-renamed
+        #'riece-ignore-user-rename-signal-function))
+    (let ((pointer (riece-identity-member user riece-ignored-user-list)))
+      (setq riece-ignored-user-list (delq (car pointer)
+                                         riece-ignored-user-list))
+      (riece-disconnect-signal
+       'user-renamed
+       #'riece-ignore-user-rename-signal-function))))
 
 (defun riece-ignore-message-filter (message)
-  (unless (riece-identity-member (riece-message-speaker message)
-                                riece-ignored-user)
+  (if (riece-identity-member (riece-message-speaker message)
+                            riece-ignored-user-list)
+      (unless riece-ignore-discard-message
+       (put-text-property 0 (length (riece-message-text message))
+                          'invisible 'riece-ignore
+                          (riece-message-text message))
+       message)
     message))
 
 (defvar riece-command-mode-map)
index cc0d310..c239a02 100644 (file)
@@ -72,12 +72,23 @@ This function is for internal use only."
   (aref signal 1))
 
 (defun riece-connect-signal (signal-name function &optional filter handback)
-  "Add SLOT as a listener of a signal identified by SIGNAL-NAME."
+  "Add FUNCTION as a listener of a signal identified by SIGNAL-NAME."
   (let ((symbol (intern (symbol-name signal-name) riece-signal-slot-obarray)))
     (set symbol (cons (riece-make-slot function filter handback)
                      (if (boundp symbol)
                          (symbol-value symbol))))))
 
+(defun riece-disconnect-signal (signal-name function)
+  "Remove FUNCTION from the listener of the signal identified by SIGNAL-NAME."
+  (let* ((symbol (intern-soft (symbol-name signal-name)
+                            riece-signal-slot-obarray))
+        (slots (symbol-value symbol)))
+    (while slots
+      (if (eq (riece-slot-function (car slots))
+             function)
+         (set symbol (delq (car slots) (symbol-value symbol))))
+      (setq slots (cdr slots)))))
+
 (defun riece-emit-signal (signal-name &rest args)
   "Emit SIGNAL."
   (let ((symbol (intern-soft (symbol-name signal-name)