X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-xface.el;h=1ec50665633b23fabc0b2805d79915f4b50a80b1;hp=dbb8a278e808574d0a9d415f0be0a6190eac26ef;hb=9a40faf27d1ddc378072d9a78dae747f44fc757a;hpb=a90da5167ee52cbf7b1320a4c6a4465b8b10075d diff --git a/lisp/riece-xface.el b/lisp/riece-xface.el index dbb8a27..1ec5066 100644 --- a/lisp/riece-xface.el +++ b/lisp/riece-xface.el @@ -34,36 +34,51 @@ (require 'riece-display) (require 'riece-lsdb) +(defvar riece-xface-enabled nil) + +(defconst riece-xface-description + "Display X-Face in user list buffer") + (defvar lsdb-insert-x-face-function) (defun riece-xface-update-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 riece-xface-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 () - (add-hook 'riece-startup-hook + (add-hook 'riece-user-list-mode-hook (lambda () - (with-current-buffer riece-user-list-buffer - (add-hook 'riece-update-buffer-functions - 'riece-xface-update-user-list-buffer t))))) + (add-hook 'riece-update-buffer-functions + 'riece-xface-update-user-list-buffer t t)))) + +(defun riece-xface-enable () + (setq riece-xface-enabled t) + (if riece-current-channel + (riece-emit-signal 'user-list-changed riece-current-channel))) + +(defun riece-xface-disable () + (setq riece-xface-enabled nil) + (if riece-current-channel + (riece-emit-signal 'user-list-changed riece-current-channel))) (provide 'riece-xface)