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

Summary:      a IBus client for GNU Emacs
Summary(ja):  GNU Emacs 用 IBus クライアント
Name:         %{origname}
Version:      %{origver}
Release:      1%{?_dist_release}

# http://launchpad.net/ibus.el
Source0:      ibus-el-%{version}.tar.gz
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source3:      vine-default-%{origname}.el
Source4:      %{origname}-init.el

#
Patch0:       ibus-el-0.2.1-emacs-24.0.90.patch

License:      GPLv3
Group:        Applications/Editors/Emacs
URL:          http://www11.atwiki.jp/s-irie/pages/21.html
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch

Requires:     emacsen
PreReq:       emacsen
%prereq_ge    emacsen-common
Requires:     python >= 2.5
Requires:     ibus >= 1.2
Requires:     python-xlib

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     iwaim, munepi

%description
ibus.el is a IBus client for GNU Emacs. This program allows users
on-the-spot style input with IBus. The input statuses are individually
kept for each buffer, and prefix-keys such as C-x and C-c can be used
even if IBus is active. So you can input various languages fast and
comfortably by using it.

%prep

%setup -q -n %{origname}-%{origver}

#%patch0 -p1 -b .emacs24

%build

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

mkdir -p %{buildroot}%{_datadir}/%{name}
install -m 0755 ibus-el-agent %{buildroot}%{_datadir}/%{name}

mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/packages
mkdir -p %{buildroot}%{emacsen_pkgdir}/install
mkdir -p %{buildroot}%{emacsen_pkgdir}/remove

#
# install el files
#

cp -p *.el %{SOURCE3} %{SOURCE4} %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}


#
# install script (bytecompile el and install elc , remove)
#

%_installemacsenscript %{origname} %{SOURCE1}

%_removeemacsenscript  %{origname} %{SOURCE2}


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

%post
#
# bytecompile and install
#
if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{origname}

fi

%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}


%preun
if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

fi


%files
%defattr(-,root,root)
%doc README doc/COPYING doc/ChangeLog
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/ibus-el-agent

%changelog
* Tue Jan 31 2012 Munehiro Yamamoto <munepi@vinelinux.org> 0.3.0-1
- new upstream release
- added "munepi" in Packager tag

* Mon Oct  3 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.2.1-3
- supported emacs-24.0.90
- updated ibus-el-init.el
  - output "Loading vine-default-ibus-el ..." to the buffer *Messages*

* Tue Apr  5 2011 IWAI, Masaharu <iwai@alib.jp> 0.2.1-2vl6
- fix <BTS:VineLinux:1117>
 - update vine-default-ibus-el.el (Source3): sync [VineSeed:22997]

* Wed Nov 24 2010 IWAI, Masaharu <iwai@alib.jp> 0.2.1-1
- new upstream release

* Tue Aug 31 2010 IWAI, Masaharu <iwai@alib.jp> 0.2.0-1
- new upstream release

* Sat Jun 12 2010 IWAI, Masaharu <iwai@alib.jp> 0.1.1-1
- new upstream release

* Mon Jun  7 2010 IWAI, Masaharu <iwai@alib.jp> 0.1.0-1
- first release for Vine Linux
