In addition to vim.buffers[i] being pretty useless (it uses index of internal 
buffer linked list which user should not know about at all) it also adds a 
convenient way to obtain buffer by its number. Ability to iterate using `:py 
for b in vim.buffers` is lost, but I will readd it a few patches after.

# HG changeset patch
# User ZyX <[email protected]>
# Date 1367070878 -14400
# Branch python-extended-2
# Node ID b7294de06503e35a274288b6fbfa33aab66cc046
# Parent  009744bca2dd4def8064ce41969c8003629f2b4d
Transform BufList into BufMap as vim.buffers[abstract_int] is useless

diff -r 009744bca2dd -r b7294de06503 runtime/doc/if_pyth.txt
--- a/runtime/doc/if_pyth.txt   Sat Apr 27 17:13:46 2013 +0400
+++ b/runtime/doc/if_pyth.txt   Sat Apr 27 17:54:38 2013 +0400
@@ -209,12 +209,11 @@
        to which the variables referred.
 
 vim.buffers                                            *python-buffers*
-       A sequence object providing access to the list of vim buffers.  The
+       A mapping object providing access to the list of vim buffers.  The
        object supports the following operations: >
            :py b = vim.buffers[i]      # Indexing (read-only)
            :py b in vim.buffers        # Membership test
            :py n = len(vim.buffers)    # Number of elements
-           :py for b in vim.buffers:   # Sequential access
 <
 vim.windows                                            *python-windows*
        A sequence object providing access to the list of vim windows.  The
diff -r 009744bca2dd -r b7294de06503 src/if_py_both.h
--- a/src/if_py_both.h  Sat Apr 27 17:13:46 2013 +0400
+++ b/src/if_py_both.h  Sat Apr 27 17:54:38 2013 +0400
@@ -534,16 +534,15 @@
  * Buffer list object - Implementation
  */
 
-static PyTypeObject BufListType;
-static PySequenceMethods BufListAsSeq;
+static PyTypeObject BufMapType;
 
 typedef struct
 {
     PyObject_HEAD
-} BufListObject;
+} BufMapObject;
 
     static PyInt
-BufListLength(PyObject *self UNUSED)
+BufMapLength(PyObject *self UNUSED)
 {
     buf_T      *b = firstbuf;
     PyInt      n = 0;
@@ -558,20 +557,41 @@
 }
 
     static PyObject *
-BufListItem(PyObject *self UNUSED, PyInt n)
+BufMapItem(PyObject *self UNUSED, PyObject *keyObject)
 {
-    buf_T *b;
-
-    for (b = firstbuf; b; b = b->b_next, --n)
+    buf_T      *b;
+    int                bnr;
+
+#if PY_MAJOR_VERSION < 3
+    if (PyInt_Check(keyObject))
+       bnr = PyInt_AsLong(keyObject);
+    else
+#endif
+    if (PyLong_Check(keyObject))
+       bnr = PyLong_AsLong(keyObject);
+    else
     {
-       if (n == 0)
-           return BufferNew(b);
+       PyErr_SetString(PyExc_ValueError, _("key must be integer"));
+       return NULL;
     }
 
-    PyErr_SetString(PyExc_IndexError, _("no such buffer"));
-    return NULL;
+    b = buflist_findnr(bnr);
+
+    if (b)
+       return BufferNew(b);
+    else
+    {
+       PyErr_SetString(PyExc_KeyError, _("no such buffer"));
+       return NULL;
+    }
 }
 
