86632147a51d4960ab4665daac82b23805390d52
[riece] / lisp / riece-xface.el
1 ;;; riece-xface.el --- display X-Face in user list buffer
2 ;; Copyright (C) 1998-2003 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Created: 1998-09-28
6 ;; Keywords: IRC, riece
7
8 ;; This file is part of Riece.
9
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)
13 ;; any later version.
14
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.
19
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.
24
25 ;;; Commentary:
26
27 ;; To use, add the following line to your ~/.riece/init.el:
28 ;; (add-to-list 'riece-addons 'riece-xface)
29
30 ;;; Code:
31
32 (require 'riece-identity)
33 (require 'riece-globals)
34 (require 'riece-display)
35 (require 'riece-lsdb)
36
37 (defvar lsdb-insert-x-face-function)
38
39 (defun riece-xface-update-user-list-buffer ()
40   (save-excursion
41     (set-buffer riece-user-list-buffer)
42     (riece-scan-property-region
43      'riece-identity (point-min)(point-max)
44      (lambda (start end)
45        (let ((records (riece-lsdb-lookup-records (get-text-property
46                                                   start 'riece-identity)))
47              xface)
48          (while (and records
49                      (null xface))
50            (setq xface (nth 1 (assq 'x-face (car records)))
51                  records (cdr records)))
52          (if (and xface
53                   (not (eq (char-after end) ? )))
54              (let ((inhibit-read-only t)
55                    buffer-read-only)
56                (goto-char end)
57                (insert " ")
58                (funcall lsdb-insert-x-face-function xface))))))))
59
60 (defun riece-xface-requires ()
61   '(riece-lsdb))
62
63 (defun riece-xface-insinuate ()
64   (add-hook 'riece-update-buffer-functions
65             'riece-xface-update-user-list-buffer t))
66
67 (provide 'riece-xface)
68
69 ;;; riece-xface.el ends here