1 ;;; riece-lsdb.el --- interface to LSDB
2 ;; Copyright (C) 1998-2003 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: IRC, riece
8 ;; This file is part of Riece.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; To use, add the following line to your ~/.riece/init.el:
28 ;; (add-to-list 'riece-addons 'riece-lsdb)
33 (autoload 'lsdb-maybe-load-hash-tables "lsdb")
34 (autoload 'lsdb-lookup-records "lsdb")
35 (autoload 'lsdb-puthash "lsdb")
36 (autoload 'lsdb-remhash "lsdb")
37 (autoload 'lsdb-gethash "lsdb")
38 (autoload 'lsdb-display-records "lsdb"))
40 (defvar riece-lsdb-cache nil)
42 (defun riece-lsdb-update-cache (record)
43 (let ((irc (cdr (assq 'irc record))))
45 (lsdb-puthash (car irc) (car record) riece-lsdb-cache)
46 (setq irc (cdr irc)))))
48 (defun riece-lsdb-delete-cache (record)
49 (let ((irc (cdr (assq 'irc record))))
51 (lsdb-remhash (car irc) riece-lsdb-cache)
52 (setq irc (cdr irc)))))
54 (defun riece-lsdb-lookup-records (user)
55 (lsdb-maybe-load-hash-tables)
56 (let ((name (lsdb-gethash (riece-format-identity user t)
59 (lsdb-lookup-records name))))
61 (defun riece-lsdb-display-records (user)
63 (let ((completion-ignore-case t))
64 (list (riece-completing-read-identity
66 (riece-get-users-on-server (riece-current-server-name))))))
67 (let ((records (riece-lsdb-lookup-records user)))
69 (lsdb-display-records records)
70 (message "No entry for `%s'" (riece-format-identity user t)))))
72 (defun riece-lsdb-insinuate ()
74 (add-to-list 'lsdb-secondary-hash-tables
76 (add-to-list 'lsdb-after-update-record-functions
77 'riece-lsdb-update-cache)
78 (add-to-list 'lsdb-after-delete-record-functions
79 'riece-lsdb-delete-cache)
80 (define-key riece-command-mode-map
81 "\C-cL" 'riece-lsdb-display-records))
85 ;;; riece-lsdb.el ends here