+static PyMappingMethods BufMapAsMapping = {
+    (lenfunc)       BufMapLength,
+    (binaryfunc)    BufMapItem,
+    (objobjargproc) 0,
+};
+
 typedef struct pylinkedlist_S {
     struct pylinkedlist_S      *pll_next;
     struct pylinkedlist_S      *pll_prev;
@@ -3401,11 +3421,11 @@
     WindowType.tp_setattr = WindowSetattr;
 #endif
 
-    vim_memset(&BufListType, 0, sizeof(BufListType));
-    BufListType.tp_name = "vim.bufferlist";
-    BufListType.tp_basicsize = sizeof(BufListObject);
-    BufListType.tp_as_sequence = &BufListAsSeq;
-    BufListType.tp_flags = Py_TPFLAGS_DEFAULT;
+    vim_memset(&BufMapType, 0, sizeof(BufMapType));
+    BufMapType.tp_name = "vim.bufferlist";
+    BufMapType.tp_basicsize = sizeof(BufMapObject);
+    BufMapType.tp_as_mapping = &BufMapAsMapping;
+    BufMapType.tp_flags = Py_TPFLAGS_DEFAULT;
     BufferType.tp_doc = "vim buffer list";
 
     vim_memset(&WinListType, 0, sizeof(WinListType));
diff -r 009744bca2dd -r b7294de06503 src/if_python.c
--- a/src/if_python.c   Sat Apr 27 17:13:46 2013 +0400
+++ b/src/if_python.c   Sat Apr 27 17:54:38 2013 +0400
@@ -1131,24 +1131,6 @@
                      &((RangeObject *)(self))->end);
 }
 
-/* Buffer list object - Definitions
- */
-
-static PySequenceMethods BufListAsSeq = {
-    (PyInquiry)                BufListLength,      /* sq_length,    len(x)   */
-    (binaryfunc)       0,                  /* sq_concat,    x+y      */
-    (PyIntArgFunc)     0,                  /* sq_repeat,    x*n      */
-    (PyIntArgFunc)     BufListItem,        /* sq_item,      x[i]     */
-    (PyIntIntArgFunc)  0,                  /* sq_slice,     x[i:j]   */
-    (PyIntObjArgProc)  0,                  /* sq_ass_item,  x[i]=v   */
-    (PyIntIntObjArgProc) 0,                /* sq_ass_slice, x[i:j]=v */
-    (objobjproc)       0,
-#if PY_MAJOR_VERSION >= 2
-    (binaryfunc)       0,
-    0,
-#endif
-};
-
 /* Window object - Implementation
  */
 
@@ -1212,9 +1194,9 @@
 }
 #endif
 
-static BufListObject TheBufferList =
+static BufMapObject TheBufferMap =
 {
-    PyObject_HEAD_INIT(&BufListType)
+    PyObject_HEAD_INIT(&BufMapType)
 };
 
 static WinListObject TheWindowList =
@@ -1240,7 +1222,7 @@
     PyType_Ready(&BufferType);
     PyType_Ready(&RangeType);
     PyType_Ready(&WindowType);
-    PyType_Ready(&BufListType);
+    PyType_Ready(&BufMapType);
     PyType_Ready(&WinListType);
     PyType_Ready(&CurrentType);
     PyType_Ready(&OptionsType);
@@ -1254,7 +1236,7 @@
     VimError = Py_BuildValue("s", "vim.error");
 
     PyDict_SetItemString(dict, "error", VimError);
-    PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferList);
+    PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferMap);
     PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent);
     PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList);
     tmp = DictionaryNew(&globvardict);
diff -r 009744bca2dd -r b7294de06503 src/if_python3.c
--- a/src/if_python3.c  Sat Apr 27 17:13:46 2013 +0400
+++ b/src/if_python3.c  Sat Apr 27 17:54:38 2013 +0400
@@ -1272,22 +1272,6 @@
     }
 }
 
-/* Buffer list object - Definitions
- */
-
-static PySequenceMethods BufListAsSeq = {
-    (lenfunc)          BufListLength,      /* sq_length,    len(x)   */
-    (binaryfunc)       0,                  /* sq_concat,    x+y      */
-    (ssizeargfunc)     0,                  /* sq_repeat,    x*n      */
-    (ssizeargfunc)     BufListItem,        /* sq_item,      x[i]     */
-    0,                                     /* was_sq_slice,     x[i:j]   */
-    (ssizeobjargproc)  0,                  /* sq_as_item,  x[i]=v   */
-    0,                                     /* sq_ass_slice, x[i:j]=v */
-    0,                                     /* sq_contains */
-    0,                                     /* sq_inplace_concat */
-    0,                                     /* sq_inplace_repeat */
-};
-
 /* Window object - Implementation
  */
 
@@ -1512,9 +1496,9 @@
 }
 #endif
 
-static BufListObject TheBufferList =
+static BufMapObject TheBufferMap =
 {
-    PyObject_HEAD_INIT(&BufListType)
+    PyObject_HEAD_INIT(&BufMapType)
 };
 
 static WinListObject TheWindowList =
