emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master fdad335: * lisp/erc/erc.el: Hide network/channel me


From: Kelvin White
Subject: [Emacs-diffs] master fdad335: * lisp/erc/erc.el: Hide network/channel messages
Date: Thu, 21 May 2015 19:39:35 +0000

branch: master
commit fdad335016c5e830f90bb8da3ed4f1365273a524
Author: kwhite <address@hidden>
Commit: kwhite <address@hidden>

    * 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
---
 doc/misc/erc.texi |   20 ++++++++++++++++++++
 etc/NEWS          |    7 +++++++
 lisp/erc/erc.el   |   53 ++++++++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi
index 9e570da..56aea0c 100644
--- a/doc/misc/erc.texi
+++ b/doc/misc/erc.texi
@@ -753,6 +753,26 @@ If non, @code{nil}, this is a list of IRC message types to 
hide, e.g.:
 @end example
 @end defopt
 
address@hidden erc-network-hide-list
+If non, @code{nil}, this is a list of IRC networks and message types
+to hide, e.g.:
+
address@hidden
+(setq erc-network-hide-list (("freenode" "JOIN" "PART" "QUIT")
+("OFTC" "JOIN" "PART""))
address@hidden example
address@hidden defopt
+
address@hidden erc-channel-hide-list
+If non, @code{nil}, this is a list of IRC channels and message types
+to hide, e.g.:
+
address@hidden
+(setq erc-channel-hide-list (("#erc" "JOIN" "PART" "QUIT")
+("#emacs" "NICK"))
address@hidden example
address@hidden 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
diff --git a/etc/NEWS b/etc/NEWS
index 2540756..7ad85ba 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index cf422f1..ad5e1a2 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -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 (address@hidden)
 ;; Maintainer: address@hidden
 ;; 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 <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]