mirror of
https://github.com/neovim/neovim.git
synced 2025-12-09 08:02:38 +00:00
vim-patch:8.0.0251: not easy to select Python 2 or 3 (#9173)
Problem: It is not so easy to write a script that works with both Python 2 and Python 3, even when the Python code works with both.
Solution: Add 'pyxversion', :pyx, etc. (Marc Weber, Ken Takata)
f42dd3c390
This commit is contained in:
committed by
Justin M. Keyes
parent
5a11e55358
commit
8f288698e4
@@ -10704,6 +10704,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
"postscript",
|
||||
"printer",
|
||||
"profile",
|
||||
"pythonx",
|
||||
"reltime",
|
||||
"quickfix",
|
||||
"rightleft",
|
||||
@@ -13026,6 +13027,10 @@ static void f_pumvisible(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
*/
|
||||
static void f_pyeval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
if (p_pyx == 0) {
|
||||
p_pyx = 2;
|
||||
}
|
||||
|
||||
script_host_eval("python", argvars, rettv);
|
||||
}
|
||||
|
||||
@@ -13034,9 +13039,24 @@ static void f_pyeval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
*/
|
||||
static void f_py3eval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
if (p_pyx == 0) {
|
||||
p_pyx = 3;
|
||||
}
|
||||
|
||||
script_host_eval("python3", argvars, rettv);
|
||||
}
|
||||
|
||||
// "pyxeval()" function
|
||||
static void f_pyxeval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
init_pyxversion();
|
||||
if (p_pyx == 2) {
|
||||
f_pyeval(argvars, rettv, NULL);
|
||||
} else {
|
||||
f_py3eval(argvars, rettv, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "range()" function
|
||||
*/
|
||||
@@ -20133,7 +20153,9 @@ void ex_function(exarg_T *eap)
|
||||
arg = skipwhite(skiptowhite(p));
|
||||
if (arg[0] == '<' && arg[1] =='<'
|
||||
&& ((p[0] == 'p' && p[1] == 'y'
|
||||
&& (!ASCII_ISALPHA(p[2]) || p[2] == 't'))
|
||||
&& (!ASCII_ISALNUM(p[2]) || p[2] == 't'
|
||||
|| ((p[2] == '3' || p[2] == 'x')
|
||||
&& !ASCII_ISALPHA(p[3]))))
|
||||
|| (p[0] == 'p' && p[1] == 'e'
|
||||
&& (!ASCII_ISALPHA(p[2]) || p[2] == 'r'))
|
||||
|| (p[0] == 't' && p[1] == 'c'
|
||||
|
||||
Reference in New Issue
Block a user