3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.152
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.152
3ef2ca
Problem:    Python: Cannot iterate over options.
3ef2ca
Solution:   Add options iterator. (ZyX)
3ef2ca
Files:	    src/if_py_both.h, src/option.c, src/proto/option.pro,
3ef2ca
	    src/testdir/test86.in, src/testdir/test86.ok,
3ef2ca
	    src/testdir/test87.in, src/testdir/test87.ok, src/vim.h
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.151/src/if_py_both.h	2014-01-14 16:36:40.000000000 +0100
3ef2ca
--- src/if_py_both.h	2014-01-14 16:51:30.000000000 +0100
3ef2ca
***************
3ef2ca
*** 2949,2958 ****
3ef2ca
  typedef struct
3ef2ca
  {
3ef2ca
      PyObject_HEAD
3ef2ca
!     int opt_type;
3ef2ca
!     void *from;
3ef2ca
!     checkfun Check;
3ef2ca
!     PyObject *fromObj;
3ef2ca
  } OptionsObject;
3ef2ca
  
3ef2ca
      static int
3ef2ca
--- 2949,2958 ----
3ef2ca
  typedef struct
3ef2ca
  {
3ef2ca
      PyObject_HEAD
3ef2ca
!     int		opt_type;
3ef2ca
!     void	*from;
3ef2ca
!     checkfun	Check;
3ef2ca
!     PyObject	*fromObj;
3ef2ca
  } OptionsObject;
3ef2ca
  
3ef2ca
      static int
3ef2ca
***************
3ef2ca
*** 3072,3077 ****
3ef2ca
--- 3072,3140 ----
3ef2ca
  }
3ef2ca
  
3ef2ca
      static int
3ef2ca
+ OptionsContains(OptionsObject *self, PyObject *keyObject)
3ef2ca
+ {
3ef2ca
+     char_u	*key;
3ef2ca
+     PyObject	*todecref;
3ef2ca
+ 
3ef2ca
+     if (!(key = StringToChars(keyObject, &todecref)))
3ef2ca
+ 	return -1;
3ef2ca
+ 
3ef2ca
+     if (*key == NUL)
3ef2ca
+     {
3ef2ca
+ 	Py_XDECREF(todecref);
3ef2ca
+ 	return 0;
3ef2ca
+     }
3ef2ca
+ 
3ef2ca
+     if (get_option_value_strict(key, NULL, NULL, self->opt_type, NULL))
3ef2ca
+     {
3ef2ca
+ 	Py_XDECREF(todecref);
3ef2ca
+ 	return 1;
3ef2ca
+     }
3ef2ca
+     else
3ef2ca
+     {
3ef2ca
+ 	Py_XDECREF(todecref);
3ef2ca
+ 	return 0;
3ef2ca
+     }
3ef2ca
+ }
3ef2ca
+ 
3ef2ca
+ typedef struct
3ef2ca
+ {
3ef2ca
+     void	*lastoption;
3ef2ca
+     int		opt_type;
3ef2ca
+ } optiterinfo_T;
3ef2ca
+ 
3ef2ca
+     static PyObject *
3ef2ca
+ OptionsIterNext(optiterinfo_T **oii)
3ef2ca
+ {
3ef2ca
+     char_u	*name;
3ef2ca
+ 
3ef2ca
+     if ((name = option_iter_next(&((*oii)->lastoption), (*oii)->opt_type)))
3ef2ca
+ 	return PyString_FromString((char *)name);
3ef2ca
+ 
3ef2ca
+     return NULL;
3ef2ca
+ }
3ef2ca
+ 
3ef2ca
+     static PyObject *
3ef2ca
+ OptionsIter(OptionsObject *self)
3ef2ca
+ {
3ef2ca
+     optiterinfo_T	*oii;
3ef2ca
+ 
3ef2ca
+     if (!(oii = PyMem_New(optiterinfo_T, 1)))
3ef2ca
+     {
3ef2ca
+ 	PyErr_NoMemory();
3ef2ca
+ 	return NULL;
3ef2ca
+     }
3ef2ca
+ 
3ef2ca
+     oii->opt_type = self->opt_type;
3ef2ca
+     oii->lastoption = NULL;
3ef2ca
+ 
3ef2ca
+     return IterNew(oii,
3ef2ca
+ 	    (destructorfun) PyMem_Free, (nextfun) OptionsIterNext,
3ef2ca
+ 	    NULL, NULL);
3ef2ca
+ }
3ef2ca
+ 
3ef2ca
+     static int
3ef2ca
  set_option_value_err(char_u *key, int numval, char_u *stringval, int opt_flags)
