;;; gnus-summary-x-face.el --- Display x-face in gnus summary buffer. ;; Copyright (C) 2001, 2003 ARISAWA Akihiro ;; Author: ARISAWA Akihiro ;; Keywords: news, gnus, x-face, bbdb ;; This file 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 file 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: ;; You can use "%ux" for gnus-summary-line-format. ;; For example, set following line in .gnus. ;; (or (require 'gnus-bbdb nil t) (require 'bbdb-gnus)) ; optional ;; (require 'gnus-summary-x-face) ;; (setq gnus-summary-line-format "%U%R%z%I%(%[%4L:%ux %-20,20n%]%) %s\n") ;; This needs x-face-e21.el and Emacs-21. ;;; Code: ;; uncomment following lines for byte-compile. ;(eval-when-compile ; (require 'x-face-e21) ; (require 'gnus-bbdb nil t) ; (require 'bbdb-gnus nil t)) (defvar gnus-summary-x-face-scale-factor 0.4 "A number of scale factor used to scale down X-face image in *Summary* mode. See also `x-face-image-attributes'.") (defvar gnus-summary-x-face-function (cond ((featurep 'xemacs) nil) ((and (>= emacs-major-version 21) window-system) (when (require 'x-face-e21 nil t) (lambda (x-face) (propertize " " 'display (x-face-create-image x-face :scale-factor gnus-summary-x-face-scale-factor))))) (t nil)) "Functions called for display x-face.") (defvar gnus-summary-x-face-extra-flag (and gnus-summary-x-face-function t) "If Non-nil, got x-face from extra-header.") (defvar gnus-summary-x-face-extract-address-components-function (cond ((fboundp 'gnus-bbdb/extract-address-components) #'gnus-bbdb/extract-address-components) ((fboundp 'bbdb-extract-address-components) #'(lambda (str) (car (bbdb-extract-address-components str)))) (t nil)) "Functions called for extracting address components.") (defvar gnus-summary-x-face-bbdb-flag (and gnus-summary-x-face-function gnus-summary-x-face-extract-address-components-function t) "If Non-nil, got x-face from bbdb. See also `gnus-bbdb/summary-author-in-bbdb'.") (defvar gnus-summary-x-face-summary-known-poster-mark (cond ((boundp 'gnus-bbdb/summary-known-poster-mark) (symbol-value 'gnus-bbdb/summary-known-poster-mark)) ((boundp 'bbdb/gnus-summary-known-poster-mark) (symbol-value 'bbdb/gnus-summary-known-poster-mark)) (nil "+"))) ;; setup (when gnus-summary-x-face-extra-flag (eval-after-load "nnmail" '(add-to-list 'nnmail-extra-headers 'X-Face)) (eval-after-load "gnus-sum" '(add-to-list 'gnus-extra-headers 'X-Face))) ;; user-function (defun gnus-user-format-function-x (header) "Return x-face, contained x-face in the message or the poster's face in the BBDB." (let (x-face record) (or (when gnus-summary-x-face-extra-flag (setq x-face (cdr (assq 'X-Face (mail-header-extra header))))) (when gnus-summary-x-face-bbdb-flag (let* ((from (mail-header-from header)) (data (condition-case () (funcall gnus-summary-x-face-extract-address-components-function from) (error nil))) (name (car data)) (net (cadr data))) (when (and data (setq record (bbdb-search-simple name (if (and net bbdb-canonicalize-net-hook) (bbdb-canonicalize-address net) net)))) (setq x-face (bbdb-record-getprop record 'face)) (when x-face (setq x-face (car (split-string x-face)))))))) (cond (x-face (funcall gnus-summary-x-face-function x-face)) (record (or (bbdb-record-getprop record bbdb-message-marker-field) gnus-summary-x-face-summary-known-poster-mark)) (t " ")))) (provide 'gnus-summary-x-face) ;;; gnus-summary-x-face.el ends here