From 2859ecce9a740ae0b3184c8cb34dd61734039e39 Mon Sep 17 00:00:00 2001 From: ueno Date: Fri, 2 Jan 2004 23:43:48 +0000 Subject: [PATCH] * riece-lsdb.el: New add-on. * COMPILE (riece-modules): Add riece-lsdb. * Makefile.am (EXTRA_DIST): Add riece-lsdb.el * riece-xface.el: New add-on. * COMPILE (riece-modules): Add riece-xface. * Makefile.am (EXTRA_DIST): Add riece-xface.el --- lisp/COMPILE | 4 ++- lisp/ChangeLog | 10 ++++++ lisp/Makefile.am | 2 +- lisp/riece-lsdb.el | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ lisp/riece-xface.el | 69 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 lisp/riece-lsdb.el create mode 100644 lisp/riece-xface.el diff --git a/lisp/COMPILE b/lisp/COMPILE index fa6d087..f9abd24 100644 --- a/lisp/COMPILE +++ b/lisp/COMPILE @@ -57,7 +57,9 @@ riece-keyword riece-menu riece-icon - riece-async)))) + riece-async + riece-lsdb + riece-xface)))) (defun riece-compile-modules (modules) (let ((load-path (cons nil load-path))) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a59e10e..96a1751 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2004-01-02 Daiki Ueno + + * riece-lsdb.el: New add-on. + * COMPILE (riece-modules): Add riece-lsdb. + * Makefile.am (EXTRA_DIST): Add riece-lsdb.el + + * riece-xface.el: New add-on. + * COMPILE (riece-modules): Add riece-xface. + * Makefile.am (EXTRA_DIST): Add riece-xface.el + 2003-12-25 Daiki Ueno * Riece: Version 0.1.7 released. diff --git a/lisp/Makefile.am b/lisp/Makefile.am index f9367f4..b0ced27 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -10,7 +10,7 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \ riece-ndcc.el riece-rdcc.el riece-log.el riece-mini.el \ riece-doctor.el riece-alias.el riece-layout.el riece-skk-kakutei.el \ riece-guess.el riece-history.el riece-button.el riece-keyword.el \ - riece-menu.el riece-icon.el riece-async.el + riece-menu.el riece-icon.el riece-async.el riece-lsdb.el riece-xface.el CLEANFILES = auto-autoloads.el custom-load.el *.elc FLAGS ?= -batch -q -no-site-file diff --git a/lisp/riece-lsdb.el b/lisp/riece-lsdb.el new file mode 100644 index 0000000..3c739c9 --- /dev/null +++ b/lisp/riece-lsdb.el @@ -0,0 +1,86 @@ +;;; riece-lsdb.el --- interface to LSDB +;; Copyright (C) 1998-2003 Daiki Ueno + +;; Author: Daiki Ueno +;; Created: 1998-09-28 +;; Keywords: IRC, riece + +;; This file is part of Riece. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; To use, add the following line to your ~/.riece/init.el: +;; (add-to-list 'riece-addons 'riece-lsdb) + +;;; Code: + +(autoload 'lsdb-maybe-load-hash-tables "lsdb") + +(eval-when-compile + (autoload 'lsdb-lookup-records "lsdb") + (autoload 'lsdb-puthash "lsdb") + (autoload 'lsdb-remhash "lsdb") + (autoload 'lsdb-gethash "lsdb") + (autoload 'lsdb-display-records "lsdb")) + +(defvar riece-lsdb-cache nil) + +(defun riece-lsdb-update-cache (record) + (let ((irc (cdr (assq 'irc record)))) + (while irc + (lsdb-puthash (car irc) (car record) riece-lsdb-cache) + (setq irc (cdr irc))))) + +(defun riece-lsdb-delete-cache (record) + (let ((irc (cdr (assq 'irc record)))) + (while irc + (lsdb-remhash (car irc) riece-lsdb-cache) + (setq irc (cdr irc))))) + +(defun riece-lsdb-lookup-records (user) + (lsdb-maybe-load-hash-tables) + (let ((name (lsdb-gethash (riece-format-identity user t) + riece-lsdb-cache))) + (if name + (lsdb-lookup-records name)))) + +(defun riece-lsdb-display-records (user) + (interactive + (let ((completion-ignore-case t)) + (list (riece-completing-read-identity + "User: " + (riece-get-users-on-server (riece-current-server-name)))))) + (let ((records (riece-lsdb-lookup-records user))) + (if records + (lsdb-display-records records) + (message "No entry for `%s'" (riece-format-identity user t))))) + +(defun riece-lsdb-insinuate () + (require 'lsdb) + (add-to-list 'lsdb-secondary-hash-tables + 'riece-lsdb-cache) + (add-to-list 'lsdb-after-update-record-functions + 'riece-lsdb-update-cache) + (add-to-list 'lsdb-after-delete-record-functions + 'riece-lsdb-delete-cache) + (define-key riece-command-mode-map + "\C-cL" 'riece-lsdb-display-records)) + +(provide 'riece-lsdb) + +;;; riece-lsdb.el ends here diff --git a/lisp/riece-xface.el b/lisp/riece-xface.el new file mode 100644 index 0000000..80d8cea --- /dev/null +++ b/lisp/riece-xface.el @@ -0,0 +1,69 @@ +;;; riece-xface.el --- display X-Face on user list buffer +;; Copyright (C) 1998-2003 Daiki Ueno + +;; Author: Daiki Ueno +;; Created: 1998-09-28 +;; Keywords: IRC, riece + +;; This file is part of Riece. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; To use, add the following line to your ~/.riece/init.el: +;; (add-to-list 'riece-addons 'riece-xface) + +;;; Code: + +(require 'riece-identity) +(require 'riece-globals) +(require 'riece-display) +(require 'riece-lsdb) + +(defvar lsdb-insert-x-face-function) + +(defun riece-xface-update-user-list-buffer () + (save-excursion + (set-buffer riece-user-list-buffer) + (riece-scan-property-region + 'riece-identity (point-min)(point-max) + (lambda (start end) + (let ((records (riece-lsdb-lookup-records (get-text-property + start 'riece-identity))) + xface) + (while (and records + (null xface)) + (setq xface (nth 1 (assq 'x-face (car records))) + records (cdr records))) + (if (and xface + (not (eq (char-after end) ? ))) + (let ((inhibit-read-only t) + buffer-read-only) + (goto-char end) + (insert " ") + (funcall lsdb-insert-x-face-function xface)))))))) + +(defun riece-xface-requires () + '(riece-lsdb)) + +(defun riece-xface-insinuate () + (add-hook 'riece-update-buffer-functions + 'riece-xface-update-user-list-buffer t)) + +(provide 'riece-xface) + +;;; riece-xface.el ends here -- 1.7.10.4