@@ -1538,7 +1522,7 @@
     PyType_Ready(&BufferType);
     PyType_Ready(&RangeType);
     PyType_Ready(&WindowType);
-    PyType_Ready(&BufListType);
+    PyType_Ready(&BufMapType);
     PyType_Ready(&WinListType);
     PyType_Ready(&CurrentType);
     PyType_Ready(&DictionaryType);
@@ -1557,8 +1541,8 @@
     Py_INCREF(VimError);
 
     PyModule_AddObject(mod, "error", VimError);
-    Py_INCREF((PyObject *)(void *)&TheBufferList);
-    PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferList);
+    Py_INCREF((PyObject *)(void *)&TheBufferMap);
+    PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferMap);
     Py_INCREF((PyObject *)(void *)&TheCurrent);
     PyModule_AddObject(mod, "current", (PyObject *)(void *)&TheCurrent);
     Py_INCREF((PyObject *)(void *)&TheWindowList);
diff -r 009744bca2dd -r b7294de06503 src/testdir/test86.ok
--- a/src/testdir/test86.ok     Sat Apr 27 17:13:46 2013 +0400
+++ b/src/testdir/test86.ok     Sat Apr 27 17:54:38 2013 +0400
@@ -226,13 +226,13 @@
   p/bopts1: False
   inv: 2! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
   del wopts3! KeyError
   del bopts3! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
 >>> iminsert
   p/gopts1! KeyError
   inv: 3! KeyError
@@ -244,13 +244,13 @@
   wopts3! KeyError
   p/bopts1: 2
   G: 1
-  W: 1:2 2:1 3:0 4:2
-  B: 1:2 2:1 3:0 4:2
+  W: 1:0 2:2 3:2 4:1
+  B: 1:0 2:2 3:2 4:1
   del wopts3! KeyError
   del bopts3! ValueError
   G: 1
-  W: 1:2 2:1 3:0 4:2
-  B: 1:2 2:1 3:0 4:2
+  W: 1:0 2:2 3:2 4:1
+  B: 1:0 2:2 3:2 4:1
 >>> omnifunc
   p/gopts1! KeyError
   inv: 1! KeyError
@@ -263,13 +263,13 @@
   p/bopts1: ''
   inv: 1! ValueError
   G: ''
-  W: 1:'B' 2:'C' 3:'A' 4:''
-  B: 1:'B' 2:'C' 3:'A' 4:''
+  W: 1:'A' 2:'B' 3:'' 4:'C'
+  B: 1:'A' 2:'B' 3:'' 4:'C'
   del wopts3! KeyError
   del bopts3! ValueError
   G: ''
-  W: 1:'B' 2:'C' 3:'A' 4:''
-  B: 1:'B' 2:'C' 3:'A' 4:''
+  W: 1:'A' 2:'B' 3:'' 4:'C'
+  B: 1:'A' 2:'B' 3:'' 4:'C'
 >>> preserveindent
   p/gopts1! KeyError
   inv: 2! KeyError
@@ -282,13 +282,13 @@
   p/bopts1: False
   inv: 2! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
   del wopts3! KeyError
   del bopts3! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
 >>> path
   p/gopts1: '.,/usr/include,,'
   inv: 0! ValueError
@@ -300,12 +300,12 @@
   p/bopts1: None
   inv: 0! ValueError
   G: '.,,'
-  W: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
-  B: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
+  W: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
+  B: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
   del wopts3! KeyError
   G: '.,,'
-  W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
-  B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
+  W: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
+  B: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
 First line
 First line
 def
diff -r 009744bca2dd -r b7294de06503 src/testdir/test87.ok
--- a/src/testdir/test87.ok     Sat Apr 27 17:13:46 2013 +0400
+++ b/src/testdir/test87.ok     Sat Apr 27 17:54:38 2013 +0400
@@ -215,13 +215,13 @@
   p/bopts1: False
   inv: 2! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
   del wopts3! KeyError
   del bopts3! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
 >>> iminsert
   p/gopts1! KeyError
   inv: 3! KeyError
@@ -233,13 +233,13 @@
   wopts3! KeyError
   p/bopts1: 2
   G: 1
