%define _noVersionedDependencies        1
%define prereq_ge()     %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1 | grep -v "is not")

%define	origver		1.3.6.24
%define	origname	x-face

Name:         %{origname}
Version:      %{origver}
Release:      0vl3
License:      GPL2

URL:          http://www.jpl.org/elips/
Source0:      ftp://ftp.jpl.org/pub/elisp/x-face-%{version}.tar.gz
Source1:      ftp://ftp.jpl.org/pub/elisp/make-gray-x-face.el
Source2:      ftp://ftp.jpl.org/pub/elisp/x-face-e21.el.gz
Source10:     %{origname}-install.sh
Source11:     %{origname}-remove.sh

Group:        Applications/Editors/Emacs
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch
Summary:      X-Face Utilities for XEmacs & Emacs-21,22
Summary(ja):  XEmacs 及び Emacs-21,22 上にて X-Face を表示するライブラリ
#Requires:    xemacs
Requires:     faces faces-xface

# for make-gray-x-face.el
Requires:     netpbm-progs

Obsoletes:    x-face-xemacs

PreReq:       emacsen
%prereq_ge   emacsen-common

Vendor:       Project Vine
Distribution: Vine Linux
Packager:     MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>


%description
X-Face enables to display 48x48 X11 bitmap "Face" in-line
for various MUAs on XEmacs.

