commit:     3c2c6e68310a16b96c058c9fa7e66b3119b88a89
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 27 13:29:47 2016 +0000
Commit:     Tim Harder <radhermit <AT> gentoo <DOT> org>
CommitDate: Sat Mar  5 23:31:09 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-syntax.git/commit/?id=3c2c6e68

newebuild: Guess PYTHON_TARGETS from system

 plugin/gentoo-common.vim | 23 +++++++++++++++++++++++
 plugin/newebuild.vim     |  2 +-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/plugin/gentoo-common.vim b/plugin/gentoo-common.vim
index 99bc29d..bacecd9 100644
--- a/plugin/gentoo-common.vim
+++ b/plugin/gentoo-common.vim
@@ -54,4 +54,27 @@ fun! GentooGetArch()
     endif
 endfun
 
+fun! GentooGetPythonTargets()
+    if exists("g:gentoopythontargets") && g:gentoopythontargets != ""
+        return g:gentoopythontargets
+    else
+        let l:py2 = system("eselect python show --python2")
+        let l:py2 = substitute(l:py2, "\n", "", "g")
+        let l:py3 = system("eselect python show --python3")
+        let l:py3 = substitute(l:py3, "\n", "", "g")
+
+        if l:py2 == ""
+            let l:py2 = "python2.7"
+        endif
+        if l:py3 == ""
+            let l:py3 = "python3.4"
+        endif
+
+        let l:pythons = substitute(l:py2 . " " . l:py3, "[.]", "_", "g")
+
+        let g:gentoopythontargets = l:pythons
+        return g:gentoopythontargets
+    endif
+endfun
+
 " vim: set et foldmethod=marker : "

diff --git a/plugin/newebuild.vim b/plugin/newebuild.vim
index c2bcd1c..7197e41 100644
--- a/plugin/newebuild.vim
+++ b/plugin/newebuild.vim
@@ -144,7 +144,7 @@ fun! <SID>MakeNewEbuild()
             " {{{ standard default setup
             " {{{ extra inherits for some categories
             if l:category ==# "dev-python"
-                put ='PYTHON_COMPAT=( python2_7 python3_4 )'
+                put ='PYTHON_COMPAT=( ' . GentooGetPythonTargets() . ' )'
                 put ='inherit distutils-r1'
                 put =''
             elseif l:category =~# "^xfce-"

Reply via email to