1 ;;; riece-alias.el --- define aliases of names
2 ;; Copyright (C) 1998-2003 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Keywords: IRC, riece
7 ;; This file is part of Riece.
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
26 (defgroup riece-alias nil
27 "Define aliases of names"
31 (defcustom riece-alias-percent-hack-mask "*.jp"
32 "The mask of local IRC network"
36 (defcustom riece-alias-enable-percent-hack t
37 "If non-nil, the target mask is abbreviated with `%'."
41 (defcustom riece-alias-alist nil
42 "An alist mapping aliases to names."
46 (defun riece-alias-abbrev-percent-hack (string)
47 (if (string-match (concat "^#\\([^ ]+\\):"
48 (regexp-quote riece-alias-percent-hack-mask)
51 (replace-match "%\\1\\2" nil nil string)
54 (defun riece-alias-expand-percent-hack (string)
55 (if (string-match "^%\\([^ ]+\\)\\( .+\\|$\\)" string)
56 (replace-match (concat "#\\1:" riece-alias-percent-hack-mask "\\2")
60 (defun riece-alias-abbrev-identity-string (string)
61 (if riece-alias-enable-percent-hack
62 (setq string (riece-alias-abbrev-percent-hack string)))
63 (let ((alist riece-alias-alist))
66 (if (equal (car (car alist)) string)
67 (throw 'done (cdr (car alist))))
68 (setq alist (cdr alist)))
71 (defun riece-alias-expand-identity-string (string)
72 (if riece-alias-enable-percent-hack
73 (setq string (riece-alias-expand-percent-hack string)))
74 (let ((alist riece-alias-alist))
77 (if (equal (cdr (car alist)) string)
78 (throw 'done (car (car alist))))
79 (setq alist (cdr alist)))
82 (defun riece-alias-insinuate ()
83 (setq riece-abbrev-identity-string-function
84 #'riece-alias-abbrev-identity-string
85 riece-expand-identity-string-function
86 #'riece-alias-expand-identity-string))
88 (provide 'riece-alias)
90 ;;; riece-alias.el ends here