3ef2ca
  {
3ef2ca
      char_u	*errmsg;
3ef2ca
***************
3ef2ca
*** 3231,3236 ****
3ef2ca
--- 3294,3312 ----
3ef2ca
      return ret;
3ef2ca
  }
3ef2ca
  
3ef2ca
+ static PySequenceMethods OptionsAsSeq = {
3ef2ca
+     0,					/* sq_length */
3ef2ca
+     0,					/* sq_concat */
3ef2ca
+     0,					/* sq_repeat */
3ef2ca
+     0,					/* sq_item */
3ef2ca
+     0,					/* sq_slice */
3ef2ca
+     0,					/* sq_ass_item */
3ef2ca
+     0,					/* sq_ass_slice */
3ef2ca
+     (objobjproc) OptionsContains,	/* sq_contains */
3ef2ca
+     0,					/* sq_inplace_concat */
3ef2ca
+     0,					/* sq_inplace_repeat */
3ef2ca
+ };
3ef2ca
+ 
3ef2ca
  static PyMappingMethods OptionsAsMapping = {
3ef2ca
      (lenfunc)       NULL,
3ef2ca
      (binaryfunc)    OptionsItem,
3ef2ca
***************
3ef2ca
*** 6121,6128 ****
3ef2ca
--- 6197,6206 ----
3ef2ca
      vim_memset(&OptionsType, 0, sizeof(OptionsType));
3ef2ca
      OptionsType.tp_name = "vim.options";
3ef2ca
      OptionsType.tp_basicsize = sizeof(OptionsObject);
3ef2ca
+     OptionsType.tp_as_sequence = &OptionsAsSeq;
3ef2ca
      OptionsType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC;
3ef2ca
      OptionsType.tp_doc = "object for manipulating options";
3ef2ca
+     OptionsType.tp_iter = (getiterfunc)OptionsIter;
3ef2ca
      OptionsType.tp_as_mapping = &OptionsAsMapping;
3ef2ca
      OptionsType.tp_dealloc = (destructor)OptionsDestructor;
3ef2ca
      OptionsType.tp_traverse = (traverseproc)OptionsTraverse;
3ef2ca
*** ../vim-7.4.151/src/option.c	2013-11-12 04:43:57.000000000 +0100
3ef2ca
--- src/option.c	2014-01-14 16:50:52.000000000 +0100
3ef2ca
***************
3ef2ca
*** 8861,8867 ****
3ef2ca
  }
3ef2ca
  #endif
3ef2ca
  
