diff options
| author | kwhite | 2015-05-21 14:30:18 -0500 |
|---|---|---|
| committer | kwhite | 2015-05-21 14:30:18 -0500 |
| commit | fdad335016c5e830f90bb8da3ed4f1365273a524 (patch) | |
| tree | e58e8cfd62cd689952339e981ae71d1b63c4545b | |
| parent | 96794d2f97cd064e4c2bf4f71459b42558cc8c79 (diff) | |
| download | emacs-fdad335016c5e830f90bb8da3ed4f1365273a524.tar.gz emacs-fdad335016c5e830f90bb8da3ed4f1365273a524.zip | |
* 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
| -rw-r--r-- | doc/misc/erc.texi | 20 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | 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 9e570da3d1d..56aea0c3184 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.: | |||
| 753 | @end example | 753 | @end example |
| 754 | @end defopt | 754 | @end defopt |
| 755 | 755 | ||
| 756 | @defopt erc-network-hide-list | ||
| 757 | If non, @code{nil}, this is a list of IRC networks and message types | ||
| 758 | to hide, e.g.: | ||
| 759 | |||
| 760 | @example | ||
| 761 | (setq erc-network-hide-list (("freenode" "JOIN" "PART" "QUIT") | ||
| 762 | ("OFTC" "JOIN" "PART"")) | ||
| 763 | @end example | ||
| 764 | @end defopt | ||
| 765 | |||
| 766 | @defopt erc-channel-hide-list | ||
| 767 | If non, @code{nil}, this is a list of IRC channels and message types | ||
| 768 | to hide, e.g.: | ||
| 769 | |||
| 770 | @example | ||
| 771 | (setq erc-channel-hide-list (("#erc" "JOIN" "PART" "QUIT") | ||
| 772 | ("#emacs" "NICK")) | ||
| 773 | @end example | ||
| 774 | @end defopt | ||
| 775 | |||
| 756 | @defopt erc-lurker-hide-list | 776 | @defopt erc-lurker-hide-list |
| 757 | Like @code{erc-hide-list}, but only applies to messages sent by | 777 | Like @code{erc-hide-list}, but only applies to messages sent by |
| 758 | lurkers. The function @code{erc-lurker-p} determines whether a given | 778 | lurkers. The function @code{erc-lurker-p} determines whether a given |
| @@ -249,6 +249,13 @@ Unicode standards. | |||
| 249 | 249 | ||
| 250 | ** The `save-place' variable is replaced by a `save-place-mode'. | 250 | ** The `save-place' variable is replaced by a `save-place-mode'. |
| 251 | 251 | ||
| 252 | ** ERC | ||
| 253 | |||
| 254 | *** Hide message types by network or channel. `erc-hide-list' will | ||
| 255 | hide all messages of the specified type, where `erc-network-hide-list' | ||
| 256 | and `erc-channel-hide-list' will only hide the specified message types | ||
| 257 | for the respective specified targets. | ||
| 258 | |||
| 252 | ** Midnight-mode | 259 | ** Midnight-mode |
| 253 | *** `midnight-mode' is a proper minor mode. | 260 | *** `midnight-mode' is a proper minor mode. |
| 254 | *** clean-buffer-*-regexps can now specify buffers via predicate functions. | 261 | *** clean-buffer-*-regexps can now specify buffers via predicate functions. |
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index cf422f1cfc5..ad5e1a2468e 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | |||
| 1 | ;; erc.el --- An Emacs Internet Relay Chat client -*- lexical-binding:t -*- | 2 | ;; erc.el --- An Emacs Internet Relay Chat client -*- lexical-binding:t -*- |
| 2 | 3 | ||
| 3 | ;; Copyright (C) 1997-2015 Free Software Foundation, Inc. | 4 | ;; Copyright (C) 1997-2015 Free Software Foundation, Inc. |
| @@ -12,6 +13,7 @@ | |||
| 12 | ;; Kelvin White (kwhite@gnu.org) | 13 | ;; Kelvin White (kwhite@gnu.org) |
| 13 | ;; Maintainer: emacs-devel@gnu.org | 14 | ;; Maintainer: emacs-devel@gnu.org |
| 14 | ;; Keywords: IRC, chat, client, Internet | 15 | ;; Keywords: IRC, chat, client, Internet |
| 16 | |||
| 15 | ;; Version: 5.3 | 17 | ;; Version: 5.3 |
| 16 | 18 | ||
| 17 | ;; This file is part of GNU Emacs. | 19 | ;; This file is part of GNU Emacs. |
| @@ -37,15 +39,13 @@ | |||
| 37 | ;; * http://sv.gnu.org/projects/erc/ | 39 | ;; * http://sv.gnu.org/projects/erc/ |
| 38 | ;; * http://www.emacswiki.org/cgi-bin/wiki/ERC | 40 | ;; * http://www.emacswiki.org/cgi-bin/wiki/ERC |
| 39 | 41 | ||
| 42 | |||
| 43 | |||
| 40 | ;; As of 2006-06-13, ERC development is now hosted on Savannah | 44 | ;; As of 2006-06-13, ERC development is now hosted on Savannah |
| 41 | ;; (http://sv.gnu.org/projects/erc). I invite everyone who wants to | 45 | ;; (http://sv.gnu.org/projects/erc). I invite everyone who wants to |
| 42 | ;; hack on it to contact me <mwolson@gnu.org> in order to get write | 46 | ;; hack on it to contact me <mwolson@gnu.org> in order to get write |
| 43 | ;; access to the shared Arch archive. | 47 | ;; access to the shared Arch archive. |
| 44 | 48 | ||
| 45 | ;; Installation: | ||
| 46 | |||
| 47 | ;; Put erc.el in your load-path, and put (require 'erc) in your .emacs. | ||
| 48 | |||
| 49 | ;; Configuration: | 49 | ;; Configuration: |
| 50 | 50 | ||
| 51 | ;; Use M-x customize-group RET erc RET to get an overview | 51 | ;; Use M-x customize-group RET erc RET to get an overview |
| @@ -258,11 +258,25 @@ If nil, only \"> \" will be shown." | |||
| 258 | (repeat :inline t :tag "Others" (string :tag "IRC Message Type")))) | 258 | (repeat :inline t :tag "Others" (string :tag "IRC Message Type")))) |
| 259 | 259 | ||
| 260 | (defcustom erc-hide-list nil | 260 | (defcustom erc-hide-list nil |
| 261 | "List of IRC type messages to hide. | 261 | "A global list of IRC message types to hide. |
| 262 | A typical value would be '(\"JOIN\" \"PART\" \"QUIT\")." | 262 | A typical value would be '(\"JOIN\" \"PART\" \"QUIT\")." |
| 263 | :group 'erc-ignore | 263 | :group 'erc-ignore |
| 264 | :type 'erc-message-type) | 264 | :type 'erc-message-type) |
| 265 | 265 | ||
| 266 | (defcustom erc-network-hide-list nil | ||
| 267 | "A list of IRC networks to hide message types from. | ||
| 268 | A typical value would be '((\"freenode\" \"MODE\") | ||
| 269 | (\"OFTC\" \"JOIN\" \"QUIT\"))." | ||
| 270 | :group 'erc-ignore | ||
| 271 | :type 'erc-message-type) | ||
| 272 | |||
| 273 | (defcustom erc-channel-hide-list nil | ||
| 274 | "A list of IRC channels to hide message types from. | ||
| 275 | A typical value would be '((\"#emacs\" \"QUIT\" \JOIN\") | ||
| 276 | (\"#erc\" \"NICK\")." | ||
| 277 | :group 'erc-ignore | ||
| 278 | :type 'erc-message-type) | ||
| 279 | |||
| 266 | (defvar erc-session-password nil | 280 | (defvar erc-session-password nil |
| 267 | "The password used for the current session.") | 281 | "The password used for the current session.") |
| 268 | (make-variable-buffer-local 'erc-session-password) | 282 | (make-variable-buffer-local 'erc-session-password) |
| @@ -2616,15 +2630,36 @@ otherwise `erc-server-announced-name'. SERVER is matched against | |||
| 2616 | erc-common-server-suffixes)) | 2630 | erc-common-server-suffixes)) |
| 2617 | erc-server-announced-name))) | 2631 | erc-server-announced-name))) |
| 2618 | 2632 | ||
| 2633 | (defun erc-add-targets (scope target-list) | ||
| 2634 | (let ((targets | ||
| 2635 | (mapcar (lambda (targets) (member scope targets)) target-list))) | ||
| 2636 | (cdr (apply 'append (delete nil targets))))) | ||
| 2637 | |||
| 2619 | (defun erc-hide-current-message-p (parsed) | 2638 | (defun erc-hide-current-message-p (parsed) |
| 2620 | "Predicate indicating whether the parsed ERC response PARSED should be hidden. | 2639 | "Predicate indicating whether the parsed ERC response PARSED should be hidden. |
| 2621 | 2640 | ||
| 2622 | Messages are always hidden if the message type of PARSED appears in | 2641 | Messages are always hidden if the message type of PARSED appears in |
| 2623 | `erc-hide-list'. In addition, messages whose type is a member of | 2642 | `erc-hide-list'. Message types that appear in `erc-network-hide-list' |
| 2624 | `erc-lurker-hide-list' are hidden if `erc-lurker-p' returns true." | 2643 | or `erc-channel-hide-list' are are only hidden if the target matches |
| 2644 | the network or channel in the list. In addition, messages whose type | ||
| 2645 | is a member of `erc-lurker-hide-list' are hidden if `erc-lurker-p' | ||
| 2646 | returns non-nil." | ||
| 2625 | (let* ((command (erc-response.command parsed)) | 2647 | (let* ((command (erc-response.command parsed)) |
| 2626 | (sender (car (erc-parse-user (erc-response.sender parsed))))) | 2648 | (sender (car (erc-parse-user (erc-response.sender parsed)))) |
| 2649 | (channel (nth 1 (erc-response.command-args parsed))) | ||
| 2650 | (network (or (and (fboundp 'erc-network-name) (erc-network-name)) | ||
| 2651 | (erc-shorten-server-name | ||
| 2652 | (or erc-server-announced-name | ||
| 2653 | erc-session-server)))) | ||
| 2654 | (current-hide-list | ||
| 2655 | (when erc-network-hide-list | ||
| 2656 | (erc-add-targets network erc-network-hide-list))) | ||
| 2657 | (current-hide-list | ||
| 2658 | (apply 'append current-hide-list | ||
| 2659 | (when erc-channel-hide-list | ||
| 2660 | (erc-add-targets channel erc-channel-hide-list))))) | ||
| 2627 | (or (member command erc-hide-list) | 2661 | (or (member command erc-hide-list) |
| 2662 | (member command current-hide-list) | ||
| 2628 | (and (member command erc-lurker-hide-list) (erc-lurker-p sender))))) | 2663 | (and (member command erc-lurker-hide-list) (erc-lurker-p sender))))) |
| 2629 | 2664 | ||
| 2630 | (defun erc-display-message (parsed type buffer msg &rest args) | 2665 | (defun erc-display-message (parsed type buffer msg &rest args) |
| @@ -4150,7 +4185,7 @@ See also `erc-display-error-notice'." | |||
| 4150 | ;; server's setting if we haven't | 4185 | ;; server's setting if we haven't |
| 4151 | ;; established a connection yet | 4186 | ;; established a connection yet |
| 4152 | (- 9 (length erc-nick-uniquifier)))) | 4187 | (- 9 (length erc-nick-uniquifier)))) |
| 4153 | erc-nick-uniquifier))) | 4188 | erc-nick-uniqifier))) |
| 4154 | (erc-cmd-NICK newnick) | 4189 | (erc-cmd-NICK newnick) |
| 4155 | (erc-display-error-notice | 4190 | (erc-display-error-notice |
| 4156 | nil | 4191 | nil |