/[gentoo-alt]/trunk/prefix/eclass/vim-plugin.eclass
Gentoo

Contents of /trunk/prefix/eclass/vim-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1166 - (show annotations) (download)
Sat Mar 25 22:08:50 2006 UTC (13 years ago) by kito
File size: 4082 byte(s)
PREFIX->EPREFIX DEST->EDEST
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-plugin.eclass,v 1.14 2005/07/11 15:08:06 swegener Exp $
4 #
5 # This eclass simplifies installation of app-vim plugins into
6 # /usr/share/vim/vimfiles. This is a version-independent directory
7 # which is read automatically by vim. The only exception is
8 # documentation, for which we make a special case via vim-doc.eclass
9
10 inherit vim-doc
11 EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
12
13 IUSE=""
14 DEPEND="|| ( >=app-editors/vim-6.3
15 >=app-editors/gvim-6.3 )"
16 RDEPEND="${DEPEND}"
17 SRC_URI="mirror://gentoo/${P}.tar.bz2"
18 SLOT="0"
19
20 vim-plugin_src_install() {
21 local f
22
23 ebegin "Fixing file permissions"
24 # Make sure perms are good
25 chmod -R a+rX ${S} || die "chmod failed"
26 find ${S} -user 'portage' -exec chown ${PORTAGE_INST_UID:-0} '{}' \; || die "chown failed"
27 find ${S} -group 'portage' -exec chgrp ${PORTAGE_INST_GID:-0} '{}' \; || die "chgrp failed"
28 eend $?
29
30 # Install non-vim-help-docs
31 cd ${S}
32 for f in *; do
33 [[ -f "${f}" ]] || continue
34 if [[ "${f}" = *.html ]]; then
35 dohtml "${f}"
36 else
37 dodoc "${f}"
38 fi
39 rm -f "${f}"
40 done
41
42 # Install remainder of plugin
43 cd ${WORKDIR}
44 dodir /usr/share/vim
45 mv ${S} ${D}/usr/share/vim/vimfiles
46 }
47
48 vim-plugin_pkg_postinst() {
49 update_vim_helptags # from vim-doc
50 update_vim_afterscripts # see below
51 display_vim_plugin_help # see below
52 }
53
54 vim-plugin_pkg_postrm() {
55 update_vim_helptags # from vim-doc
56 update_vim_afterscripts # see below
57
58 # Remove empty dirs; this allows
59 # /usr/share/vim to be removed if vim-core is unmerged
60 find ${EPREFIX}/usr/share/vim/vimfiles -depth -type d -exec rmdir {} \; 2>/dev/null
61 }
62
63 # update_vim_afterscripts: create scripts in
64 # /usr/share/vim/vimfiles/after/* comprised of the snippets in
65 # /usr/share/vim/vimfiles/after/*/*.d
66 update_vim_afterscripts() {
67 local d f afterdir=${EPREFIX}/usr/share/vim/vimfiles/after
68
69 # Nothing to do if the dir isn't there
70 [ -d ${afterdir} ] || return 0
71
72 einfo "Updating scripts in ${afterdir}"
73 find ${afterdir} -type d -name \*.vim.d | \
74 while read d; do
75 echo '" Generated by update_vim_afterscripts' > "${d%.d}"
76 find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | \
77 sort -z | xargs -0 cat >> "${d%.d}"
78 done
79
80 einfo "Removing dead scripts in ${afterdir}"
81 find ${afterdir} -type f -name \*.vim | \
82 while read f; do
83 [[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
84 || continue
85 # This is a generated file, but might be abandoned. Check
86 # if there's no corresponding .d directory, or if the
87 # file's effectively empty
88 if [[ ! -d "${f}.d" || -z "$(grep -v '^"')" ]]; then
89 rm -f "${f}"
90 fi
91 done
92 }
93
94 # Display a message with the plugin's help file if one is available. Uses the
95 # VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they
96 # should be separated by spaces. If no help files are available, but the env
97 # var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
98 # have nothing else, display a link to VIM_PLUGIN_HELPURI. An extra message
99 # regarding enabling filetype plugins is displayed if VIM_PLUGIN_MESSAGES
100 # includes the word "filetype".
101 display_vim_plugin_help() {
102 local h
103
104 if [[ -n "${VIM_PLUGIN_HELPFILES}" ]] ; then
105 einfo " "
106 einfo "This plugin provides documentation via vim's help system. To"
107 einfo "view it, use:"
108 for h in ${VIM_PLUGIN_HELPFILES} ; do
109 einfo " :help ${h}"
110 done
111 einfo " "
112
113 elif [[ -n "${VIM_PLUGIN_HELPTEXT}" ]] ; then
114 einfo " "
115 while read h ; do
116 einfo "$h"
117 done <<<"${VIM_PLUGIN_HELPTEXT}"
118 einfo " "
119
120 elif [[ -n "${VIM_PLUGIN_HELPURI}" ]] ; then
121 einfo " "
122 einfo "Documentation for this plugin is available online at:"
123 einfo " ${VIM_PLUGIN_HELPURI}"
124 einfo " "
125 fi
126
127 if hasq "filetype" "${VIM_PLUGIN_MESSAGES}" ; then
128 einfo "This plugin makes use of filetype settings. To enable these,"
129 einfo "add lines like:"
130 einfo " filetype plugin on"
131 einfo " filetype indent on"
132 einfo "to your ~/.vimrc file."
133 einfo " "
134 fi
135 }
136

  ViewVC Help
Powered by ViewVC 1.1.20