-  W: 1:2 2:1 3:0 4:2
-  B: 1:2 2:1 3:0 4:2
+  W: 1:0 2:2 3:2 4:1
+  B: 1:0 2:2 3:2 4:1
   del wopts3! KeyError
   del bopts3! ValueError
   G: 1
-  W: 1:2 2:1 3:0 4:2
-  B: 1:2 2:1 3:0 4:2
+  W: 1:0 2:2 3:2 4:1
+  B: 1:0 2:2 3:2 4:1
 >>> omnifunc
   p/gopts1! KeyError
   inv: 1! KeyError
@@ -252,13 +252,13 @@
   p/bopts1: b''
   inv: 1! ValueError
   G: ''
-  W: 1:'B' 2:'C' 3:'A' 4:''
-  B: 1:'B' 2:'C' 3:'A' 4:''
+  W: 1:'A' 2:'B' 3:'' 4:'C'
+  B: 1:'A' 2:'B' 3:'' 4:'C'
   del wopts3! KeyError
   del bopts3! ValueError
   G: ''
-  W: 1:'B' 2:'C' 3:'A' 4:''
-  B: 1:'B' 2:'C' 3:'A' 4:''
+  W: 1:'A' 2:'B' 3:'' 4:'C'
+  B: 1:'A' 2:'B' 3:'' 4:'C'
 >>> preserveindent
   p/gopts1! KeyError
   inv: 2! KeyError
@@ -271,13 +271,13 @@
   p/bopts1: False
   inv: 2! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
   del wopts3! KeyError
   del bopts3! ValueError
   G: 0
-  W: 1:1 2:1 3:0 4:0
-  B: 1:1 2:1 3:0 4:0
+  W: 1:0 2:1 3:0 4:1
+  B: 1:0 2:1 3:0 4:1
 >>> path
   p/gopts1: b'.,/usr/include,,'
   inv: 0! ValueError
@@ -289,12 +289,12 @@
   p/bopts1: None
   inv: 0! ValueError
   G: '.,,'
-  W: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
-  B: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
+  W: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
+  B: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
   del wopts3! KeyError
   G: '.,,'
-  W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
-  B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
+  W: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
+  B: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
 First line
 First line
 def

-- 
-- 
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.


diff -cr vim.009744bca2dd/runtime/doc/if_pyth.txt vim.b7294de06503/runtime/doc/if_pyth.txt
*** vim.009744bca2dd/runtime/doc/if_pyth.txt	2013-04-28 20:28:22.172843534 +0400
--- vim.b7294de06503/runtime/doc/if_pyth.txt	2013-04-28 20:28:22.182843433 +0400
***************
*** 209,220 ****
  	to which the variables referred.
  
  vim.buffers						*python-buffers*
! 	A sequence object providing access to the list of vim buffers.  The
  	object supports the following operations: >
  	    :py b = vim.buffers[i]	# Indexing (read-only)
  	    :py b in vim.buffers	# Membership test
  	    :py n = len(vim.buffers)	# Number of elements
- 	    :py for b in vim.buffers:	# Sequential access
  <
  vim.windows						*python-windows*
  	A sequence object providing access to the list of vim windows.  The
--- 209,219 ----
  	to which the variables referred.
  
  vim.buffers						*python-buffers*
! 	A mapping object providing access to the list of vim buffers.  The
  	object supports the following operations: >
  	    :py b = vim.buffers[i]	# Indexing (read-only)
  	    :py b in vim.buffers	# Membership test
  	    :py n = len(vim.buffers)	# Number of elements
  <
  vim.windows						*python-windows*
  	A sequence object providing access to the list of vim windows.  The
diff -cr vim.009744bca2dd/src/if_py_both.h vim.b7294de06503/src/if_py_both.h
*** vim.009744bca2dd/src/if_py_both.h	2013-04-28 20:28:22.168843574 +0400
--- vim.b7294de06503/src/if_py_both.h	2013-04-28 20:28:22.178843473 +0400
***************
*** 534,549 ****
   * Buffer list object - Implementation
   */
  
! static PyTypeObject BufListType;
! static PySequenceMethods BufListAsSeq;
  
  typedef struct
  {
      PyObject_HEAD
! } BufListObject;
  
      static PyInt
