Guest User

Gen2ly

a guest
Oct 16th, 2009
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.10 KB | None | 0 0
  1. " Vim plugin
  2. " Purpose:      Intelligently create content for new ebuild files
  3. " Author:       Ciaran McCreesh <[email protected]>
  4. " Copyright:    Copyright (c) 2004-2005 Ciaran McCreesh
  5. " Licence:      You may redistribute this under the same terms as Vim itself
  6.  
  7. if &compatible || v:version < 603 || exists("g:loaded_newebuild")
  8.    finish
  9. endif
  10.  
  11. let g:loaded_newebuild=1
  12.  
  13. runtime! plugin/gentoo-common.vim
  14.  
  15. fun! <SID>MakeNewEbuild()
  16.    let l:pastebackup = &paste
  17.    set nopaste
  18.  
  19.    " {{{ variables
  20.     let l:arch = GentooGetArch()
  21.     let l:filename = expand("%:p")
  22.     let l:category = substitute(l:filename,
  23.                 \ "^.*/\\([^/]\\+\\)/[^/]\\+/[^/]\\+\\.ebuild", "\\1", "g")
  24.     " }}}
  25.  
  26.    call GentooHeader()
  27.  
  28.    if expand("%:e") =~# "eclass\$"
  29.        " {{{ eclass special setup
  30.         let l:eclass=substitute(expand("%:t"), "\\.eclass\$", "", "")
  31.         put ='#'
  32.         put ='# Original Author: ' . GentooGetUser()
  33.         put ='# Purpose: '
  34.         put ='#'
  35.         put =''
  36.         " }}}
  37.  
  38.        " {{{ go to the first thing to edit
  39.         0
  40.         /^# Purpose:/
  41.         normal $
  42.         nohls
  43.         " }}}
  44.    else
  45.        put ='EAPI=\"2\"'
  46.        put =''
  47.        if l:category ==# "app-vim"
  48.            " {{{ app-vim special setup
  49.             put ='#VIM_PLUGIN_VIM_VERSION=\"7.0\"'
  50.             put ='inherit vim-plugin'
  51.             put =''
  52.             put ='DESCRIPTION=\"vim plugin: \"'
  53.             put ='HOMEPAGE=\"http://www.vim.org/scripts/script.php?script_id=\"'
  54.             put ='LICENSE=\"\"'
  55.             put ='KEYWORDS=\"~' . l:arch . '\"'
  56.             put ='IUSE=\"\"'
  57.             put =''
  58.             put ='VIM_PLUGIN_HELPFILES=\"\"'
  59.             put ='VIM_PLUGIN_HELPTEXT=\"\"'
  60.             put ='VIM_PLUGIN_HELPURI=\"\"'
  61.             put ='VIM_PLUGIN_MESSAGES=\"\"'
  62.             put =''
  63.             " }}}
  64.        elseif l:category ==# "www-apache" && expand("%:t") =~# "^mod_"
  65.            " {{{ www-apache default setup (for module pkgs)
  66.             put ='inherit apache-module'
  67.             put =''
  68.             put ='DESCRIPTION=\"\"'
  69.             put ='HOMEPAGE=\"\"'
  70.             put ='LICENSE=\"\"'
  71.             put =''
  72.             put ='KEYWORDS=\"~' . l:arch . '\"'
  73.             put ='IUSE=\"\"'
  74.             put ='SLOT=\"0\"'
  75.             put =''
  76.             put ='# See apache-module.eclass for more information.'
  77.             put ='APACHE2_MOD_CONF=\"XX_${PN}\"'
  78.             put ='APACHE2_MOD_DEFINE=\"\"'
  79.             put =''
  80.             put ='need_apache2'
  81.             " }}}
  82.     elseif l:category ==# "dev-java"
  83.         " {{{ dev-java generation-2 default ant ebuild
  84.         put ='JAVA_PKG_IUSE=\"doc source\"'
  85.         put =''
  86.         put ='inherit java-pkg-2 java-ant-2'
  87.         put =''
  88.         put ='DESCRIPTION=\"\"'
  89.         put ='HOMEPAGE=\"\"'
  90.         put ='SRC_URI=\"${P}.zip\"'
  91.         put =''
  92.         put ='LICENSE=\"\"'
  93.         put ='SLOT=\"0\"'
  94.         put ='KEYWORDS=\"~' . l:arch .'\"'
  95.         put =''
  96.         put ='IUSE=\"\"'
  97.         put =''
  98.         put ='COMMON_DEP=\"\"'
  99.         put =''
  100.         put ='RDEPEND=\">=virtual/jre-1.4'
  101.         put ='  ${COMMON_DEP}\"'
  102.         put ='DEPEND=\">=virtual/jdk-1.4'
  103.         put ='  app-arch/unzip'
  104.         put ='  ${COMMON_DEP}\"'
  105.         put =''
  106.         put ='EANT_BUILD_TARGET=\"\"'
  107.         put ='EANT_DOC_TARGET=\"\"'
  108.         put =''
  109.         put ='src_install() {'
  110.         put ='  java-pkg_dojar \"${PN}.jar\"'
  111.         put ='  use doc && java-pkg_dojavadoc build/javadoc'
  112.         put ='  use source && java-pkg_dosrc src'
  113.         put ='}'
  114.         put =''
  115.         else
  116.             " {{{ standard default setup
  117.            " {{{ extra inherits for some categories
  118.             if l:category =~# "^games-"
  119.                 put ='inherit games'
  120.                 put =''
  121.             elseif l:category ==# "dev-python"
  122.                 put ='inherit distutils'
  123.                 put =''
  124.             elseif l:category ==# "dev-perl"
  125.                 put ='inherit perl-module'
  126.                 put =''
  127.             endif
  128.             " }}}
  129.  
  130.            put ='DESCRIPTION=\"\"'
  131.            put ='HOMEPAGE=\"\"'
  132.            put ='SRC_URI=\"\"'
  133.            put =''
  134.            put ='LICENSE=\"\"'
  135.            put ='SLOT=\"0\"'
  136.            put ='KEYWORDS=\"~' . l:arch . '\"'
  137.            put ='IUSE=\"\"'
  138.            put =''
  139.  
  140.            " {{{ extra deps for some categories
  141.             put ='DEPEND=\"\"'
  142.             put ='RDEPEND=\"${DEPEND}\"'
  143.             put =''
  144.             " }}}
  145.        endif
  146.  
  147.        " {{{ go to the first thing to edit
  148.         0
  149.         /^DESCRIPTION=/
  150.         exec "normal 2f\""
  151.         nohls
  152.         " }}}
  153.    endif
  154.  
  155.    if pastebackup == 0
  156.        set nopaste
  157.    endif
  158. endfun
  159.  
  160. com! -nargs=0 NewEbuild call <SID>MakeNewEbuild()
  161.  
  162. if !exists("g:ebuild_create_on_empty")
  163.    " Enable autogeneration of ebuilds by default
  164.     let g:ebuild_create_on_empty = 1
  165. endif
  166.  
  167. " check to see if v:progname is vimdiff to disable new ebuild creation
  168. if v:progname =~ "vimdiff"
  169.    let g:ebuild_create_on_empty = 0
  170. endif
  171.  
  172. augroup NewEbuild
  173.    au!
  174.    autocmd BufNewFile *.e{build,class}
  175.                \ if g:ebuild_create_on_empty |
  176.                \    call <SID>MakeNewEbuild() |
  177.                \ endif
  178. augroup END
  179.  
  180. " vim: set et foldmethod=marker : "
  181.  
Advertisement
Add Comment
Please, Sign In to add comment