3ef2ca
! #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
3ef2ca
  /*
3ef2ca
   * Returns the option attributes and its value. Unlike the above function it
3ef2ca
   * will return either global value or local value of the option depending on
3ef2ca
--- 8861,8867 ----
3ef2ca
  }
3ef2ca
  #endif
3ef2ca
  
3ef2ca
! #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
3ef2ca
  /*
3ef2ca
   * Returns the option attributes and its value. Unlike the above function it
3ef2ca
   * will return either global value or local value of the option depending on
3ef2ca
***************
3ef2ca
*** 8874,8880 ****
3ef2ca
   * opt_type). Uses
3ef2ca
   *
3ef2ca
   * Returned flags:
3ef2ca
!  *       0 hidden or unknown option
3ef2ca
   *  see SOPT_* in vim.h for other flags
3ef2ca
   *
3ef2ca
   * Possible opt_type values: see SREQ_* in vim.h
3ef2ca
--- 8874,8881 ----
3ef2ca
   * opt_type). Uses
3ef2ca
   *
3ef2ca
   * Returned flags:
3ef2ca
!  *       0 hidden or unknown option, also option that does not have requested 
3ef2ca
!  *         type (see SREQ_* in vim.h)
3ef2ca
   *  see SOPT_* in vim.h for other flags
3ef2ca
   *
3ef2ca
   * Possible opt_type values: see SREQ_* in vim.h
3ef2ca
***************
3ef2ca
*** 8997,9002 ****
3ef2ca
--- 8998,9065 ----
3ef2ca
  
3ef2ca
      return r;
3ef2ca
  }
3ef2ca
+ 
3ef2ca
+ /*
3ef2ca
+  * Iterate over options. First argument is a pointer to a pointer to a structure 
3ef2ca
+  * inside options[] array, second is option type like in the above function.
3ef2ca
+  *
3ef2ca
+  * If first argument points to NULL it is assumed that iteration just started 
3ef2ca
+  * and caller needs the very first value.
3ef2ca
+  * If first argument points to the end marker function returns NULL and sets 
3ef2ca
+  * first argument to NULL.
3ef2ca
+  *
3ef2ca
+  * Returns full option name for current option on each call.
3ef2ca
+  */
3ef2ca
+     char_u *
3ef2ca
+ option_iter_next(option, opt_type)
3ef2ca
+     void	**option;
3ef2ca
+     int		opt_type;
3ef2ca
+ {
3ef2ca
+     struct vimoption	*ret = NULL;
3ef2ca
+     do
3ef2ca
+     {
3ef2ca
+ 	if (*option == NULL)
3ef2ca
+ 	    *option = (void *) options;
3ef2ca
+ 	else if (((struct vimoption *) (*option))->fullname == NULL)
3ef2ca
+ 	{
3ef2ca
+ 	    *option = NULL;
3ef2ca
+ 	    return NULL;
3ef2ca
+ 	}
3ef2ca
+ 	else
3ef2ca
+ 	    *option = (void *) (((struct vimoption *) (*option)) + 1);
3ef2ca
+ 
3ef2ca
+ 	ret = ((struct vimoption *) (*option));
3ef2ca
+ 
3ef2ca
+ 	/* Hidden option */
3ef2ca
+ 	if (ret->var == NULL)
3ef2ca
+ 	{
3ef2ca
+ 	    ret = NULL;
3ef2ca
+ 	    continue;
3ef2ca
+ 	}
3ef2ca
+ 
3ef2ca
+ 	switch (opt_type)
3ef2ca
+ 	{
3ef2ca
+ 	    case SREQ_GLOBAL:
3ef2ca
+ 		if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
3ef2ca
+ 		    ret = NULL;
3ef2ca
+ 		break;
3ef2ca
+ 	    case SREQ_BUF:
3ef2ca
+ 		if (!(ret->indir & PV_BUF))
3ef2ca
+ 		    ret = NULL;
3ef2ca
+ 		break;
3ef2ca
+ 	    case SREQ_WIN:
3ef2ca
+ 		if (!(ret->indir & PV_WIN))
3ef2ca
+ 		    ret = NULL;
3ef2ca
+ 		break;
3ef2ca
+ 	    default:
3ef2ca
+ 		EMSG2(_(e_intern2), "option_iter_next()");
3ef2ca
+ 		return NULL;
3ef2ca
+ 	}
3ef2ca
+     }
3ef2ca
+     while (ret == NULL);
3ef2ca
+ 
3ef2ca
+     return (char_u *)ret->fullname;
3ef2ca
+ }
3ef2ca
  #endif
3ef2ca
  
