aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorDavid Jimenez <dvejmz@users.noreply.github.com>2019-01-02 13:51:03 +0000
committerJustin M. Keyes <justinkz@gmail.com>2019-01-02 14:51:03 +0100
commit8f288698e4730f6cc91240fe899e93921aff9d71 (patch)
tree638a46ca5a47d9613ad9957ae5498605817e2404 /src/nvim/eval.c
parent5a11e553588f90f3c945222d89ee3ff80cfc3fc7 (diff)
downloadrneovim-8f288698e4730f6cc91240fe899e93921aff9d71.tar.gz
rneovim-8f288698e4730f6cc91240fe899e93921aff9d71.tar.bz2
rneovim-8f288698e4730f6cc91240fe899e93921aff9d71.zip
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) https://github.com/vim/vim/commit/f42dd3c3901ea0ba38e67a616aea9953cae81b8d
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 3a231ab8f1..f1cce716e0 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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'