! BufListLength(PyObject *self UNUSED)
  {
      buf_T	*b = firstbuf;
      PyInt	n = 0;
--- 534,548 ----
   * Buffer list object - Implementation
   */
  
! static PyTypeObject BufMapType;
  
  typedef struct
  {
      PyObject_HEAD
! } BufMapObject;
  
      static PyInt
! BufMapLength(PyObject *self UNUSED)
  {
      buf_T	*b = firstbuf;
      PyInt	n = 0;
***************
*** 558,577 ****
  }
  
      static PyObject *
! BufListItem(PyObject *self UNUSED, PyInt n)
  {
!     buf_T *b;
  
!     for (b = firstbuf; b; b = b->b_next, --n)
      {
! 	if (n == 0)
! 	    return BufferNew(b);
      }
  
!     PyErr_SetString(PyExc_IndexError, _("no such buffer"));
!     return NULL;
  }
  
  typedef struct pylinkedlist_S {
      struct pylinkedlist_S	*pll_next;
      struct pylinkedlist_S	*pll_prev;
--- 557,597 ----
  }
  
      static PyObject *
! BufMapItem(PyObject *self UNUSED, PyObject *keyObject)
  {
!     buf_T	*b;
!     int		bnr;
  
! #if PY_MAJOR_VERSION < 3
!     if (PyInt_Check(keyObject))
! 	bnr = PyInt_AsLong(keyObject);
!     else
! #endif
!     if (PyLong_Check(keyObject))
! 	bnr = PyLong_AsLong(keyObject);
!     else
      {
! 	PyErr_SetString(PyExc_ValueError, _("key must be integer"));
! 	return NULL;
      }
  
!     b = buflist_findnr(bnr);
! 
!     if (b)
! 	return BufferNew(b);
!     else
!     {
! 	PyErr_SetString(PyExc_KeyError, _("no such buffer"));
! 	return NULL;
!     }
  }
  
+ static PyMappingMethods BufMapAsMapping = {
+     (lenfunc)       BufMapLength,
+     (binaryfunc)    BufMapItem,
+     (objobjargproc) 0,
+ };
+ 
  typedef struct pylinkedlist_S {
      struct pylinkedlist_S	*pll_next;
      struct pylinkedlist_S	*pll_prev;
***************
*** 3401,3411 ****
      WindowType.tp_setattr = WindowSetattr;
  #endif
  
!     vim_memset(&BufListType, 0, sizeof(BufListType));
!     BufListType.tp_name = "vim.bufferlist";
!     BufListType.tp_basicsize = sizeof(BufListObject);
!     BufListType.tp_as_sequence = &BufListAsSeq;
!     BufListType.tp_flags = Py_TPFLAGS_DEFAULT;
      BufferType.tp_doc = "vim buffer list";
  
      vim_memset(&WinListType, 0, sizeof(WinListType));
--- 3421,3431 ----
      WindowType.tp_setattr = WindowSetattr;
  #endif
  
!     vim_memset(&BufMapType, 0, sizeof(BufMapType));
!     BufMapType.tp_name = "vim.bufferlist";
!     BufMapType.tp_basicsize = sizeof(BufMapObject);
!     BufMapType.tp_as_mapping = &BufMapAsMapping;
!     BufMapType.tp_flags = Py_TPFLAGS_DEFAULT;
      BufferType.tp_doc = "vim buffer list";
  
      vim_memset(&WinListType, 0, sizeof(WinListType));
diff -cr vim.009744bca2dd/src/if_python3.c vim.b7294de06503/src/if_python3.c
*** vim.009744bca2dd/src/if_python3.c	2013-04-28 20:28:22.171843543 +0400
--- vim.b7294de06503/src/if_python3.c	2013-04-28 20:28:22.181843443 +0400
***************
*** 1272,1293 ****
      }
  }
  