3ef2ca
  /*
3ef2ca
*** ../vim-7.4.151/src/proto/option.pro	2013-11-05 07:12:59.000000000 +0100
3ef2ca
--- src/proto/option.pro	2014-01-14 16:51:41.000000000 +0100
3ef2ca
***************
3ef2ca
*** 23,28 ****
3ef2ca
--- 23,29 ----
3ef2ca
  char_u *check_stl_option __ARGS((char_u *s));
3ef2ca
  int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval, int opt_flags));
3ef2ca
  int get_option_value_strict __ARGS((char_u *name, long *numval, char_u **stringval, int opt_type, void *from));
3ef2ca
+ char_u *option_iter_next __ARGS((void **option, int opt_type));
3ef2ca
  char_u *set_option_value __ARGS((char_u *name, long number, char_u *string, int opt_flags));
3ef2ca
  char_u *get_term_code __ARGS((char_u *tname));
3ef2ca
  char_u *get_highlight_default __ARGS((void));
3ef2ca
*** ../vim-7.4.151/src/testdir/test86.in	2014-01-14 16:36:40.000000000 +0100
3ef2ca
--- src/testdir/test86.in	2014-01-14 16:49:10.000000000 +0100
3ef2ca
***************
3ef2ca
*** 506,511 ****
3ef2ca
--- 506,516 ----
3ef2ca
  :py bopts1=vim.buffers[vim.bindeval("g:bufs")[2]].options
3ef2ca
  :py bopts2=vim.buffers[vim.bindeval("g:bufs")[1]].options
3ef2ca
  :py bopts3=vim.buffers[vim.bindeval("g:bufs")[0]].options
3ef2ca
+ :$put ='wopts iters equal: '.pyeval('list(wopts1) == list(wopts2)')
3ef2ca
+ :$put ='bopts iters equal: '.pyeval('list(bopts1) == list(bopts2)')
3ef2ca
+ :py gset=set(iter(gopts1))
3ef2ca
+ :py wset=set(iter(wopts1))
3ef2ca
+ :py bset=set(iter(bopts1))
3ef2ca
  :set path=.,..,,
3ef2ca
  :let lst=[]
3ef2ca
  :let lst+=[['paste',          1,     0,     1,     2,      1,    1,      0    ]]
3ef2ca
***************
3ef2ca
*** 536,541 ****
3ef2ca
--- 541,548 ----
3ef2ca
  :       py oval3=bool(oval3)
3ef2ca
  :   endif
3ef2ca
  :   put ='>>> '.oname
3ef2ca
+ :   $put ='  g/w/b:'.pyeval('oname in gset').'/'.pyeval('oname in wset').'/'.pyeval('oname in bset')
3ef2ca
+ :   $put ='  g/w/b (in):'.pyeval('oname in gopts1').'/'.pyeval('oname in wopts1').'/'.pyeval('oname in bopts1')
3ef2ca
  :   for v in ['gopts1', 'wopts1', 'bopts1']
3ef2ca
  :       try
3ef2ca
  :           put ='  p/'.v.': '.Ev('repr('.v.'['''.oname.'''])')
3ef2ca
***************
3ef2ca
*** 1122,1127 ****
3ef2ca
--- 1129,1141 ----
3ef2ca
  ee('import failing')
3ef2ca
  vim.options['rtp'] = old_rtp
3ef2ca
  del old_rtp
3ef2ca
+ cb.append("> Options")
3ef2ca
+ cb.append(">> OptionsItem")
3ef2ca
+ ee('vim.options["abcQ"]')
3ef2ca
+ ee('vim.options[""]')
3ef2ca
+ stringtochars_test('vim.options[%s]')
3ef2ca
+ cb.append(">> OptionsContains")
3ef2ca
+ stringtochars_test('%s in vim.options')
3ef2ca
  cb.append("> Dictionary")
3ef2ca
  cb.append(">> DictionaryConstructor")
3ef2ca
  ee('vim.Dictionary("abcI")')
3ef2ca
*** ../vim-7.4.151/src/testdir/test86.ok	2014-01-14 16:36:40.000000000 +0100
3ef2ca
--- src/testdir/test86.ok	2014-01-14 16:49:10.000000000 +0100
3ef2ca
***************
3ef2ca
*** 112,118 ****
3ef2ca
--- 112,122 ----
3ef2ca
  def
3ef2ca
  bar
3ef2ca
  jkl
3ef2ca
+ wopts iters equal: 1
3ef2ca
+ bopts iters equal: 1
3ef2ca
  >>> paste
3ef2ca
+   g/w/b:1/0/0
3ef2ca
+   g/w/b (in):1/0/0
3ef2ca
    p/gopts1: False
3ef2ca
    p/wopts1! KeyError
3ef2ca
    inv: 2! KeyError
3ef2ca
***************
3ef2ca
*** 133,138 ****
3ef2ca
--- 137,144 ----
3ef2ca
    W: 1:1 2:1 3:1 4:1
3ef2ca
    B: 1:1 2:1 3:1 4:1
3ef2ca
  >>> previewheight
3ef2ca
+   g/w/b:1/0/0
3ef2ca
+   g/w/b (in):1/0/0
3ef2ca
    p/gopts1: 12
3ef2ca
    inv: 'a'! TypeError
3ef2ca
    p/wopts1! KeyError
3ef2ca
***************
3ef2ca
*** 154,159 ****
3ef2ca
--- 160,167 ----
3ef2ca
    W: 1:5 2:5 3:5 4:5
3ef2ca
    B: 1:5 2:5 3:5 4:5
3ef2ca
  >>> operatorfunc
3ef2ca
+   g/w/b:1/0/0
3ef2ca
+   g/w/b (in):1/0/0
3ef2ca
    p/gopts1: ''
3ef2ca
    inv: 2! TypeError
3ef2ca
    p/wopts1! KeyError
3ef2ca
***************
3ef2ca
*** 175,180 ****
3ef2ca
--- 183,190 ----
3ef2ca
    W: 1:'A' 2:'A' 3:'A' 4:'A'
3ef2ca
    B: 1:'A' 2:'A' 3:'A' 4:'A'
3ef2ca
  >>> number
3ef2ca
+   g/w/b:0/1/0
3ef2ca
+   g/w/b (in):0/1/0
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 0! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 193,198 ****
3ef2ca
--- 203,210 ----
3ef2ca
    W: 1:1 2:1 3:0 4:0
3ef2ca
    B: 1:1 2:1 3:0 4:0
3ef2ca
  >>> numberwidth
3ef2ca
+   g/w/b:0/1/0
3ef2ca
+   g/w/b (in):0/1/0
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: -100! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 212,217 ****
3ef2ca
--- 224,231 ----
3ef2ca
    W: 1:3 2:5 3:2 4:8
3ef2ca
    B: 1:3 2:5 3:2 4:8
3ef2ca
  >>> colorcolumn
3ef2ca
+   g/w/b:0/1/0
3ef2ca
+   g/w/b (in):0/1/0
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 'abc4'! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 231,236 ****
3ef2ca
--- 245,252 ----
3ef2ca
    W: 1:'+2' 2:'+3' 3:'+1' 4:''
3ef2ca
    B: 1:'+2' 2:'+3' 3:'+1' 4:''
3ef2ca
  >>> statusline
3ef2ca
+   g/w/b:1/1/0
3ef2ca
+   g/w/b (in):1/1/0
3ef2ca
    p/gopts1: ''
3ef2ca
    inv: 0! TypeError
3ef2ca
    p/wopts1: None
3ef2ca
***************
3ef2ca
*** 248,253 ****
3ef2ca
--- 264,271 ----
3ef2ca
    W: 1:'2' 2:'1' 3:'1' 4:'1'
3ef2ca
    B: 1:'2' 2:'1' 3:'1' 4:'1'
3ef2ca
  >>> autoindent
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 2! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 266,271 ****
3ef2ca
--- 284,291 ----
3ef2ca
    W: 1:0 2:1 3:0 4:1
3ef2ca
    B: 1:0 2:1 3:0 4:1
3ef2ca
  >>> shiftwidth
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 3! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 284,289 ****
3ef2ca
--- 304,311 ----
3ef2ca
    W: 1:0 2:2 3:8 4:1
3ef2ca
    B: 1:0 2:2 3:8 4:1
3ef2ca
  >>> omnifunc
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 1! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 303,308 ****
3ef2ca
--- 325,332 ----
3ef2ca
    W: 1:'A' 2:'B' 3:'' 4:'C'
3ef2ca
    B: 1:'A' 2:'B' 3:'' 4:'C'
3ef2ca
  >>> preserveindent
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 2! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 321,326 ****
3ef2ca
--- 345,352 ----
3ef2ca
    W: 1:0 2:1 3:0 4:1
3ef2ca
    B: 1:0 2:1 3:0 4:1
3ef2ca
  >>> path
3ef2ca
+   g/w/b:1/0/1
3ef2ca
+   g/w/b (in):1/0/1
3ef2ca
    p/gopts1: '.,..,,'
3ef2ca
    inv: 0! TypeError
3ef2ca
    p/wopts1! KeyError
3ef2ca
***************
3ef2ca
*** 509,514 ****
3ef2ca
--- 535,555 ----
3ef2ca
  import xxx_no_such_module_xxx:ImportError:('No module named xxx_no_such_module_xxx',)
3ef2ca
  import failing_import:ImportError:('No module named failing_import',)
3ef2ca
  import failing:NotImplementedError:()
3ef2ca
+ > Options
3ef2ca
+ >> OptionsItem
3ef2ca
+ vim.options["abcQ"]:KeyError:('abcQ',)
3ef2ca
+ vim.options[""]:ValueError:('empty keys are not allowed',)
3ef2ca
+ >>> Testing StringToChars using vim.options[%s]
3ef2ca
+ vim.options[1]:TypeError:('expected str() or unicode() instance, but got int',)
3ef2ca
+ vim.options[u"\0"]:TypeError:('expected string without null bytes',)
3ef2ca
+ vim.options["\0"]:TypeError:('expected string without null bytes',)
3ef2ca
+ <<< Finished
3ef2ca
+ >> OptionsContains
3ef2ca
+ >>> Testing StringToChars using %s in vim.options
3ef2ca
+ 1 in vim.options:TypeError:('expected str() or unicode() instance, but got int',)
3ef2ca
+ u"\0" in vim.options:TypeError:('expected string without null bytes',)
3ef2ca
+ "\0" in vim.options:TypeError:('expected string without null bytes',)
3ef2ca
+ <<< Finished
3ef2ca
  > Dictionary
3ef2ca
  >> DictionaryConstructor
3ef2ca
  vim.Dictionary("abcI"):ValueError:('expected sequence element of size 2, but got sequence of size 1',)
3ef2ca
*** ../vim-7.4.151/src/testdir/test87.in	2014-01-14 16:36:40.000000000 +0100
3ef2ca
--- src/testdir/test87.in	2014-01-14 16:49:10.000000000 +0100
3ef2ca
***************
3ef2ca
*** 503,508 ****
3ef2ca
--- 503,513 ----
3ef2ca
  :py3 bopts1=vim.buffers[vim.bindeval("g:bufs")[2]].options
3ef2ca
  :py3 bopts2=vim.buffers[vim.bindeval("g:bufs")[1]].options
3ef2ca
  :py3 bopts3=vim.buffers[vim.bindeval("g:bufs")[0]].options
3ef2ca
+ :$put ='wopts iters equal: '.py3eval('list(wopts1) == list(wopts2)')
3ef2ca
+ :$put ='bopts iters equal: '.py3eval('list(bopts1) == list(bopts2)')
3ef2ca
+ :py3 gset=set(iter(gopts1))
3ef2ca
+ :py3 wset=set(iter(wopts1))
3ef2ca
+ :py3 bset=set(iter(bopts1))
3ef2ca
  :set path=.,..,,
3ef2ca
  :let lst=[]
3ef2ca
  :let lst+=[['paste',          1,     0,     1,     2,      1,    1,      0    ]]
3ef2ca
***************
3ef2ca
*** 533,538 ****
3ef2ca
--- 538,545 ----
3ef2ca
  :       py3 oval3=bool(oval3)
3ef2ca
  :   endif
3ef2ca
  :   put ='>>> '.oname
3ef2ca
+ :   $put ='  g/w/b:'.py3eval('oname in gset').'/'.py3eval('oname in wset').'/'.py3eval('oname in bset')
3ef2ca
+ :   $put ='  g/w/b (in):'.py3eval('oname in gopts1').'/'.py3eval('oname in wopts1').'/'.py3eval('oname in bopts1')
3ef2ca
  :   for v in ['gopts1', 'wopts1', 'bopts1']
3ef2ca
  :       try
3ef2ca
  :           put ='  p/'.v.': '.Ev('repr('.v.'['''.oname.'''])')
3ef2ca
***************
3ef2ca
*** 1099,1104 ****
3ef2ca
--- 1106,1118 ----
3ef2ca
  ee('import failing')
3ef2ca
  vim.options['rtp'] = old_rtp
3ef2ca
  del old_rtp
3ef2ca
+ cb.append("> Options")
3ef2ca
+ cb.append(">> OptionsItem")
3ef2ca
+ ee('vim.options["abcQ"]')
3ef2ca
+ ee('vim.options[""]')
3ef2ca
+ stringtochars_test('vim.options[%s]')
3ef2ca
+ cb.append(">> OptionsContains")
3ef2ca
+ stringtochars_test('%s in vim.options')
3ef2ca
  cb.append("> Dictionary")
3ef2ca
  cb.append(">> DictionaryConstructor")
3ef2ca
  ee('vim.Dictionary("abcI")')
3ef2ca
*** ../vim-7.4.151/src/testdir/test87.ok	2014-01-14 16:36:40.000000000 +0100
3ef2ca
--- src/testdir/test87.ok	2014-01-14 16:49:10.000000000 +0100
3ef2ca
***************
3ef2ca
*** 112,118 ****
3ef2ca
--- 112,122 ----
3ef2ca
  def
3ef2ca
  bar
3ef2ca
  jkl
3ef2ca
+ wopts iters equal: 1
3ef2ca
+ bopts iters equal: 1
3ef2ca
  >>> paste
3ef2ca
+   g/w/b:1/0/0
3ef2ca
+   g/w/b (in):1/0/0
3ef2ca
    p/gopts1: False
3ef2ca
    p/wopts1! KeyError
3ef2ca
    inv: 2! KeyError
3ef2ca
***************
3ef2ca
*** 133,138 ****
3ef2ca
--- 137,144 ----
3ef2ca
    W: 1:1 2:1 3:1 4:1
3ef2ca
    B: 1:1 2:1 3:1 4:1
3ef2ca
  >>> previewheight
3ef2ca
+   g/w/b:1/0/0
3ef2ca
+   g/w/b (in):1/0/0
3ef2ca
    p/gopts1: 12
3ef2ca
    inv: 'a'! TypeError
3ef2ca
    p/wopts1! KeyError
3ef2ca
***************
3ef2ca
*** 154,159 ****
3ef2ca
--- 160,167 ----
3ef2ca
    W: 1:5 2:5 3:5 4:5
3ef2ca
    B: 1:5 2:5 3:5 4:5
3ef2ca
  >>> operatorfunc
3ef2ca
+   g/w/b:1/0/0
3ef2ca
+   g/w/b (in):1/0/0
3ef2ca
    p/gopts1: b''
3ef2ca
    inv: 2! TypeError
3ef2ca
    p/wopts1! KeyError
3ef2ca
***************
3ef2ca
*** 175,180 ****
3ef2ca
--- 183,190 ----
3ef2ca
    W: 1:'A' 2:'A' 3:'A' 4:'A'
3ef2ca
    B: 1:'A' 2:'A' 3:'A' 4:'A'
3ef2ca
  >>> number
3ef2ca
+   g/w/b:0/1/0
3ef2ca
+   g/w/b (in):0/1/0
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 0! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 193,198 ****
3ef2ca
--- 203,210 ----
3ef2ca
    W: 1:1 2:1 3:0 4:0
3ef2ca
    B: 1:1 2:1 3:0 4:0
3ef2ca
  >>> numberwidth
3ef2ca
+   g/w/b:0/1/0
3ef2ca
+   g/w/b (in):0/1/0
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: -100! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 212,217 ****
3ef2ca
--- 224,231 ----
3ef2ca
    W: 1:3 2:5 3:2 4:8
3ef2ca
    B: 1:3 2:5 3:2 4:8
3ef2ca
  >>> colorcolumn
3ef2ca
+   g/w/b:0/1/0
3ef2ca
+   g/w/b (in):0/1/0
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 'abc4'! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 231,236 ****
3ef2ca
--- 245,252 ----
3ef2ca
    W: 1:'+2' 2:'+3' 3:'+1' 4:''
3ef2ca
    B: 1:'+2' 2:'+3' 3:'+1' 4:''
3ef2ca
  >>> statusline
3ef2ca
+   g/w/b:1/1/0
3ef2ca
+   g/w/b (in):1/1/0
3ef2ca
    p/gopts1: b''
3ef2ca
    inv: 0! TypeError
3ef2ca
    p/wopts1: None
3ef2ca
***************
3ef2ca
*** 248,253 ****
3ef2ca
--- 264,271 ----
3ef2ca
    W: 1:'2' 2:'1' 3:'1' 4:'1'
3ef2ca
    B: 1:'2' 2:'1' 3:'1' 4:'1'
3ef2ca
  >>> autoindent
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 2! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 266,271 ****
3ef2ca
--- 284,291 ----
3ef2ca
    W: 1:0 2:1 3:0 4:1
3ef2ca
    B: 1:0 2:1 3:0 4:1
3ef2ca
  >>> shiftwidth
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 3! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 284,289 ****
3ef2ca
--- 304,311 ----
3ef2ca
    W: 1:0 2:2 3:8 4:1
3ef2ca
    B: 1:0 2:2 3:8 4:1
3ef2ca
  >>> omnifunc
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 1! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 303,308 ****
3ef2ca
--- 325,332 ----
3ef2ca
    W: 1:'A' 2:'B' 3:'' 4:'C'
3ef2ca
    B: 1:'A' 2:'B' 3:'' 4:'C'
3ef2ca
  >>> preserveindent
3ef2ca
+   g/w/b:0/0/1
3ef2ca
+   g/w/b (in):0/0/1
3ef2ca
    p/gopts1! KeyError
3ef2ca
    inv: 2! KeyError
3ef2ca
    gopts1! KeyError
3ef2ca
***************
3ef2ca
*** 321,326 ****
3ef2ca
--- 345,352 ----
3ef2ca
    W: 1:0 2:1 3:0 4:1
3ef2ca
    B: 1:0 2:1 3:0 4:1
3ef2ca
  >>> path
3ef2ca
+   g/w/b:1/0/1
3ef2ca
+   g/w/b (in):1/0/1
3ef2ca
    p/gopts1: b'.,..,,'
3ef2ca
    inv: 0! TypeError
3ef2ca
    p/wopts1! KeyError
3ef2ca
***************
3ef2ca
*** 509,514 ****
3ef2ca
--- 535,555 ----
3ef2ca
  import xxx_no_such_module_xxx:(<class 'ImportError'>, ImportError('No module named xxx_no_such_module_xxx',))
3ef2ca
  import failing_import:(<class 'ImportError'>, ImportError('No module named failing_import',))
3ef2ca
  import failing:(<class 'NotImplementedError'>, NotImplementedError())
3ef2ca
+ > Options
3ef2ca
+ >> OptionsItem
3ef2ca
+ vim.options["abcQ"]:(<class 'KeyError'>, KeyError('abcQ',))
3ef2ca
+ vim.options[""]:(<class 'ValueError'>, ValueError('empty keys are not allowed',))
3ef2ca
+ >>> Testing StringToChars using vim.options[%s]
3ef2ca
+ vim.options[1]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',))
3ef2ca
+ vim.options[b"\0"]:(<class 'TypeError'>, TypeError('expected bytes with no null',))
3ef2ca
+ vim.options["\0"]:(<class 'TypeError'>, TypeError('expected bytes with no null',))
3ef2ca
+ <<< Finished
3ef2ca
+ >> OptionsContains
3ef2ca
+ >>> Testing StringToChars using %s in vim.options
3ef2ca
+ 1 in vim.options:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',))
3ef2ca
+ b"\0" in vim.options:(<class 'TypeError'>, TypeError('expected bytes with no null',))
3ef2ca
+ "\0" in vim.options:(<class 'TypeError'>, TypeError('expected bytes with no null',))
3ef2ca
+ <<< Finished
3ef2ca
  > Dictionary
3ef2ca
  >> DictionaryConstructor
3ef2ca
  vim.Dictionary("abcI"):(<class 'ValueError'>, ValueError('expected sequence element of size 2, but got sequence of size 1',))
3ef2ca
*** ../vim-7.4.151/src/vim.h	2013-11-09 03:31:45.000000000 +0100
3ef2ca
--- src/vim.h	2014-01-14 16:49:10.000000000 +0100
3ef2ca
***************
3ef2ca
*** 2249,2254 ****
3ef2ca
--- 2249,2255 ----
3ef2ca
  #define SOPT_BUF	0x20	/* Option has buffer-local value */
3ef2ca
  #define SOPT_UNSET	0x40	/* Option does not have local value set */
3ef2ca
  
3ef2ca
+ /* Option types for various functions in option.c */
3ef2ca
  #define SREQ_GLOBAL	0	/* Request global option */
3ef2ca
  #define SREQ_WIN	1	/* Request window-local option */
3ef2ca
  #define SREQ_BUF	2	/* Request buffer-local option */
3ef2ca
*** ../vim-7.4.151/src/version.c	2014-01-14 16:36:40.000000000 +0100
3ef2ca
--- src/version.c	2014-01-14 16:43:58.000000000 +0100
3ef2ca
***************
3ef2ca
*** 740,741 ****
3ef2ca
--- 740,743 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     152,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
hundred-and-one symptoms of being an internet addict:
3ef2ca
160. You get in the elevator and double-click the button for the floor
3ef2ca
     you want.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///