| 1 |
# Copyright 1999-2004 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/vim-doc.eclass,v 1.9 2005/07/06 20:23:20 agriffis Exp $
|
| 4 |
#
|
| 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 |
vimfiles=/usr/share/vim/vimfiles
|
| 20 |
|
| 21 |
if [[ $PN != vim-core ]]; then
|
| 22 |
# 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 |
if [[ -z "$vim" ]]; then
|
| 31 |
ewarn "No suitable vim binary to rebuild documentation tags"
|
| 32 |
fi
|
| 33 |
fi
|
| 34 |
|
| 35 |
# 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 |
# Install the documentation symlinks into the versioned vim
|
| 43 |
# directory and run :helptags
|
| 44 |
for d in /usr/share/vim/vim[0-9]*; do
|
| 45 |
[[ -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 |
[[ $(readlink "$s") = $vimfiles/* ]] && rm -f "$s"
|
| 50 |
done
|
| 51 |
if [[ -f "$d/doc/tags" && $(find "$d" | wc -l | tr -d ' ') = 3 ]]; then
|
| 52 |
# /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 |
if [[ -d $vimfiles/doc ]]; then
|
| 62 |
ln -s $vimfiles/doc/*.txt $d/doc 2>/dev/null
|
| 63 |
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 |
rm "${vim}"
|
| 73 |
fi
|
| 74 |
done
|
| 75 |
}
|