1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-27 10:54:40 +00:00

* lisp/erc/erc.el: Hide network/channel messages

(erc-network-hide-list, etc-channel-hide-list): New lists to define
message types per network/channel.
(erc-add-targets): New function to parse list of targets
(erc-hide-current-message-p): Modified to check for new targets
This commit is contained in:
kwhite 2015-05-21 14:30:18 -05:00
parent 96794d2f97
commit fdad335016
3 changed files with 71 additions and 9 deletions

View File

@ -753,6 +753,26 @@ If non, @code{nil}, this is a list of IRC message types to hide, e.g.:
@end example
@end defopt
@defopt erc-network-hide-list
If non, @code{nil}, this is a list of IRC networks and message types
to hide, e.g.:
@example
(setq erc-network-hide-list (("freenode" "JOIN" "PART" "QUIT")
("OFTC" "JOIN" "PART""))
@end example
@end defopt
@defopt erc-channel-hide-list
If non, @code{nil}, this is a list of IRC channels and message types
to hide, e.g.:
@example
(setq erc-channel-hide-list (("#erc" "JOIN" "PART" "QUIT")
("#emacs" "NICK"))
@end example
@end defopt
@defopt erc-lurker-hide-list
Like @code{erc-hide-list}, but only applies to messages sent by
lurkers. The function @code{erc-lurker-p} determines whether a given

View File

@ -249,6 +249,13 @@ Unicode standards.
** The `save-place' variable is replaced by a `save-place-mode'.
** ERC
*** Hide message types by network or channel. `erc-hide-list' will
hide all messages of the specified type, where `erc-network-hide-list'
and `erc-channel-hide-list' will only hide the specified message types
for the respective specified targets.
** Midnight-mode
*** `midnight-mode' is a proper minor mode.
*** clean-buffer-*-regexps can now specify buffers via predicate functions.

View File

@ -1,3 +1,4 @@
;; erc.el --- An Emacs Internet Relay Chat client -*- lexical-binding:t -*-
;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
@ -12,6 +13,7 @@
;; Kelvin White (kwhite@gnu.org)
;; Maintainer: emacs-devel@gnu.org
;; Keywords: IRC, chat, client, Internet
;; Version: 5.3
;; This file is part of GNU Emacs.
@ -37,15 +39,13 @@
;; * http://sv.gnu.org/projects/erc/
;; * http://www.emacswiki.org/cgi-bin/wiki/ERC
;; As of 2006-06-13, ERC development is now hosted on Savannah
;; (http://sv.gnu.org/projects/erc). I invite everyone who wants to
;; hack on it to contact me <mwolson@gnu.org> in order to get write
;; access to the shared Arch archive.
;; Installation:
;; Put erc.el in your load-path, and put (require 'erc) in your .emacs.
;; Configuration:
;; Use M-x customize-group RET erc RET to get an overview
@ -258,11 +258,25 @@ If nil, only \"> \" will be shown."
(repeat :inline t :tag "Others" (string :tag "IRC Message Type"))))
(defcustom erc-hide-list nil
"List of IRC type messages to hide.
"A global list of IRC message types to hide.
A typical value would be '(\"JOIN\" \"PART\" \"QUIT\")."
:group 'erc-ignore
:type 'erc-message-type)
(defcustom erc-network-hide-list nil
"A list of IRC networks to hide message types from.
A typical value would be '((\"freenode\" \"MODE\")
(\"OFTC\" \"JOIN\" \"QUIT\"))."
:group 'erc-ignore
:type 'erc-message-type)
(defcustom erc-channel-hide-list nil
"A list of IRC channels to hide message types from.
A typical value would be '((\"#emacs\" \"QUIT\" \JOIN\")
(\"#erc\" \"NICK\")."
:group 'erc-ignore
:type 'erc-message-type)
(defvar erc-session-password nil
"The password used for the current session.")
(make-variable-buffer-local 'erc-session-password)
@ -2616,15 +2630,36 @@ otherwise `erc-server-announced-name'. SERVER is matched against
erc-common-server-suffixes))
erc-server-announced-name)))
(defun erc-add-targets (scope target-list)
(let ((targets
(mapcar (lambda (targets) (member scope targets)) target-list)))
(cdr (apply 'append (delete nil targets)))))
(defun erc-hide-current-message-p (parsed)
"Predicate indicating whether the parsed ERC response PARSED should be hidden.
Messages are always hidden if the message type of PARSED appears in
`erc-hide-list'. In addition, messages whose type is a member of
`erc-lurker-hide-list' are hidden if `erc-lurker-p' returns true."
`erc-hide-list'. Message types that appear in `erc-network-hide-list'
or `erc-channel-hide-list' are are only hidden if the target matches
the network or channel in the list. In addition, messages whose type
is a member of `erc-lurker-hide-list' are hidden if `erc-lurker-p'
returns non-nil."
(let* ((command (erc-response.command parsed))
(sender (car (erc-parse-user (erc-response.sender parsed)))))
(sender (car (erc-parse-user (erc-response.sender parsed))))
(channel (nth 1 (erc-response.command-args parsed)))
(network (or (and (fboundp 'erc-network-name) (erc-network-name))
(erc-shorten-server-name
(or erc-server-announced-name
erc-session-server))))
(current-hide-list
(when erc-network-hide-list
(erc-add-targets network erc-network-hide-list)))
(current-hide-list
(apply 'append current-hide-list
(when erc-channel-hide-list
(erc-add-targets channel erc-channel-hide-list)))))
(or (member command erc-hide-list)
(member command current-hide-list)
(and (member command erc-lurker-hide-list) (erc-lurker-p sender)))))
(defun erc-display-message (parsed type buffer msg &rest args)
@ -4150,7 +4185,7 @@ See also `erc-display-error-notice'."
;; server's setting if we haven't
;; established a connection yet
(- 9 (length erc-nick-uniquifier))))
erc-nick-uniquifier)))
erc-nick-uniqifier)))
(erc-cmd-NICK newnick)
(erc-display-error-notice
nil