| 1 |
vapier |
1.5 |
# Copyright 1999-2004 Gentoo Foundation |
| 2 |
agriffis |
1.1 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
pioto |
1.11 |
# $Header: /var/cvsroot/gentoo-x86/eclass/vim-doc.eclass,v 1.10 2005/12/07 17:53:25 ciaranm Exp $ |
| 4 |
agriffis |
1.1 |
# |
| 5 |
|
|
# This eclass is used by vim.eclass and vim-plugin.eclass to update |
| 6 |
|
|
# the documentation tags. This is necessary since vim doesn't look in |
| 7 |
|
|
# /usr/share/vim/vimfiles/doc for documentation; it only uses the |
| 8 |
|
|
# versioned directory, for example /usr/share/vim/vim62/doc |
| 9 |
|
|
# |
| 10 |
|
|
# We depend on vim being installed, which is satisfied by either the |
| 11 |
|
|
# DEPEND in vim-plugin or by whatever version of vim is being |
| 12 |
|
|
# installed by the eclass. |
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
update_vim_helptags() { |
| 16 |
|
|
local vimfiles vim d s |
| 17 |
|
|
|
| 18 |
|
|
# This is where vim plugins are installed |
| 19 |
pioto |
1.11 |
vimfiles="${ROOT}"/usr/share/vim/vimfiles |
| 20 |
agriffis |
1.1 |
|
| 21 |
agriffis |
1.6 |
if [[ $PN != vim-core ]]; then |
| 22 |
ciaranm |
1.7 |
# Find a suitable vim binary for updating tags :helptags |
| 23 |
|
|
if use ppc-macos ; then |
| 24 |
|
|
vim=$(which gvim 2>/dev/null ) |
| 25 |
|
|
else |
| 26 |
|
|
vim=$(which vim 2>/dev/null) |
| 27 |
|
|
[[ -z "$vim" ]] && vim=$(which gvim 2>/dev/null) |
| 28 |
|
|
[[ -z "$vim" ]] && vim=$(which kvim 2>/dev/null) |
| 29 |
|
|
fi |
| 30 |
agriffis |
1.6 |
if [[ -z "$vim" ]]; then |
| 31 |
|
|
ewarn "No suitable vim binary to rebuild documentation tags" |
| 32 |
|
|
fi |
| 33 |
agriffis |
1.1 |
fi |
| 34 |
|
|
|
| 35 |
ciaranm |
1.10 |
# Make vim not try to connect to X. See :help gui-x11-start |
| 36 |
|
|
# in vim for how this evil trickery works. |
| 37 |
|
|
if ! [[ -z "${vim}" ]] ; then |
| 38 |
|
|
ln -s "${vim}" "${T}/tagvim" |
| 39 |
|
|
vim="${T}/tagvim" |
| 40 |
|
|
fi |
| 41 |
|
|
|
| 42 |
agriffis |
1.1 |
# Install the documentation symlinks into the versioned vim |
| 43 |
|
|
# directory and run :helptags |
| 44 |
pioto |
1.11 |
for d in "${ROOT}"/usr/share/vim/vim[0-9]*; do |
| 45 |
agriffis |
1.1 |
[[ -d "$d/doc" ]] || continue # catch a failed glob |
| 46 |
|
|
|
| 47 |
|
|
# Remove links, and possibly remove stale dirs |
| 48 |
|
|
find $d/doc -name \*.txt -type l | while read s; do |
| 49 |
agriffis |
1.6 |
[[ $(readlink "$s") = $vimfiles/* ]] && rm -f "$s" |
| 50 |
agriffis |
1.1 |
done |
| 51 |
agriffis |
1.4 |
if [[ -f "$d/doc/tags" && $(find "$d" | wc -l | tr -d ' ') = 3 ]]; then |
| 52 |
agriffis |
1.1 |
# /usr/share/vim/vim61 |
| 53 |
|
|
# /usr/share/vim/vim61/doc |
| 54 |
|
|
# /usr/share/vim/vim61/doc/tags |
| 55 |
|
|
einfo "Removing $d" |
| 56 |
|
|
rm -r "$d" |
| 57 |
|
|
continue |
| 58 |
|
|
fi |
| 59 |
|
|
|
| 60 |
|
|
# Re-create / install new links |
| 61 |
agriffis |
1.2 |
if [[ -d $vimfiles/doc ]]; then |
| 62 |
|
|
ln -s $vimfiles/doc/*.txt $d/doc 2>/dev/null |
| 63 |
agriffis |
1.1 |
fi |
| 64 |
|
|
|
| 65 |
|
|
# Update tags; need a vim binary for this |
| 66 |
|
|
if [[ -n "$vim" ]]; then |
| 67 |
|
|
einfo "Updating documentation tags in $d" |
| 68 |
|
|
DISPLAY= $vim -u NONE -U NONE -T xterm -X -n -f \ |
| 69 |
|
|
'+set nobackup nomore' \ |
| 70 |
|
|
"+helptags $d/doc" \ |
| 71 |
|
|
'+qa!' </dev/null &>/dev/null |
| 72 |
ciaranm |
1.10 |
rm "${vim}" |
| 73 |
agriffis |
1.1 |
fi |
| 74 |
|
|
done |
| 75 |
|
|
} |