1 ;; erc-replace.el -- wash and massage messages inserted into the buffer
3 ;; Copyright (C) 2001, 2002, 2004, 2006, 2007,
4 ;; 2008 Free Software Foundation, Inc.
6 ;; Author: Andreas Fuchs <asf@void.at>
7 ;; Maintainer: Mario Lang (mlang@delysid.org)
8 ;; Keywords: IRC, client, Internet
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; This module allows you to systematically replace text in incoming
30 ;; messages. Load erc-replace, and customize `erc-replace-alist'.
31 ;; Then add to your ~/.emacs:
33 ;; (require 'erc-replace)
34 ;; (erc-replace-mode 1)
40 (defgroup erc-replace nil
41 "Replace text from incoming messages"
44 (defcustom erc-replace-alist nil
45 "Alist describing text to be replaced in incoming messages.
46 This is useful for filters.
48 The alist has elements of the form (FROM . TO). FROM can be a regular
49 expression or a variable, or any sexp, TO can be a string or a
50 function to call, or any sexp. If a function, it will be called with
51 one argument, the string to be replaced, and it should return a
54 :type
'(repeat (cons :tag
"Search & Replace"
64 (defun erc-replace-insert ()
65 "Function to run from `erc-insert-modify-hook'.
66 It replaces text according to `erc-replace-alist'."
68 (goto-char (point-min))
69 (let ((from (car elt
))
71 (unless (stringp from
)
72 (setq from
(eval from
)))
73 (while (re-search-forward from nil t
)
76 ((and (symbolp to
) (fboundp to
))
77 (replace-match (funcall to
(match-string 0))))
82 ;;;###autoload (autoload 'erc-replace-mode "erc-replace")
83 (define-erc-module replace nil
84 "This mode replaces incoming text according to `erc-replace-alist'."
85 ((add-hook 'erc-insert-modify-hook
87 ((remove-hook 'erc-insert-modify-hook
88 'erc-replace-insert
)))
90 (provide 'erc-replace
)
92 ;;; erc-replace.el ends here
95 ;; indent-tabs-mode: t
99 ;; arch-tag: dd904a59-d8a6-47f8-ac3a-76b698289a18