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

Name:          yatex
Version:       1.78.4
Release:       5%{?_dist_release}
License:       Distributable
Source0:       http://www.yatex.org/yatex%{version}.tar.gz 
#Source0:       http://www.gentei.org/~yuuji/tmp/yatex11205111805.tar.gz
Source1:       %{name}-install.sh
Source2:       %{name}-remove.sh
Source3:       %{name}-init.el
Source4:       vine-default-%{name}.el
Source5:       vine-default-yahtml.el

Source10:      fwdevince.py

## Vine Patch(es)
Patch1:        yatexhlp-emacs.diff
Patch2:        yatex-make.diff
# based on a patch at http://www.nekolinux.2y.net/nekomemo/yahtml01.html
# and modified to suit 1.70 release
Patch3:        yahtml-1.70-timestamp.patch

Patch10:       yatex-1.78.4-vine-vl7.patch

URL:           http://www.yatex.org/
Group:         Applications/Editors/Emacs
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
Summary:       YaTeX - Yet Another TeX mode for Emacs
Summary(ja):   野鳥(YaTeX) - Yet Another TeX mode for Emacs
BuildArch:     noarch

Requires:       evince python3

Requires(post): emacsen
Requires(post): emacsen-common
Requires(post): make
BuildRequires: emacsen-common
BuildRequires: nkf perl
Obsoletes:     yatex-xemacs

Distribution:  Vine Linux
Vendor:        Project Vine
Packager:      munepi

%description
YaTeX is an intelligent, acquisitive and integrated package which reduces
your efforts of composing LaTeX source on GNU Emacs.


If you are YaTeX user and you install both yatex and auctex on your system, 
you may add the following configure in your emacs init file 
~/.emacs.d/emacsXX-vine-default.el (XX: emacs major version): 

;; I am a YaTeX user!!!
(setq vine-default-auctex nil
      vine-default-preview-latex nil)


%description -l ja
YaTeX(野鳥)とは、EmacsでLaTeXソースを書くときに生ずる手間を軽減
してくれる、LaTeX 入力支援環境です。


yatex と auctex パッケージの両方をインストールする場合、
~/.emacs.d/emacsXX-vine-default.el (XX: emacs のメジャーバージョン)
に以下の設定を追加するとよいでしょう。

;; YaTeX ユーザです！！！
(setq vine-default-auctex nil
      vine-default-preview-latex nil)


vine-default-yatex では、エディタ emacs と PDF プレビュー evince との
forward/inverse search を設定済です。
 - emacs -> evince (forward search): C-c C-g
 - evince -> emacs (inverse search): Ctrl+左クリック

%prep
%setup -n yatex%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1

%patch10 -p1 -b .vine

(cd docs
    # change permissions
    chmod 644 *

    # encode as utf-8 (LF)
    # NOTE: This changes needs to entry info files to Info DIR
    for i in yatexj yatexe yahtmlj yahtmle; do nkf --unix -w --overwrite $i; done
)


%build


%install
%__rm -rf ${RPM_BUILD_ROOT}

install -Dpm 755 %{SOURCE10} ${RPM_BUILD_ROOT}%{_bindir}/fwdevince

%__mkdir_p ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}
%__mkdir_p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/install
%__mkdir_p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/remove
%__mkdir_p ${RPM_BUILD_ROOT}%{_infodir}


#
# install el files
#

%__cp -a *.el makefile help \
      ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}
%__cp -a %{SOURCE3} %{SOURCE4} %{SOURCE5} \
      ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}/

#
# install info files
#

%__install -m 644 docs/{yahtmle,yahtmlj,yatexe,yatexj} \
   ${RPM_BUILD_ROOT}%{_infodir}


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

%_installemacsenscript %{name} %{SOURCE1}

%_removeemacsenscript  %{name} %{SOURCE2}


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


%post
#
# bytecompile and install
#

if [ "$1" = 2 ] ; then

%_emacsenPackageRemove %{name}

fi

%_addemacsenlist %{name}

%_emacsenPackageInstall %{name}

for i in yatexe yatexj yahtmle yahtmlj; do 
    /sbin/install-info --dir-file %{_infodir}/dir --section="Emacs" \
    		       %{_infodir}/${i}.gz
done


%preun

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{name}

%_removeemacsenlist %{name}

for i in yatexe yatexj yahtmle yahtmlj; do 
    /sbin/install-info --delete --dir-file %{_infodir}/dir --section="Emacs" \
    		       %{_infodir}/${i}.gz
done

fi


%files
%defattr(-,root,root)
%doc 00readme install manifest yatex.new
%doc docs
%{_bindir}/fwdevince
%{_datadir}/emacs/site-lisp/yatex/
%{_infodir}/yahtmle*
%{_infodir}/yahtmlj*
%{_infodir}/yatexe*
%{_infodir}/yatexj*
%{emacsen_pkgdir}/install/%{name}
%{emacsen_pkgdir}/remove/%{name}


%changelog
* Tue May 10 2016 Munehiro Yamamoto <munepi@vinelinux.org> 1.78.4-5
- fixed fwdevince.py

* Sun Jan 24 2016 Munehiro Yamamoto <munepi@vinelinux.org> 1.78.4-4
- added Requires: evince python3

* Sun Jan 24 2016 Munehiro Yamamoto <munepi@vinelinux.org> 1.78.4-3
- updated vine-default-yatex.el
  - supported forward search via fwdevince.py/python3
  - supported inverse search via evince

* Sun Jan 24 2016 Munehiro Yamamoto <munepi@vinelinux.org> 1.78.4-2
- set uplatex+dvipdfmx as default

* Mon Jan 11 2016 Munehiro Yamamoto <munepi@vinelinux.org> 1.78.4-1
- new upstream release
- TeX Live 2015

