From 734fcedd7c3560801e76bfbd8c321dc218d8fa27 Mon Sep 17 00:00:00 2001 From: ueno Date: Tue, 18 May 2004 03:46:17 +0000 Subject: [PATCH] * 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. --- lisp/ChangeLog | 9 +++++++ lisp/riece-ignore.el | 64 ++++++++++++++++++++++++++++++++++++++------------ lisp/riece-signal.el | 13 +++++++++- 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1293002..d86b58a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,14 @@ 2004-05-18 Daiki Ueno + * 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 + * riece-url.el (riece-url-regexp): Accept ";". * riece-ignore.el: New add-on. diff --git a/lisp/riece-ignore.el b/lisp/riece-ignore.el index c8a6383..32c36bb 100644 --- a/lisp/riece-ignore.el +++ b/lisp/riece-ignore.el @@ -33,26 +33,60 @@ (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) diff --git a/lisp/riece-signal.el b/lisp/riece-signal.el index cc0d310..c239a02 100644 --- a/lisp/riece-signal.el +++ b/lisp/riece-signal.el @@ -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) -- 1.7.10.4