summaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-28 16:06:38 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-28 16:06:38 +0100
commitf42dd3c3901ea0ba38e67a616aea9953cae81b8d (patch)
tree3626ca40161dbfaa5e72a4dbeaa46b24480ddc8c /src/option.c
parent0c0590d9827cb07a33c1552cb3558b94bddcb4dc (diff)
downloadvim-git-f42dd3c3901ea0ba38e67a616aea9953cae81b8d.tar.gz
patch 8.0.0251: not easy to select Python 2 or 3v8.0.0251
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)
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/option.c b/src/option.c
index a987a4cdf..b90d5fdfa 100644
--- a/src/option.c
+++ b/src/option.c
@@ -479,6 +479,17 @@ struct vimoption
# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
#endif
+/* Default python version for pyx* commands */
+#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
+# define DEFAULT_PYTHON_VER 0
+#elif defined(FEAT_PYTHON3)
+# define DEFAULT_PYTHON_VER 3
+#elif defined(FEAT_PYTHON)
+# define DEFAULT_PYTHON_VER 2
+#else
+# define DEFAULT_PYTHON_VER 0
+#endif
+
/*
* options[] is initialized here.
* The order of the options MUST be alphabetic for ":set all" and findoption().
@@ -2143,6 +2154,14 @@ static struct vimoption options[] =
{(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
SCRIPTID_INIT},
#endif
+ {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
+#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
+ (char_u *)&p_pyx, PV_NONE,
+#else
+ (char_u *)NULL, PV_NONE,
+#endif
+ {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
+ SCRIPTID_INIT},
{"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
#ifdef FEAT_TEXTOBJ
(char_u *)&p_qe, PV_QE,
@@ -8826,6 +8845,15 @@ set_num_option(
mzvim_reset_timer();
#endif
+#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
+ /* 'pyxversion' */
+ else if (pp == &p_pyx)
+ {
+ if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
+ errmsg = e_invarg;
+ }
+#endif
+
/* sync undo before 'undolevels' changes */
else if (pp == &p_ul)
{