%define _noVersionedDependencies	1
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'Requires(post)::%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define	origname auto-complete
%define origver  1.3.1

Summary:      The most intelligent auto-completion extension for GNU Emacs
Summary(ja):  GNU Emacs のための最も賢い自動補完機能
Name:         %{origname}-mode
Version:      %{origver}
Release:      1%{?_dist_release}

Source0:      http://cx4a.org/pub/auto-complete/auto-complete-%{version}.tar.bz2
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source3:      vine-default-%{origname}.el.in
Source4:      %{origname}-init.el

License:      GPLv3
Group:        Applications/Editors/Emacs
URL:          http://cx4a.org/software/auto-complete/
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch

Requires:     emacsen
Requires(post): emacsen
#%prereq_ge    emacsen-common

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     munepi

%description
Auto Complete Mode is the most intelligent auto-completion extension for GNU 
Emacs. Auto Complete Mode renews an old completion interface and provides an 
environment that makes users could be more concentrate on their own works.

Features
 * Visual interface
 * Reduce overhead of completion by using statistic method
 * Extensibility


%description -l ja
Auto Complete ModeはGNU Emacsのための最も賢い自動補完機能です。
従来の使いづらい補完インターフェースを一新し、
ユーザーがより本質的な作業に集中できる環境を提供します。

特徴
 * 視覚的な操作感
 * 統計的手法による補完オーバーヘッドの削減
 * 拡張性

%prep

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

%build

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

%__mkdir_p %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}
%__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}
%__cp -ra dict %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/ac-dict || exit 1


#
# 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 COPYING.FDL.txt COPYING.GPLv3.txt README.txt TODO.txt
%doc doc etc
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}


%changelog
* Thu Aug 25 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.3.1-1
- first release for Vine Linux