- /* Buffer list object - Definitions
-  */
- 
- static PySequenceMethods BufListAsSeq = {
-     (lenfunc)		BufListLength,	    /* sq_length,    len(x)   */
-     (binaryfunc)	0,		    /* sq_concat,    x+y      */
-     (ssizeargfunc)	0,		    /* sq_repeat,    x*n      */
-     (ssizeargfunc)	BufListItem,	    /* sq_item,      x[i]     */
-     0,					    /* was_sq_slice,	 x[i:j]   */
-     (ssizeobjargproc)	0,		    /* sq_as_item,  x[i]=v   */
-     0,					    /* sq_ass_slice, x[i:j]=v */
-     0,					    /* sq_contains */
-     0,					    /* sq_inplace_concat */
-     0,					    /* sq_inplace_repeat */
- };
- 
  /* Window object - Implementation
   */
  
--- 1272,1277 ----
***************
*** 1512,1520 ****
  }
  #endif
  
! static BufListObject TheBufferList =
  {
!     PyObject_HEAD_INIT(&BufListType)
  };
  
  static WinListObject TheWindowList =
--- 1496,1504 ----
  }
  #endif
  
! static BufMapObject TheBufferMap =
  {
!     PyObject_HEAD_INIT(&BufMapType)
  };
  
  static WinListObject TheWindowList =
***************
*** 1538,1544 ****
      PyType_Ready(&BufferType);
      PyType_Ready(&RangeType);
      PyType_Ready(&WindowType);
!     PyType_Ready(&BufListType);
      PyType_Ready(&WinListType);
      PyType_Ready(&CurrentType);
      PyType_Ready(&DictionaryType);
--- 1522,1528 ----
      PyType_Ready(&BufferType);
      PyType_Ready(&RangeType);
      PyType_Ready(&WindowType);
!     PyType_Ready(&BufMapType);
      PyType_Ready(&WinListType);
      PyType_Ready(&CurrentType);
      PyType_Ready(&DictionaryType);
***************
*** 1557,1564 ****
      Py_INCREF(VimError);
  
      PyModule_AddObject(mod, "error", VimError);
!     Py_INCREF((PyObject *)(void *)&TheBufferList);
!     PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferList);
      Py_INCREF((PyObject *)(void *)&TheCurrent);
      PyModule_AddObject(mod, "current", (PyObject *)(void *)&TheCurrent);
      Py_INCREF((PyObject *)(void *)&TheWindowList);
--- 1541,1548 ----
      Py_INCREF(VimError);
  
      PyModule_AddObject(mod, "error", VimError);
!     Py_INCREF((PyObject *)(void *)&TheBufferMap);
!     PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferMap);
      Py_INCREF((PyObject *)(void *)&TheCurrent);
      PyModule_AddObject(mod, "current", (PyObject *)(void *)&TheCurrent);
      Py_INCREF((PyObject *)(void *)&TheWindowList);
diff -cr vim.009744bca2dd/src/if_python.c vim.b7294de06503/src/if_python.c
*** vim.009744bca2dd/src/if_python.c	2013-04-28 20:28:22.174843513 +0400
--- vim.b7294de06503/src/if_python.c	2013-04-28 20:28:22.184843413 +0400
***************
*** 1131,1154 ****
  		      &((RangeObject *)(self))->end);
  }
  
- /* Buffer list object - Definitions
-  */
- 
- static PySequenceMethods BufListAsSeq = {
-     (PyInquiry)		BufListLength,	    /* sq_length,    len(x)   */
-     (binaryfunc)	0,		    /* sq_concat,    x+y      */
-     (PyIntArgFunc)	0,		    /* sq_repeat,    x*n      */
-     (PyIntArgFunc)	BufListItem,	    /* sq_item,      x[i]     */
-     (PyIntIntArgFunc)	0,		    /* sq_slice,     x[i:j]   */
-     (PyIntObjArgProc)	0,		    /* sq_ass_item,  x[i]=v   */
-     (PyIntIntObjArgProc) 0,		    /* sq_ass_slice, x[i:j]=v */
-     (objobjproc)	0,
- #if PY_MAJOR_VERSION >= 2
-     (binaryfunc)	0,
-     0,
- #endif
- };
- 
  /* Window object - Implementation
   */
  
--- 1131,1136 ----
***************
*** 1212,1220 ****
  }
  #endif
  
! static BufListObject TheBufferList =
  {
!     PyObject_HEAD_INIT(&BufListType)
  };
  
  static WinListObject TheWindowList =
--- 1194,1202 ----
  }
  #endif
  
