X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Friece-xface.el;h=d43cf5ecf2cc2083a3216272d3131cccee39a6a8;hb=b0b80d7382338f859999eedd490d51bfab6f04c8;hp=80d8cea50e0a80f49aa6a3618085f296748eeb44;hpb=1b797a0f2b4e4cc447062c297cd83322872e7dfa;p=riece diff --git a/lisp/riece-xface.el b/lisp/riece-xface.el index 80d8cea..d43cf5e 100644 --- a/lisp/riece-xface.el +++ b/lisp/riece-xface.el @@ -1,4 +1,4 @@ -;;; riece-xface.el --- display X-Face on user list buffer +;;; riece-xface.el --- display X-Face in IRC buffers ;; Copyright (C) 1998-2003 Daiki Ueno ;; Author: Daiki Ueno @@ -19,13 +19,12 @@ ;; 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. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: -;; To use, add the following line to your ~/.riece/init.el: -;; (add-to-list 'riece-addons 'riece-xface) +;; NOTE: This is an add-on module for Riece. ;;; Code: @@ -34,35 +33,60 @@ (require 'riece-display) (require 'riece-lsdb) +(defconst riece-xface-description + "Display X-Face in IRC buffers.") + (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)))))))) + (if (get 'riece-xface 'riece-addon-enabled) + (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 () +(defun riece-xface-user-list-mode-hook () (add-hook 'riece-update-buffer-functions - 'riece-xface-update-user-list-buffer t)) + 'riece-xface-update-user-list-buffer t t)) + +(defun riece-xface-insinuate () + (if riece-user-list-buffer + (with-current-buffer riece-user-list-buffer + (riece-xface-user-list-mode-hook))) + (add-hook 'riece-user-list-mode-hook + 'riece-xface-user-list-mode-hook)) + +(defun riece-xface-uninstall () + (if riece-user-list-buffer + (with-current-buffer riece-user-list-buffer + (remove-hook 'riece-update-buffer-functions + 'riece-xface-update-user-list-buffer t))) + (remove-hook 'riece-user-list-mode-hook + 'riece-xface-user-list-mode-hook)) + +(defun riece-xface-enable () + (if riece-current-channel + (riece-emit-signal 'user-list-changed riece-current-channel))) + +(defun riece-xface-disable () + (if riece-current-channel + (riece-emit-signal 'user-list-changed riece-current-channel))) (provide 'riece-xface)