vim.Options.__iter__ makes it possible to iterate over option names: i.e.
for oname in vim.options:
print('Global option {0} has value {1!r}'.format(oname,
vim.options[oname]))
prints
Global option aleph has value 224
Global option arabicshape has value True
and so on.
vim.Options.__contains__ makes it possible to check whether some option exists:
if 'cole' not in vim.options:
print('Compiled without +conceal')
(note that `if 'conceallevel' in vim.options:` (full option name) will work
even without this part due to vim.Options.__iter__. vim.Options.__contains__ is
faster though.)
# HG changeset patch
# User ZyX <[email protected]>
# Date 1383332303 -14400
# Fri Nov 01 22:58:23 2013 +0400
# Branch python-.options
# Node ID f332d6dfb4749c7fc7f1f4961b8e817ce3cba46b
# Parent 92c9748e0ccbc42a5e28ce8fb9b8818e756a06da
Add options iterator
diff -r 92c9748e0ccb -r f332d6dfb474 src/if_py_both.h
--- a/src/if_py_both.h Sun Oct 06 17:46:56 2013 +0200
+++ b/src/if_py_both.h Fri Nov 01 22:58:23 2013 +0400
@@ -2708,10 +2708,10 @@
typedef struct
{
PyObject_HEAD
- int opt_type;
- void *from;
- checkfun Check;
- PyObject *fromObj;
+ int opt_type;
+ void *from;
+ checkfun Check;
+ PyObject *fromObj;
} OptionsObject;
static int
@@ -2830,6 +2830,42 @@
}
}
+typedef struct
+{
+ void *lastoption;
+ int opt_type;
+} optiterinfo_T;
+
+ static PyObject *
+OptionsIterNext(optiterinfo_T **oii)
+{
+ char_u *name;
+
+ if ((name = option_iter_next(&((*oii)->lastoption), (*oii)->opt_type)))
+ return PyString_FromString(name);
+
+ return NULL;
+}
+
+ static PyObject *
+OptionsIter(OptionsObject *self)
+{
+ optiterinfo_T *oii;
+
+ if (!(oii = PyMem_New(optiterinfo_T, 1)))
+ {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ oii->opt_type = self->opt_type;
+ oii->lastoption = NULL;
+
+ return IterNew(oii,
+ (destructorfun) PyMem_Free, (nextfun) OptionsIterNext,
+ NULL, NULL);
+}
+
static int
set_option_value_err(char_u *key, int numval, char_u *stringval, int opt_flags)
{
@@ -5879,6 +5915,7 @@
OptionsType.tp_basicsize = sizeof(OptionsObject);
OptionsType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC;
OptionsType.tp_doc = "object for manipulating options";
+ OptionsType.tp_iter = (getiterfunc)OptionsIter;
OptionsType.tp_as_mapping = &OptionsAsMapping;
OptionsType.tp_dealloc = (destructor)OptionsDestructor;
OptionsType.tp_traverse = (traverseproc)OptionsTraverse;
diff -r 92c9748e0ccb -r f332d6dfb474 src/option.c
--- a/src/option.c Sun Oct 06 17:46:56 2013 +0200
+++ b/src/option.c Fri Nov 01 22:58:23 2013 +0400
@@ -8956,6 +8956,68 @@
return r;
}
+
+/*
+ * Iterate over options. First argument is a pointer to a pointer to a
structure
+ * inside options[] array, second is option type like in the above function.
+ *
+ * If first argument points to NULL it is assumed that iteration just started
+ * and caller needs the very first value.
+ * If first argument points to the end marker function returns NULL and sets
+ * first argument to NULL.
+ *
+ * Returns full option name for current option on each call.
+ */
+ char_u *
+option_iter_next(option, opt_type)
+ void **option;
+ int opt_type;
+{
+ struct vimoption *ret = NULL;
+ do
+ {
+ if (*option == NULL)
+ *option = (void *) options;
+ else if (((struct vimoption *) (*option))->fullname == NULL)
+ {
+ *option = NULL;
+ return NULL;
+ }
+ else
+ *option = (void *) (((struct vimoption *) (*option)) + 1);
+
+ ret = ((struct vimoption *) (*option));
+
+ /* Hidden option */
+ if (ret->var == NULL)
+ {
+ ret = NULL;
+ continue;
+ }
+
+ switch (opt_type)
+ {
+ case SREQ_GLOBAL:
+ if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
+ ret = NULL;
+ break;
+ case SREQ_BUF:
+ if (!(ret->indir & PV_BUF))
+ ret = NULL;
+ break;
+ case SREQ_WIN:
+ if (!(ret->indir & PV_WIN))
+ ret = NULL;
+ break;
+ default:
+ EMSG2(_(e_intern2), "option_iter_next()");
+ return NULL;
+ }
+ }
+ while (ret == NULL);
+
+ return ret->fullname;
+}
#endif
/*
diff -r 92c9748e0ccb -r f332d6dfb474 src/proto/option.pro
--- a/src/proto/option.pro Sun Oct 06 17:46:56 2013 +0200
+++ b/src/proto/option.pro Fri Nov 01 22:58:23 2013 +0400
@@ -23,6 +23,7 @@
char_u *check_stl_option __ARGS((char_u *s));
int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval,
int opt_flags));
int get_option_value_strict __ARGS((char_u *name, long *numval, char_u
**stringval, int opt_type, void *from));
+char_u *option_iter_next __ARGS((void **option, int opt_type));
char_u *set_option_value __ARGS((char_u *name, long number, char_u *string,
int opt_flags));
char_u *get_term_code __ARGS((char_u *tname));
char_u *get_highlight_default __ARGS((void));
diff -r 92c9748e0ccb -r f332d6dfb474 src/testdir/test86.in
--- a/src/testdir/test86.in Sun Oct 06 17:46:56 2013 +0200
+++ b/src/testdir/test86.in Fri Nov 01 22:58:23 2013 +0400
@@ -449,6 +449,11 @@
:py bopts1=vim.buffers[vim.bindeval("g:bufs")[2]].options
:py bopts2=vim.buffers[vim.bindeval("g:bufs")[1]].options
:py bopts3=vim.buffers[vim.bindeval("g:bufs")[0]].options
+:$put ='wopts iters equal: '.pyeval('list(wopts1) == list(wopts2)')
+:$put ='bopts iters equal: '.pyeval('list(bopts1) == list(bopts2)')
+:py gset=set(iter(gopts1))
+:py wset=set(iter(wopts1))
+:py bset=set(iter(bopts1))
:set path=.,..,,
:let lst=[]
:let lst+=[['paste', 1, 0, 1, 2, 1, 1, 0
]]
@@ -479,6 +484,7 @@
: py oval3=bool(oval3)
: endif
: put ='>>> '.oname
+: $put =' g/w/b:'.pyeval('oname in gset').'/'.pyeval('oname in
wset').'/'.pyeval('oname in bset')
: for v in ['gopts1', 'wopts1', 'bopts1']
: try
: put =' p/'.v.': '.Ev('repr('.v.'['''.oname.'''])')
diff -r 92c9748e0ccb -r f332d6dfb474 src/testdir/test86.ok
--- a/src/testdir/test86.ok Sun Oct 06 17:46:56 2013 +0200
+++ b/src/testdir/test86.ok Fri Nov 01 22:58:23 2013 +0400
@@ -101,7 +101,10 @@
def
bar
jkl
+wopts iters equal: 1
+bopts iters equal: 1
>>> paste
+ g/w/b:1/0/0
p/gopts1: False
p/wopts1! KeyError
inv: 2! KeyError
@@ -122,6 +125,7 @@
W: 1:1 2:1 3:1 4:1
B: 1:1 2:1 3:1 4:1
>>> previewheight
+ g/w/b:1/0/0
p/gopts1: 12
inv: 'a'! TypeError
p/wopts1! KeyError
@@ -143,6 +147,7 @@
W: 1:5 2:5 3:5 4:5
B: 1:5 2:5 3:5 4:5
>>> operatorfunc
+ g/w/b:1/0/0
p/gopts1: ''
inv: 2! TypeError
p/wopts1! KeyError
@@ -164,6 +169,7 @@
W: 1:'A' 2:'A' 3:'A' 4:'A'
B: 1:'A' 2:'A' 3:'A' 4:'A'
>>> number
+ g/w/b:0/1/0
p/gopts1! KeyError
inv: 0! KeyError
gopts1! KeyError
@@ -182,6 +188,7 @@
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
>>> numberwidth
+ g/w/b:0/1/0
p/gopts1! KeyError
inv: -100! KeyError
gopts1! KeyError
@@ -201,6 +208,7 @@
W: 1:3 2:5 3:2 4:8
B: 1:3 2:5 3:2 4:8
>>> colorcolumn
+ g/w/b:0/1/0
p/gopts1! KeyError
inv: 'abc4'! KeyError
gopts1! KeyError
@@ -220,6 +228,7 @@
W: 1:'+2' 2:'+3' 3:'+1' 4:''
B: 1:'+2' 2:'+3' 3:'+1' 4:''
>>> statusline
+ g/w/b:1/1/0
p/gopts1: ''
inv: 0! TypeError
p/wopts1: None
@@ -237,6 +246,7 @@
W: 1:'2' 2:'1' 3:'1' 4:'1'
B: 1:'2' 2:'1' 3:'1' 4:'1'
>>> autoindent
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -255,6 +265,7 @@
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> shiftwidth
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 3! KeyError
gopts1! KeyError
@@ -273,6 +284,7 @@
W: 1:0 2:2 3:8 4:1
B: 1:0 2:2 3:8 4:1
>>> omnifunc
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 1! KeyError
gopts1! KeyError
@@ -292,6 +304,7 @@
W: 1:'A' 2:'B' 3:'' 4:'C'
B: 1:'A' 2:'B' 3:'' 4:'C'
>>> preserveindent
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -310,6 +323,7 @@
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> path
+ g/w/b:1/0/1
p/gopts1: '.,..,,'
inv: 0! TypeError
p/wopts1! KeyError
diff -r 92c9748e0ccb -r f332d6dfb474 src/testdir/test87.in
--- a/src/testdir/test87.in Sun Oct 06 17:46:56 2013 +0200
+++ b/src/testdir/test87.in Fri Nov 01 22:58:23 2013 +0400
@@ -416,6 +416,11 @@
:py3 bopts1=vim.buffers[vim.bindeval("g:bufs")[2]].options
:py3 bopts2=vim.buffers[vim.bindeval("g:bufs")[1]].options
:py3 bopts3=vim.buffers[vim.bindeval("g:bufs")[0]].options
+:$put ='wopts iters equal: '.py3eval('list(wopts1) == list(wopts2)')
+:$put ='bopts iters equal: '.py3eval('list(bopts1) == list(bopts2)')
+:py3 gset=set(iter(gopts1))
+:py3 wset=set(iter(wopts1))
+:py3 bset=set(iter(bopts1))
:set path=.,..,,
:let lst=[]
:let lst+=[['paste', 1, 0, 1, 2, 1, 1, 0
]]
@@ -446,6 +451,7 @@
: py3 oval3=bool(oval3)
: endif
: put ='>>> '.oname
+: $put =' g/w/b:'.py3eval('oname in gset').'/'.py3eval('oname in
wset').'/'.py3eval('oname in bset')
: for v in ['gopts1', 'wopts1', 'bopts1']
: try
: put =' p/'.v.': '.Ev('repr('.v.'['''.oname.'''])')
diff -r 92c9748e0ccb -r f332d6dfb474 src/testdir/test87.ok
--- a/src/testdir/test87.ok Sun Oct 06 17:46:56 2013 +0200
+++ b/src/testdir/test87.ok Fri Nov 01 22:58:23 2013 +0400
@@ -90,7 +90,10 @@
def
bar
jkl
+wopts iters equal: 1
+bopts iters equal: 1
>>> paste
+ g/w/b:1/0/0
p/gopts1: False
p/wopts1! KeyError
inv: 2! KeyError
@@ -111,6 +114,7 @@
W: 1:1 2:1 3:1 4:1
B: 1:1 2:1 3:1 4:1
>>> previewheight
+ g/w/b:1/0/0
p/gopts1: 12
inv: 'a'! TypeError
p/wopts1! KeyError
@@ -132,6 +136,7 @@
W: 1:5 2:5 3:5 4:5
B: 1:5 2:5 3:5 4:5
>>> operatorfunc
+ g/w/b:1/0/0
p/gopts1: b''
inv: 2! TypeError
p/wopts1! KeyError
@@ -153,6 +158,7 @@
W: 1:'A' 2:'A' 3:'A' 4:'A'
B: 1:'A' 2:'A' 3:'A' 4:'A'
>>> number
+ g/w/b:0/1/0
p/gopts1! KeyError
inv: 0! KeyError
gopts1! KeyError
@@ -171,6 +177,7 @@
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
>>> numberwidth
+ g/w/b:0/1/0
p/gopts1! KeyError
inv: -100! KeyError
gopts1! KeyError
@@ -190,6 +197,7 @@
W: 1:3 2:5 3:2 4:8
B: 1:3 2:5 3:2 4:8
>>> colorcolumn
+ g/w/b:0/1/0
p/gopts1! KeyError
inv: 'abc4'! KeyError
gopts1! KeyError
@@ -209,6 +217,7 @@
W: 1:'+2' 2:'+3' 3:'+1' 4:''
B: 1:'+2' 2:'+3' 3:'+1' 4:''
>>> statusline
+ g/w/b:1/1/0
p/gopts1: b''
inv: 0! TypeError
p/wopts1: None
@@ -226,6 +235,7 @@
W: 1:'2' 2:'1' 3:'1' 4:'1'
B: 1:'2' 2:'1' 3:'1' 4:'1'
>>> autoindent
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -244,6 +254,7 @@
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> shiftwidth
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 3! KeyError
gopts1! KeyError
@@ -262,6 +273,7 @@
W: 1:0 2:2 3:8 4:1
B: 1:0 2:2 3:8 4:1
>>> omnifunc
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 1! KeyError
gopts1! KeyError
@@ -281,6 +293,7 @@
W: 1:'A' 2:'B' 3:'' 4:'C'
B: 1:'A' 2:'B' 3:'' 4:'C'
>>> preserveindent
+ g/w/b:0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -299,6 +312,7 @@
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> path
+ g/w/b:1/0/1
p/gopts1: b'.,..,,'
inv: 0! TypeError
p/wopts1! KeyError
diff -r 92c9748e0ccb -r f332d6dfb474 src/vim.h
--- a/src/vim.h Sun Oct 06 17:46:56 2013 +0200
+++ b/src/vim.h Fri Nov 01 22:58:23 2013 +0400
@@ -2239,6 +2239,7 @@
#define SOPT_BUF 0x20 /* Option has buffer-local value */
#define SOPT_UNSET 0x40 /* Option does not have local value set */
+/* Option types for various functions in option.c */
#define SREQ_GLOBAL 0 /* Request global option */
#define SREQ_WIN 1 /* Request window-local option */
#define SREQ_BUF 2 /* Request buffer-local option */
# HG changeset patch
# User ZyX <[email protected]>
# Date 1383333254 -14400
# Fri Nov 01 23:14:14 2013 +0400
# Branch python-.options
# Node ID 30090cbe7eee7d41031a85fc4680fde51805efaf
# Parent f332d6dfb4749c7fc7f1f4961b8e817ce3cba46b
Add support for “if 'arabic' in vim.options”
diff -r f332d6dfb474 -r 30090cbe7eee src/if_py_both.h
--- a/src/if_py_both.h Fri Nov 01 22:58:23 2013 +0400
+++ b/src/if_py_both.h Fri Nov 01 23:14:14 2013 +0400
@@ -2830,6 +2830,33 @@
}
}
+ static int
+OptionsContains(OptionsObject *self, PyObject *keyObject)
+{
+ char_u *key;
+ PyObject *todecref;
+
+ if (!(key = StringToChars(keyObject, &todecref)))
+ return -1;
+
+ if (*key == NUL)
+ {
+ Py_XDECREF(todecref);
+ return 0;
+ }
+
+ if (get_option_value_strict(key, NULL, NULL, self->opt_type, NULL))
+ {
+ Py_XDECREF(todecref);
+ return 1;
+ }
+ else
+ {
+ Py_XDECREF(todecref);
+ return 0;
+ }
+}
+
typedef struct
{
void *lastoption;
@@ -3023,6 +3050,19 @@
return ret;
}
+static PySequenceMethods OptionsAsSeq = {
+ 0, /* sq_length */
+ 0, /* sq_concat */
+ 0, /* sq_repeat */
+ 0, /* sq_item */
+ 0, /* sq_slice */
+ 0, /* sq_ass_item */
+ 0, /* sq_ass_slice */
+ (objobjproc) OptionsContains, /* sq_contains */
+ 0, /* sq_inplace_concat */
+ 0, /* sq_inplace_repeat */
+};
+
static PyMappingMethods OptionsAsMapping = {
(lenfunc) NULL,
(binaryfunc) OptionsItem,
@@ -5913,6 +5953,7 @@
vim_memset(&OptionsType, 0, sizeof(OptionsType));
OptionsType.tp_name = "vim.options";
OptionsType.tp_basicsize = sizeof(OptionsObject);
+ OptionsType.tp_as_sequence = &OptionsAsSeq;
OptionsType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC;
OptionsType.tp_doc = "object for manipulating options";
OptionsType.tp_iter = (getiterfunc)OptionsIter;
diff -r f332d6dfb474 -r 30090cbe7eee src/testdir/test86.in
--- a/src/testdir/test86.in Fri Nov 01 22:58:23 2013 +0400
+++ b/src/testdir/test86.in Fri Nov 01 23:14:14 2013 +0400
@@ -485,6 +485,7 @@
: endif
: put ='>>> '.oname
: $put =' g/w/b:'.pyeval('oname in gset').'/'.pyeval('oname in
wset').'/'.pyeval('oname in bset')
+: $put =' g/w/b (in):'.pyeval('oname in gopts1').'/'.pyeval('oname in
wopts1').'/'.pyeval('oname in bopts1')
: for v in ['gopts1', 'wopts1', 'bopts1']
: try
: put =' p/'.v.': '.Ev('repr('.v.'['''.oname.'''])')
diff -r f332d6dfb474 -r 30090cbe7eee src/testdir/test86.ok
--- a/src/testdir/test86.ok Fri Nov 01 22:58:23 2013 +0400
+++ b/src/testdir/test86.ok Fri Nov 01 23:14:14 2013 +0400
@@ -105,6 +105,7 @@
bopts iters equal: 1
>>> paste
g/w/b:1/0/0
+ g/w/b (in):1/0/0
p/gopts1: False
p/wopts1! KeyError
inv: 2! KeyError
@@ -126,6 +127,7 @@
B: 1:1 2:1 3:1 4:1
>>> previewheight
g/w/b:1/0/0
+ g/w/b (in):1/0/0
p/gopts1: 12
inv: 'a'! TypeError
p/wopts1! KeyError
@@ -148,6 +150,7 @@
B: 1:5 2:5 3:5 4:5
>>> operatorfunc
g/w/b:1/0/0
+ g/w/b (in):1/0/0
p/gopts1: ''
inv: 2! TypeError
p/wopts1! KeyError
@@ -170,6 +173,7 @@
B: 1:'A' 2:'A' 3:'A' 4:'A'
>>> number
g/w/b:0/1/0
+ g/w/b (in):0/1/0
p/gopts1! KeyError
inv: 0! KeyError
gopts1! KeyError
@@ -189,6 +193,7 @@
B: 1:1 2:1 3:0 4:0
>>> numberwidth
g/w/b:0/1/0
+ g/w/b (in):0/1/0
p/gopts1! KeyError
inv: -100! KeyError
gopts1! KeyError
@@ -209,6 +214,7 @@
B: 1:3 2:5 3:2 4:8
>>> colorcolumn
g/w/b:0/1/0
+ g/w/b (in):0/1/0
p/gopts1! KeyError
inv: 'abc4'! KeyError
gopts1! KeyError
@@ -229,6 +235,7 @@
B: 1:'+2' 2:'+3' 3:'+1' 4:''
>>> statusline
g/w/b:1/1/0
+ g/w/b (in):1/1/0
p/gopts1: ''
inv: 0! TypeError
p/wopts1: None
@@ -247,6 +254,7 @@
B: 1:'2' 2:'1' 3:'1' 4:'1'
>>> autoindent
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -266,6 +274,7 @@
B: 1:0 2:1 3:0 4:1
>>> shiftwidth
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 3! KeyError
gopts1! KeyError
@@ -285,6 +294,7 @@
B: 1:0 2:2 3:8 4:1
>>> omnifunc
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 1! KeyError
gopts1! KeyError
@@ -305,6 +315,7 @@
B: 1:'A' 2:'B' 3:'' 4:'C'
>>> preserveindent
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -324,6 +335,7 @@
B: 1:0 2:1 3:0 4:1
>>> path
g/w/b:1/0/1
+ g/w/b (in):1/0/1
p/gopts1: '.,..,,'
inv: 0! TypeError
p/wopts1! KeyError
diff -r f332d6dfb474 -r 30090cbe7eee src/testdir/test87.in
--- a/src/testdir/test87.in Fri Nov 01 22:58:23 2013 +0400
+++ b/src/testdir/test87.in Fri Nov 01 23:14:14 2013 +0400
@@ -452,6 +452,7 @@
: endif
: put ='>>> '.oname
: $put =' g/w/b:'.py3eval('oname in gset').'/'.py3eval('oname in
wset').'/'.py3eval('oname in bset')
+: $put =' g/w/b (in):'.py3eval('oname in gopts1').'/'.py3eval('oname in
wopts1').'/'.py3eval('oname in bopts1')
: for v in ['gopts1', 'wopts1', 'bopts1']
: try
: put =' p/'.v.': '.Ev('repr('.v.'['''.oname.'''])')
diff -r f332d6dfb474 -r 30090cbe7eee src/testdir/test87.ok
--- a/src/testdir/test87.ok Fri Nov 01 22:58:23 2013 +0400
+++ b/src/testdir/test87.ok Fri Nov 01 23:14:14 2013 +0400
@@ -94,6 +94,7 @@
bopts iters equal: 1
>>> paste
g/w/b:1/0/0
+ g/w/b (in):1/0/0
p/gopts1: False
p/wopts1! KeyError
inv: 2! KeyError
@@ -115,6 +116,7 @@
B: 1:1 2:1 3:1 4:1
>>> previewheight
g/w/b:1/0/0
+ g/w/b (in):1/0/0
p/gopts1: 12
inv: 'a'! TypeError
p/wopts1! KeyError
@@ -137,6 +139,7 @@
B: 1:5 2:5 3:5 4:5
>>> operatorfunc
g/w/b:1/0/0
+ g/w/b (in):1/0/0
p/gopts1: b''
inv: 2! TypeError
p/wopts1! KeyError
@@ -159,6 +162,7 @@
B: 1:'A' 2:'A' 3:'A' 4:'A'
>>> number
g/w/b:0/1/0
+ g/w/b (in):0/1/0
p/gopts1! KeyError
inv: 0! KeyError
gopts1! KeyError
@@ -178,6 +182,7 @@
B: 1:1 2:1 3:0 4:0
>>> numberwidth
g/w/b:0/1/0
+ g/w/b (in):0/1/0
p/gopts1! KeyError
inv: -100! KeyError
gopts1! KeyError
@@ -198,6 +203,7 @@
B: 1:3 2:5 3:2 4:8
>>> colorcolumn
g/w/b:0/1/0
+ g/w/b (in):0/1/0
p/gopts1! KeyError
inv: 'abc4'! KeyError
gopts1! KeyError
@@ -218,6 +224,7 @@
B: 1:'+2' 2:'+3' 3:'+1' 4:''
>>> statusline
g/w/b:1/1/0
+ g/w/b (in):1/1/0
p/gopts1: b''
inv: 0! TypeError
p/wopts1: None
@@ -236,6 +243,7 @@
B: 1:'2' 2:'1' 3:'1' 4:'1'
>>> autoindent
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -255,6 +263,7 @@
B: 1:0 2:1 3:0 4:1
>>> shiftwidth
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 3! KeyError
gopts1! KeyError
@@ -274,6 +283,7 @@
B: 1:0 2:2 3:8 4:1
>>> omnifunc
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 1! KeyError
gopts1! KeyError
@@ -294,6 +304,7 @@
B: 1:'A' 2:'B' 3:'' 4:'C'
>>> preserveindent
g/w/b:0/0/1
+ g/w/b (in):0/0/1
p/gopts1! KeyError
inv: 2! KeyError
gopts1! KeyError
@@ -313,6 +324,7 @@
B: 1:0 2:1 3:0 4:1
>>> path
g/w/b:1/0/1
+ g/w/b (in):1/0/1
p/gopts1: b'.,..,,'
inv: 0! TypeError
p/wopts1! KeyError
# HG changeset patch
# User ZyX <[email protected]>
# Date 1383334516 -14400
# Fri Nov 01 23:35:16 2013 +0400
# Branch python-.options
# Node ID 6d9e09170d734470f7526584de1a0a0acaadfd78
# Parent 30090cbe7eee7d41031a85fc4680fde51805efaf
Add failure tests
diff -r 30090cbe7eee -r 6d9e09170d73 src/testdir/test86.in
--- a/src/testdir/test86.in Fri Nov 01 23:14:14 2013 +0400
+++ b/src/testdir/test86.in Fri Nov 01 23:35:16 2013 +0400
@@ -1080,6 +1080,13 @@
ee('import failing')
vim.options['rtp'] = old_rtp
del old_rtp
+cb.append("> Options")
+cb.append(">> OptionsItem")
+ee('vim.options["abcQ"]')
+ee('vim.options[""]')
+stringtochars_test('vim.options[%s]')
+cb.append(">> OptionsContains")
+stringtochars_test('%s in vim.options')
cb.append("> Dictionary")
cb.append(">> DictionaryConstructor")
ee('vim.Dictionary("abcI")')
diff -r 30090cbe7eee -r 6d9e09170d73 src/testdir/test86.ok
--- a/src/testdir/test86.ok Fri Nov 01 23:14:14 2013 +0400
+++ b/src/testdir/test86.ok Fri Nov 01 23:35:16 2013 +0400
@@ -524,6 +524,21 @@
import xxx_no_such_module_xxx:ImportError:('No module named
xxx_no_such_module_xxx',)
import failing_import:ImportError:('No module named failing_import',)
import failing:NotImplementedError:()
+> Options
+>> OptionsItem
+vim.options["abcQ"]:KeyError:('abcQ',)
+vim.options[""]:ValueError:('empty keys are not allowed',)
+>>> Testing StringToChars using vim.options[%s]
+vim.options[1]:TypeError:('expected str() or unicode() instance, but got int',)
+vim.options[u"\0"]:TypeError:('expected string without null bytes',)
+vim.options["\0"]:TypeError:('expected string without null bytes',)
+<<< Finished
+>> OptionsContains
+>>> Testing StringToChars using %s in vim.options
+1 in vim.options:TypeError:('expected str() or unicode() instance, but got
int',)
+u"\0" in vim.options:TypeError:('expected string without null bytes',)
+"\0" in vim.options:TypeError:('expected string without null bytes',)
+<<< Finished
> Dictionary
>> DictionaryConstructor
vim.Dictionary("abcI"):ValueError:('expected sequence element of size 2, but
got sequence of size 1',)
diff -r 30090cbe7eee -r 6d9e09170d73 src/testdir/test87.in
--- a/src/testdir/test87.in Fri Nov 01 23:14:14 2013 +0400
+++ b/src/testdir/test87.in Fri Nov 01 23:35:16 2013 +0400
@@ -1031,6 +1031,13 @@
ee('import failing')
vim.options['rtp'] = old_rtp
del old_rtp
+cb.append("> Options")
+cb.append(">> OptionsItem")
+ee('vim.options["abcQ"]')
+ee('vim.options[""]')
+stringtochars_test('vim.options[%s]')
+cb.append(">> OptionsContains")
+stringtochars_test('%s in vim.options')
cb.append("> Dictionary")
cb.append(">> DictionaryConstructor")
ee('vim.Dictionary("abcI")')
diff -r 30090cbe7eee -r 6d9e09170d73 src/testdir/test87.ok
--- a/src/testdir/test87.ok Fri Nov 01 23:14:14 2013 +0400
+++ b/src/testdir/test87.ok Fri Nov 01 23:35:16 2013 +0400
@@ -513,6 +513,21 @@
import xxx_no_such_module_xxx:(<class 'ImportError'>, ImportError('No module
named xxx_no_such_module_xxx',))
import failing_import:(<class 'ImportError'>, ImportError('No module named
failing_import',))
import failing:(<class 'NotImplementedError'>, NotImplementedError())
+> Options
+>> OptionsItem
+vim.options["abcQ"]:(<class 'KeyError'>, KeyError('abcQ',))
+vim.options[""]:(<class 'ValueError'>, ValueError('empty keys are not
allowed',))
+>>> Testing StringToChars using vim.options[%s]
+vim.options[1]:(<class 'TypeError'>, TypeError('expected bytes() or str()
instance, but got int',))
+vim.options[b"\0"]:(<class 'TypeError'>, TypeError('expected bytes with no
null',))
+vim.options["\0"]:(<class 'TypeError'>, TypeError('expected bytes with no
null',))
+<<< Finished
+>> OptionsContains
+>>> Testing StringToChars using %s in vim.options
+1 in vim.options:(<class 'TypeError'>, TypeError('expected bytes() or str()
instance, but got int',))
+b"\0" in vim.options:(<class 'TypeError'>, TypeError('expected bytes with no
null',))
+"\0" in vim.options:(<class 'TypeError'>, TypeError('expected bytes with no
null',))
+<<< Finished
> Dictionary
>> DictionaryConstructor
vim.Dictionary("abcI"):(<class 'ValueError'>, ValueError('expected sequence
element of size 2, but got sequence of size 1',))
# HG changeset patch
# User ZyX <[email protected]>
# Date 1383389187 -14400
# Sat Nov 02 14:46:27 2013 +0400
# Branch python-.options
# Node ID 0e806d83e81fdce4517e98ab55b66d8afac216bf
# Parent 6d9e09170d734470f7526584de1a0a0acaadfd78
Fix comment: it did not describe all situations when zero was returned
diff -r 6d9e09170d73 -r 0e806d83e81f src/option.c
--- a/src/option.c Fri Nov 01 23:35:16 2013 +0400
+++ b/src/option.c Sat Nov 02 14:46:27 2013 +0400
@@ -8833,7 +8833,8 @@
* opt_type). Uses
*
* Returned flags:
- * 0 hidden or unknown option
+ * 0 hidden or unknown option, also option that does not have requested
+ * type (see SREQ_* in vim.h)
* see SOPT_* in vim.h for other flags
*
* Possible opt_type values: see SREQ_* in vim.h
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.