* Mon May 13 2013 Munehiro Yamamoto <munepi@vinelinux.org> 1.77-1
- new upstream release
- applied yatex-1.77-vine-vl{6,7}.patch instead

* Tue May 22 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.76-2
- new upstream release
- updated yatex-1.76-vine-vl{6,7}.patch

* Sat May 12 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.76-1.20120511
- source snapshot 20120511: testing version 1.76 development
- dropped obsoleted/upstreamed patches
- applied yatex-1.76-vine-vl{6,7}.patch

* Fri May 11 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.75-3
- added BuildRequires: nkf perl
- updated yatex-1.74-vine.patch as yatex-1.75-vine-vl{6,7}.patch
- dropped pre-formatted info files
- use original info files
  - encode info files as utf-8
  - add INFO-DIR-ENTRY

* Thu May 10 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.75-2
- fixed vine-default-yatex.el
- applied yatex-1.74-vine.patch for vl6
- updated yatex-1.74-vine.patch: support some extensions for \includegraphics

* Thu Feb  9 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.75-1
- new upstream release
- updated vine-default-yatex.el

* Sat Dec  3 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-9
- support TeX Live 2011
- applied yatex-1.74-vine-vl7.patch
- updated vine-default-yatex.el

* Thu Aug 11 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-8
- added Requires(post): make

* Sat Apr 16 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-7
- updated vine-default-yatex.el
  - check 'YaTeX-inhibit-prefix-letter
  - used "pbibtex -kanji=utf8" as default bibtex-command
  - used "mendex -U" as default makeindex-command

* Wed Mar 23 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-6
- updated vine-default-{yatex,yahtml}.el
  - revived auto-fill-mode on {yatex,yahtml}-mode

* Tue Feb 22 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-5
- updated yatex-init.el
  - dropped all pathes of auctex and preview-latex from load-path

* Sat Jan 29 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-4
- updated vine-default-yatex.el
  - added (setq YaTeX-inhibit-prefix-letter t) [yatex:04567]
  - supported TeX Live
    - used "eplatex", "pxdvi", "pdvips" as default commands
- updated yatex-init.el
  - output "Loading vine-default-yatex ..." to the buffer *Messages*
  - defined vine-default-yahtml
- added vine-default-yahtml.el

* Tue Jan 04 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-3
- updated vine-default-yatex.el
  - added bbl extension in auto-mode-alist to run yatex-mode

* Sun Dec 05 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-2
- updated vine-default-yatex.el
  - supported new vine-default

* Mon Jan 04 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-1
- new upstream release

* Sun Oct 18 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.73-7
- updated vine-default-yatex.el
  - dropped (setq YaTeX-no-begend-shortcut t)
- use %{emacsen_pkgdir}

* Sun May 17 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-6
- updated vine-default-yatex.el
  - (setq tex-command "platex -kanji=utf8 -src-specials") [VineSeed:17572]

* Wed May 06 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-5
- updated yatex-install.sh
  - *-init.el: changed from hard copy to symbolic link 
    on /etc/emacs-XX.YY/site-start.d

* Tue Apr 21 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-4
- fixed yatex-init.el

* Sat Apr 11 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-3
- added yatex-init.el, vine-default-yatex.el
- updated yatex-install.sh, yatex-remove.sh for vine-default-yatex.el

* Sun Mar 29 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-2
- spec in utf8

* Sat Jun 14 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.73-1
- applied new versioning policy

* Wed Aug 08 2007 KOBAYASHI Taizo <tkoba@vinelinux.org> 1.73-0vl1
- new upstream release

* Mon Sep 11 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.72-0vl2
- s/Copyright/License/
- changed Group to Applications/Editors/Emacs <BTS:VineLinux:163>

* Sun Feb 01 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.72-0vl1
- update yatex-1.72

* Wed May 07 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.71-0vl1
- update yatex-1.71

* Wed Jul 17 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.70-0vl2
- added Patch3 to add hhmts timestamp feature

* Mon May 27 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.70-0vl1
- update yatex-1.70

* Tue May 21 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.69-0vl0.1
- update yatex10203151806

* Wed Mar 13 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.68-0vl4
- fixed: bytecompile yatex19

* Fri Dec 28 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.68-0vl3
- now emacsen-common aware
- FIXME: newer upstream 1.69.2 do not work fine with xemacs-21.1.14

* Wed Oct 11 2000 Jun Nishii <jun@vinelinux.org>
- 1.68-0vl2
- no kanji code conversion of documents

* Tue Sep 19 2000 T.R. Kobayashi <tkoba@ike-dyn.ritsumei.ac.jp>
- 1.68-0vl1
- update to 1.68

* Wed Jul 05 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl5
- YATEXHLP.{jp,eng} moved to appropriate dir

* Fri Jun 23 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl3
- rebuilt for emacs-20.7

* Thu May 11 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl2
- oops ... fixed target dir for help files

* Tue May 09 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl1
- rebuilt for emacs-20.6

* Tue Jan 11 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-6
- included forgotten info file for YaHTML

* Fri Jan 07 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-5
- updated for emacs-20.5a release

* Wed Dec  1 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-4
- change Group to Applications/Editors/EmacsLisp

* Sun Nov 28 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-3
- %post and %preun section modified

* Thu Sep 23 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-2
- fixed minor problem in the %files section

* Sat Sep 18 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-1
- updated to 1.67 release
- rebuilt for emacs-20.4 on Vine Linux 1.9
- updated URL for the new web site of YaTeX
- some typo fix

* Tue May  4 1999 Daisuke SUZUKI <daisuke@linux.or.jp>
- Initial Release
