--- /proc/self/fd/11 2012-01-24 20:14:43.208972689 +0100 +++ erc.el 2012-01-24 20:09:40.485514822 +0100 @@ -256,10 +256,23 @@ (defcustom erc-hide-list nil "*List of IRC type messages to hide. +Behaves according to `erc-hide-method'. A typical value would be '(\"JOIN\" \"PART\" \"QUIT\")." :group 'erc-ignore :type 'erc-message-type) +(defcustom erc-hide-method 'discard + "Either discard messages in `erc-hide-list' or make them invisible. + +The value discard results in complete dismissal of the message. +invisible means the messages are inserted into the erc-buffer but +hidden in `erc-hide-mode'. + +NOTE: Invisible messages are logged if `erc-log-mode' is active!" + :group 'erc-ignore + :type '(choice (const :tag "discard" discard) + (const :tag "make invisible" invisible))) + (defvar erc-session-password nil "The password used for the current session.") (make-variable-buffer-local 'erc-session-password) @@ -2469,11 +2482,37 @@ (if (not (erc-response-p parsed)) (erc-display-line string buffer) - (unless (member (erc-response.command parsed) erc-hide-list) + (when (or (not (member (erc-response.command parsed) erc-hide-list)) + (and (eq erc-hide-method 'invisible) + (progn + (unless (string-match "\n$" string) + (setq string (concat string "\n"))) + (erc-put-text-property + 0 (length string) 'invisible 'erc-hide string) + t))) (erc-put-text-property 0 (length string) 'erc-parsed parsed string) (erc-put-text-property 0 (length string) 'rear-sticky t string) (erc-display-line string buffer))))) +(define-minor-mode erc-hide-mode + "Make IRC messages matching `erc-hide-list' invisible. + +This mode only has an effect if `erc-hide-method' is set invisible." + :group 'erc-ignore + (if erc-hide-mode + (add-to-invisibility-spec 'erc-hide) + (remove-from-invisibility-spec 'erc-hide))) + +(defun erc-hide-mode-maybe (&optional buffer) + "Turn on `erc-hide-mode' in BUFFER (defaults to `current-buffer')." + (with-current-buffer (or buffer (current-buffer)) + (when (derived-mode-p 'erc-mode) + (erc-hide-mode)))) + +(define-globalized-minor-mode global-erc-hide-mode + erc-hide-mode erc-hide-mode-maybe + :group 'erc-ignore) + (defun erc-message-type-member (position list) "Return non-nil if the erc-parsed text-property at POSITION is in LIST.