After installation, add below lines to your ~/.emacs file:

	(when (and window-system (module-installed-p 'x-face))
	   (autoload 'x-face-xmas-mew-display-x-face "x-face" nil t)
	   (setq wl-highlight-x-face-function
	      'x-face-xmas-mew-display-x-face)
	)
 

%description -l ja
X-Face を使うと、XEmacs 上で動く多くの MUA 上で
48x48 のビットマップ「Face」をインライン表示することができます。

(当パッケージに同梱している)
x-face-e21.el を使うと、emacs21 上で同様なことができます。
(emacs21 では bitmap-mule を使うこともできますが、~/.x-face-cache
をぐずぐずに崩してしまうので、bitmap-mule を使わずに必ず
当パッケージを使ってください)

XEmacs の設定例 ~/.xemacs.el(~/.xemacs/init.el)

	;;; XEmacs + Wanderlust の設定
	(when (and window-system (module-installed-p 'x-face))
	   (autoload 'x-face-xmas-mew-display-x-face "x-face" nil t)
	   (setq wl-highlight-x-face-function
	      'x-face-xmas-mew-display-x-face)
	)

	;;; XEmacs + Mew の設定
	(autoload 'x-face-xmas-mew-display-x-face "x-face")
	(setq mew-use-highlight-x-face-function 'x-face-xmas-mew-display-x-face)

上手く表示できない場合は、付属のドキュメントを参照してみてください。
(%{_defaultdocdir}/%{name}-%{version}/README.ja)

Emacs-21.x の設定例(~/.emacs.el)

	;;; Emacs-21.x + Wanderlust
	(autoload 'x-face-decode-message-header "x-face-e21")
	(setq wl-highlight-x-face-function 'x-face-decode-message-header)

	;;; Emacs-21.x + Mew
        (cond ((featurep 'xemacs)
          ;;
              )
          ((= 21 emacs-major-version)
           (setq mew-use-highlight-x-face t
              mew-use-highlight-x-face-function 'x-face-decode-message-header)
              (define-key mew-summary-mode-map "\C-x4s" 'x-face-save)
              (define-key mew-draft-mode-map "\C-x4i" 'x-face-insert)
              (define-key mew-draft-header-map "\C-x4i" 'x-face-insert)
              (define-key mew-draft-mode-map "\M-t" 'x-face-show)
              (define-key mew-draft-header-map "\M-t" 'x-face-show)
          )
        )

上手く表示できない場合は、ソースを参照してみてください。
(%{_sharedstatedir}/emacs/site-lisp/%{name}/x-face-e21.el)


Version.1.3.6.14 以降では多階調 の X-Face を表示することが可能です。

make-gray-x-face を使用することにより、多階調 X-Face を作成すること
ができます。(xemacs21.4 及び emacs21 のみ)

make-gray-x-face を使用するには、~/.emacs.el(~/.xemacs/init.el)に
以下を追加してください。

(autoload 'convert-image-to-gray-x-face "make-gray-x-face" nil t)

M-x convert-image-to-gray-x-face でもって gif か png の絵を
X-Face にしたものを現在位置に挿入します。
(Depth: は 2 から 8 までの値を指定するのですが、まぁ 3 位で良いのではないでしょうか)
名前(~/.xface)を付けて保存しておけばメール送信時に自動的に添付されます。

また、複数の X-Face を使い分けたい場合は、select-xface を使うと便利です。
(多階調 X-Face を wl で使いたい場合は必ず select-xface を使ってください。
wl に http://lists.airs.net/wl/archive/200203/msg00064.html
が当たってない為)


%prep
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}

%setup -n x-face-%{version}
cp %{SOURCE2} .
gunzip x-face-e21.el.gz


%install
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
[ "${RPM_BUILD_ROOT}" != "/" ] && mkdir -p ${RPM_BUILD_ROOT}

mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{origname}
mkdir -p ${RPM_BUILD_ROOT}/%{_libdir}/emacsen-common/packages/install
mkdir -p ${RPM_BUILD_ROOT}/%{_libdir}/emacsen-common/packages/remove

cp -a Makefile *.el* *.xpm *.xbm %{SOURCE1} \
	${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{origname}

%_installemacsenscript %{origname} %{SOURCE10}

%_removeemacsenscript  %{origname} %{SOURCE11}


%post

## bytecompile el and install elc

if [ "$1" = 2 ] ; then

%_emacsenPackageRemove %{origname}

fi

%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}


%preun

if [ "$1" = 0 ] ; then

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

fi


%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}


%files
%defattr(-,root,root)
%doc ChangeLog.ja METHOD.ja README-Anim.ja README-Makefile.ja README.ja TODO.ja
%doc x-face-beta-logo.xbm x-face-beta-logo.xpm x-face-logo.xbm x-face-logo.xpm
%{_datadir}/emacs/site-lisp/%{origname}
%{_libdir}/emacsen-common/packages/install/%{origname}
%{_libdir}/emacsen-common/packages/remove/%{origname}


%changelog
* Mon Jun 18 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.24-0vl3
- update x-face-e21(Revised:2007/03/06)
- Modded x-face-install.sh, x-face-remove.sh(for emacs-22)

* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.3.6.24-0vl2
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Fri Jul  9 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.24-0vl1
- update
- update x-face-e21(Revised:2004/05/10)

* Mon Jun 30 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.23-0vl1
- update

* Wed May 21 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.20-0vl5
- update x-face-e21(Revised:2003/03/24)
- Copyright -> License

* Sat May 11 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.20-0vl4
- add Requires: netpbm-progs(for make-gray-x-face.elc)

* Sat May  4 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.20-0vl3
- mv x-face-xemacs x-face
- Modified %description

* Thu Mar 28 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.20-0vl2
- Add x-face-e21.el.gz for Emacs-21.1
- Byte Compiled make-gray-x-face.el for Emacs-21.1

* Mon Mar 18 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.20-0vl1
- update to 1.3.6.20
- included make-gray-x-face.el

* Mon Feb 25 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.19-0vl1
- update to 1.3.6.19
- Delete %Patch0(from Elips X-Mail-Count: 0004572)

* Thu Feb 21 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.16-0vl2
- Add %Patch0(from Elips X-Mail-Count: 0004572)

* Wed Feb 20 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.16-0vl1
- update to 1.3.6.16
- Delete Requires: netpbm 

* Thu Feb 15 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.15-0vl1
- update to 1.3.6.15
- add Requires: netpbm

* Sat Jan 26 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.13-0vl3
- Commentout(Requires: xemacs) because name changed xemacs21.1,xemacs21.4

* Sat Jan 12 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.13-0vl2
- x-face-xemacs-install.sh fix(VERSION=)

* Sun Dec 23 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6.13-0vl1
- updated to 1.3.6.13

* Sat Dec 15 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.3.6.12-0vl1
- updated to 1.3.6.12 release
- now emacsen-common aware

* Sat Jan 08 2000 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.6.9-1
- updated in sync with 1.3.6.9 release

* Tue Dec 21 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.6.8-1
- updated in sync with 1.3.6.8 release

* Sat Dec 18 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.6.7-1
- updated in sync with 1.3.6.7 release

* Thu Nov 18 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.6.6-1
- updated in sync with 1.3.6.6 release
- change Group to Applications/Editors/EmacsLisp

* Thu Nov 18 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.6.4-1
- updated in sync with 1.3.6.4 release

* Thu Sep 30 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.6-1
- updated to 1.3.6 release
- fixed Copyright: tag

* Wed Sep 29 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.5.5-3
- in sync with downgraded xemacs release (21.1.4-1)

* Thu Sep 23 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.5.5-2
- Requires: faces, faces-xface added
  (compface is replaced with faces rpms from Red Hat Rawhide)

* Fri Sep 10 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.5.5-1
- updated to 1.3.5.5 release

* Thu Sep  2 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.5.3-5
- spec has been splitted into mule / xemacs packages

* Sun Aug 29 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.5.3-3
- slight modifications for the %prep & %clean section

* Thu Aug 26 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.5.3-2
- updated for XEmacs 21.1.6

* Mon Jul 12 1999 MATSUBAYASHI 'Shaolin' Kohji
- 1.3.5.3-1
- first RPM release