! static BufMapObject TheBufferMap =
  {
!     PyObject_HEAD_INIT(&BufMapType)
  };
  
  static WinListObject TheWindowList =
***************
*** 1240,1246 ****
      PyType_Ready(&BufferType);
      PyType_Ready(&RangeType);
      PyType_Ready(&WindowType);
!     PyType_Ready(&BufListType);
      PyType_Ready(&WinListType);
      PyType_Ready(&CurrentType);
      PyType_Ready(&OptionsType);
--- 1222,1228 ----
      PyType_Ready(&BufferType);
      PyType_Ready(&RangeType);
      PyType_Ready(&WindowType);
!     PyType_Ready(&BufMapType);
      PyType_Ready(&WinListType);
      PyType_Ready(&CurrentType);
      PyType_Ready(&OptionsType);
***************
*** 1254,1260 ****
      VimError = Py_BuildValue("s", "vim.error");
  
      PyDict_SetItemString(dict, "error", VimError);
!     PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferList);
      PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent);
      PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList);
      tmp = DictionaryNew(&globvardict);
--- 1236,1242 ----
      VimError = Py_BuildValue("s", "vim.error");
  
      PyDict_SetItemString(dict, "error", VimError);
!     PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferMap);
      PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent);
      PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList);
      tmp = DictionaryNew(&globvardict);
diff -cr vim.009744bca2dd/src/testdir/test86.ok vim.b7294de06503/src/testdir/test86.ok
*** vim.009744bca2dd/src/testdir/test86.ok	2013-04-28 20:28:22.169843563 +0400
--- vim.b7294de06503/src/testdir/test86.ok	2013-04-28 20:28:22.179843463 +0400
***************
*** 226,238 ****
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
  >>> iminsert
    p/gopts1! KeyError
    inv: 3! KeyError
--- 226,238 ----
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
  >>> iminsert
    p/gopts1! KeyError
    inv: 3! KeyError
***************
*** 244,256 ****
    wopts3! KeyError
    p/bopts1: 2
    G: 1
!   W: 1:2 2:1 3:0 4:2
!   B: 1:2 2:1 3:0 4:2
    del wopts3! KeyError
    del bopts3! ValueError
    G: 1
!   W: 1:2 2:1 3:0 4:2
!   B: 1:2 2:1 3:0 4:2
  >>> omnifunc
    p/gopts1! KeyError
    inv: 1! KeyError
--- 244,256 ----
    wopts3! KeyError
    p/bopts1: 2
    G: 1
!   W: 1:0 2:2 3:2 4:1
!   B: 1:0 2:2 3:2 4:1
    del wopts3! KeyError
    del bopts3! ValueError
    G: 1
!   W: 1:0 2:2 3:2 4:1
!   B: 1:0 2:2 3:2 4:1
  >>> omnifunc
    p/gopts1! KeyError
    inv: 1! KeyError
***************
*** 263,275 ****
    p/bopts1: ''
    inv: 1! ValueError
    G: ''
!   W: 1:'B' 2:'C' 3:'A' 4:''
!   B: 1:'B' 2:'C' 3:'A' 4:''
    del wopts3! KeyError
    del bopts3! ValueError
    G: ''
!   W: 1:'B' 2:'C' 3:'A' 4:''
!   B: 1:'B' 2:'C' 3:'A' 4:''
  >>> preserveindent
    p/gopts1! KeyError
    inv: 2! KeyError
--- 263,275 ----
    p/bopts1: ''
    inv: 1! ValueError
    G: ''
!   W: 1:'A' 2:'B' 3:'' 4:'C'
!   B: 1:'A' 2:'B' 3:'' 4:'C'
    del wopts3! KeyError
    del bopts3! ValueError
    G: ''
!   W: 1:'A' 2:'B' 3:'' 4:'C'
!   B: 1:'A' 2:'B' 3:'' 4:'C'
  >>> preserveindent
    p/gopts1! KeyError
    inv: 2! KeyError
***************
*** 282,294 ****
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
  >>> path
    p/gopts1: '.,/usr/include,,'
    inv: 0! ValueError
--- 282,294 ----
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
  >>> path
    p/gopts1: '.,/usr/include,,'
    inv: 0! ValueError
***************
*** 300,311 ****
    p/bopts1: None
    inv: 0! ValueError
    G: '.,,'
!   W: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
!   B: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
    del wopts3! KeyError
    G: '.,,'
!   W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
!   B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
  First line
  First line
  def
--- 300,311 ----
    p/bopts1: None
    inv: 0! ValueError
    G: '.,,'
!   W: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
!   B: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
    del wopts3! KeyError
    G: '.,,'
!   W: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
!   B: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
  First line
  First line
  def
diff -cr vim.009744bca2dd/src/testdir/test87.ok vim.b7294de06503/src/testdir/test87.ok
*** vim.009744bca2dd/src/testdir/test87.ok	2013-04-28 20:28:22.166843593 +0400
--- vim.b7294de06503/src/testdir/test87.ok	2013-04-28 20:28:22.176843493 +0400
***************
*** 215,227 ****
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
  >>> iminsert
    p/gopts1! KeyError
    inv: 3! KeyError
--- 215,227 ----
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
  >>> iminsert
    p/gopts1! KeyError
    inv: 3! KeyError
***************
*** 233,245 ****
    wopts3! KeyError
    p/bopts1: 2
    G: 1
!   W: 1:2 2:1 3:0 4:2
!   B: 1:2 2:1 3:0 4:2
    del wopts3! KeyError
    del bopts3! ValueError
    G: 1
!   W: 1:2 2:1 3:0 4:2
!   B: 1:2 2:1 3:0 4:2
  >>> omnifunc
    p/gopts1! KeyError
    inv: 1! KeyError
--- 233,245 ----
    wopts3! KeyError
    p/bopts1: 2
    G: 1
!   W: 1:0 2:2 3:2 4:1
!   B: 1:0 2:2 3:2 4:1
    del wopts3! KeyError
    del bopts3! ValueError
    G: 1
!   W: 1:0 2:2 3:2 4:1
!   B: 1:0 2:2 3:2 4:1
  >>> omnifunc
    p/gopts1! KeyError
    inv: 1! KeyError
***************
*** 252,264 ****
    p/bopts1: b''
    inv: 1! ValueError
    G: ''
!   W: 1:'B' 2:'C' 3:'A' 4:''
!   B: 1:'B' 2:'C' 3:'A' 4:''
    del wopts3! KeyError
    del bopts3! ValueError
    G: ''
!   W: 1:'B' 2:'C' 3:'A' 4:''
!   B: 1:'B' 2:'C' 3:'A' 4:''
  >>> preserveindent
    p/gopts1! KeyError
    inv: 2! KeyError
--- 252,264 ----
    p/bopts1: b''
    inv: 1! ValueError
    G: ''
!   W: 1:'A' 2:'B' 3:'' 4:'C'
!   B: 1:'A' 2:'B' 3:'' 4:'C'
    del wopts3! KeyError
    del bopts3! ValueError
    G: ''
!   W: 1:'A' 2:'B' 3:'' 4:'C'
!   B: 1:'A' 2:'B' 3:'' 4:'C'
  >>> preserveindent
    p/gopts1! KeyError
    inv: 2! KeyError
***************
*** 271,283 ****
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:1 2:1 3:0 4:0
!   B: 1:1 2:1 3:0 4:0
  >>> path
    p/gopts1: b'.,/usr/include,,'
    inv: 0! ValueError
--- 271,283 ----
    p/bopts1: False
    inv: 2! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
    del wopts3! KeyError
    del bopts3! ValueError
    G: 0
!   W: 1:0 2:1 3:0 4:1
!   B: 1:0 2:1 3:0 4:1
  >>> path
    p/gopts1: b'.,/usr/include,,'
    inv: 0! ValueError
***************
*** 289,300 ****
    p/bopts1: None
    inv: 0! ValueError
    G: '.,,'
!   W: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
!   B: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
    del wopts3! KeyError
    G: '.,,'
!   W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
!   B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
  First line
  First line
  def
--- 289,300 ----
    p/bopts1: None
    inv: 0! ValueError
    G: '.,,'
!   W: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
!   B: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
    del wopts3! KeyError
    G: '.,,'
!   W: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
!   B: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
  First line
  First line
  def

Raspunde prin e-mail lui