Patch 7.3.1042
Problem:    Python: can't assign to vim.Buffer.name.
Solution:   Python patch 3. (ZyX)
Files:      runtime/doc/if_pyth.txt, src/ex_cmds.c, src/if_py_both.h,
            src/if_python3.c, src/if_python.c, src/proto/ex_cmds.pro,
            src/testdir/test86.in, src/testdir/test86.ok,
            src/testdir/test87.in, src/testdir/test87.ok


*** ../vim-7.3.1041/runtime/doc/if_pyth.txt     2013-05-21 19:49:58.000000000 
+0200
--- runtime/doc/if_pyth.txt     2013-05-29 21:40:05.000000000 +0200
***************
*** 250,256 ****
        object and always use windows from that tab page (or throw vim.error 
        in case tab page was deleted). You can keep a reference to both 
        without keeping a reference to vim module object or |python-tabpage|, 
!       they will not loose their properties in this case.
  
  vim.tabpages                                          *python-tabpages*
        A sequence object providing access to the list of vim tab pages. The 
--- 250,256 ----
        object and always use windows from that tab page (or throw vim.error 
        in case tab page was deleted). You can keep a reference to both 
        without keeping a reference to vim module object or |python-tabpage|, 
!       they will not lose their properties in this case.
  
  vim.tabpages                                          *python-tabpages*
        A sequence object providing access to the list of vim tab pages. The 
***************
*** 361,366 ****
--- 361,371 ----
                        this object will raise KeyError. If option is 
                        |global-local| and local value is missing getting it 
                        will return None.
+       b.name          String, RW. Contains buffer name (full path).
+                       Note: when assigning to b.name |BufFilePre| and 
+                       |BufFilePost| autocommands are launched.
+       b.number        Buffer number. Can be used as |python-buffers| key.
+                       Read-only.
  
  The buffer object methods are:
        b.append(str)   Append a line to the buffer
*** ../vim-7.3.1041/src/ex_cmds.c       2013-04-14 23:19:32.000000000 +0200
--- src/ex_cmds.c       2013-05-29 21:44:19.000000000 +0200
***************
*** 784,789 ****
--- 784,790 ----
       */
      last_line = curbuf->b_ml.ml_line_count;
      mark_adjust(line1, line2, last_line - line2, 0L);
+     changed_lines(last_line - num_lines + 1, 0, last_line + 1, num_lines);
      if (dest >= line2)
      {
        mark_adjust(line2 + 1, dest, -num_lines, 0L);
***************
*** 799,804 ****
--- 800,806 ----
      curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
      mark_adjust(last_line - num_lines + 1, last_line,
                                             -(last_line - dest - extra), 0L);
+     changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra);
  
      /*
       * Now we delete the original text -- webb
***************
*** 2414,2419 ****
--- 2416,2473 ----
      info_message = FALSE;
  }
  
+     int
+ rename_buffer(new_fname)
+     char_u    *new_fname;
+ {
+     char_u    *fname, *sfname, *xfname;
+ #ifdef FEAT_AUTOCMD
+     buf_T     *buf = curbuf;
+ 
+     apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, buf);
+     /* buffer changed, don't change name now */
+     if (buf != curbuf)
+       return FAIL;
+ # ifdef FEAT_EVAL
+     if (aborting())       /* autocmds may abort script processing */
+       return FAIL;
+ # endif
+ #endif
+     /*
+      * The name of the current buffer will be changed.
+      * A new (unlisted) buffer entry needs to be made to hold the old file
+      * name, which will become the alternate file name.
+      * But don't set the alternate file name if the buffer didn't have a
+      * name.
+      */
+     fname = buf->b_ffname;
+     sfname = buf->b_sfname;
+     xfname = buf->b_fname;
+     buf->b_ffname = NULL;
+     buf->b_sfname = NULL;
+     if (setfname(buf, new_fname, NULL, TRUE) == FAIL)
+     {
+       buf->b_ffname = fname;
+       buf->b_sfname = sfname;
+       return FAIL;
+     }
+     buf->b_flags |= BF_NOTEDITED;
+     if (xfname != NULL && *xfname != NUL)
+     {
+       buf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0);
+       if (buf != NULL && !cmdmod.keepalt)
+           curwin->w_alt_fnum = buf->b_fnum;
+     }
+     vim_free(fname);
+     vim_free(sfname);
+ #ifdef FEAT_AUTOCMD
+     apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, buf);
+ #endif
+     /* Change directories when the 'acd' option is set. */
+     DO_AUTOCHDIR
+     return OK;
+ }
+ 
  /*
   * ":file[!] [fname]".
   */
***************
*** 2421,2429 ****
  ex_file(eap)
      exarg_T   *eap;
  {
-     char_u    *fname, *sfname, *xfname;
-     buf_T     *buf;
- 
      /* ":0file" removes the file name.  Check for illegal uses ":3file",
       * "0file name", etc. */
      if (eap->addr_count > 0
--- 2475,2480 ----
***************
*** 2437,2485 ****
  
      if (*eap->arg != NUL || eap->addr_count == 1)
      {
! #ifdef FEAT_AUTOCMD
!       buf = curbuf;
!       apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
!       /* buffer changed, don't change name now */
!       if (buf != curbuf)
!           return;
! # ifdef FEAT_EVAL
!       if (aborting())     /* autocmds may abort script processing */
!           return;
! # endif
! #endif
!       /*
!        * The name of the current buffer will be changed.
!        * A new (unlisted) buffer entry needs to be made to hold the old file
!        * name, which will become the alternate file name.
!        * But don't set the alternate file name if the buffer didn't have a
!        * name.
!        */
!       fname = curbuf->b_ffname;
!       sfname = curbuf->b_sfname;
!       xfname = curbuf->b_fname;
!       curbuf->b_ffname = NULL;
!       curbuf->b_sfname = NULL;
!       if (setfname(curbuf, eap->arg, NULL, TRUE) == FAIL)
!       {
!           curbuf->b_ffname = fname;
!           curbuf->b_sfname = sfname;
            return;
-       }
-       curbuf->b_flags |= BF_NOTEDITED;
-       if (xfname != NULL && *xfname != NUL)
-       {
-           buf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0);
-           if (buf != NULL && !cmdmod.keepalt)
-               curwin->w_alt_fnum = buf->b_fnum;
-       }
-       vim_free(fname);
-       vim_free(sfname);
- #ifdef FEAT_AUTOCMD
-       apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
- #endif
-       /* Change directories when the 'acd' option is set. */
-       DO_AUTOCHDIR
      }
      /* print full file name if :cd used */
      fileinfo(FALSE, FALSE, eap->forceit);
--- 2488,2495 ----
  
      if (*eap->arg != NUL || eap->addr_count == 1)
      {
!       if (rename_buffer(eap->arg) == FAIL)
            return;
      }
      /* print full file name if :cd used */
      fileinfo(FALSE, FALSE, eap->forceit);
*** ../vim-7.3.1041/src/if_py_both.h    2013-05-29 21:37:29.000000000 +0200
--- src/if_py_both.h    2013-05-29 21:47:35.000000000 +0200
***************
*** 30,35 ****
--- 30,43 ----
  #define INVALID_WINDOW_VALUE ((win_T *)(-1))
  #define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
  
+ #define DICTKEY_DECL \
+     PyObject  *dictkey_todecref;
+ #define DICTKEY_GET(err) \
+     if (!(key = StringToChars(keyObject, &dictkey_todecref))) \
+       return err;
+ #define DICTKEY_UNREF \
+     Py_XDECREF(dictkey_todecref);
+ 
  typedef void (*rangeinitializer)(void *);
  typedef void (*runner)(const char *, void *
  #ifdef PY_CAN_RECURSE
***************
*** 64,69 ****
--- 72,122 ----
  {
  }
  
+ /*
+  * The "todecref" argument holds a pointer to PyObject * that must be
+  * DECREF'ed after returned char_u * is no longer needed or NULL if all what
+  * was needed to generate returned value is object.
+  *
+  * Use Py_XDECREF to decrement reference count.
+  */
+     static char_u *
+ StringToChars(PyObject *object, PyObject **todecref)
+ {
+     char_u    *p;
+     PyObject  *bytes = NULL;
+ 
+     if (PyBytes_Check(object))
+     {
+ 
+       if (PyString_AsStringAndSize(object, (char **) &p, NULL) == -1)
+           return NULL;
+       if (p == NULL)
+           return NULL;
+ 
+       *todecref = NULL;
+     }
+     else if (PyUnicode_Check(object))
+     {
+       bytes = PyUnicode_AsEncodedString(object, (char *)ENC_OPT, NULL);
+       if (bytes == NULL)
+           return NULL;
+ 
+       if(PyString_AsStringAndSize(bytes, (char **) &p, NULL) == -1)
+           return NULL;
+       if (p == NULL)
+           return NULL;
+ 
+       *todecref = bytes;
+     }
+     else
+     {
+       PyErr_SetString(PyExc_TypeError, _("object must be string"));
+       return NULL;
+     }
+ 
+     return (char_u *) p;
+ }
+ 
  /* Output buffer management
   */
  
***************
*** 1586,1591 ****
--- 1639,1656 ----
      return VimTryEnd();
  }
  
+     static void *
+ py_memsave(void *p, size_t len)
+ {
+     void      *r;
+     if (!(r = PyMem_Malloc(len)))
+       return NULL;
+     mch_memmove(r, p, len);
+     return r;
+ }
+ 
+ #define PY_STRSAVE(s) ((char_u *) py_memsave(s, STRLEN(s) + 1))
+ 
      static int
  OptionsAssItem(OptionsObject *self, PyObject *keyObject, PyObject *valObject)
  {
***************
*** 1670,1726 ****
      else
      {
        char_u  *val;
!       if (PyBytes_Check(valObject))
!       {
  
!           if (PyString_AsStringAndSize(valObject, (char **) &val, NULL) == -1)
!           {
!               DICTKEY_UNREF
!               return -1;
!           }
!           if (val == NULL)
!           {
!               DICTKEY_UNREF
!               return -1;
!           }
! 
!           val = vim_strsave(val);
!       }
!       else if (PyUnicode_Check(valObject))
        {
!           PyObject    *bytes;
! 
!           bytes = PyUnicode_AsEncodedString(valObject, (char *)ENC_OPT, NULL);
!           if (bytes == NULL)
!           {
!               DICTKEY_UNREF
!               return -1;
!           }
! 
!           if(PyString_AsStringAndSize(bytes, (char **) &val, NULL) == -1)
!           {
!               DICTKEY_UNREF
!               return -1;
!           }
!           if (val == NULL)
!           {
!               DICTKEY_UNREF
!               return -1;
!           }
! 
!           val = vim_strsave(val);
!           Py_XDECREF(bytes);
        }
        else
!       {
!           PyErr_SetString(PyExc_TypeError, _("object must be string"));
!           DICTKEY_UNREF
!           return -1;
!       }
! 
!       r = set_option_value_for(key, 0, val, opt_flags,
!                               self->opt_type, self->from);
!       vim_free(val);
      }
  
      DICTKEY_UNREF
--- 1735,1750 ----
      else
      {
        char_u  *val;
!       PyObject        *todecref;
  
!       if ((val = StringToChars(valObject, &todecref)))
        {
!           r = set_option_value_for(key, 0, val, opt_flags,
!                                   self->opt_type, self->from);
!           Py_XDECREF(todecref);
        }
        else
!           r = -1;
      }
  
      DICTKEY_UNREF
***************
*** 2541,2547 ****
            array = NULL;
        else
        {
!           array = (char **)alloc((unsigned)(new_len * sizeof(char *)));
            if (array == NULL)
            {
                PyErr_NoMemory();
--- 2565,2571 ----
            array = NULL;
        else
        {
!           array = PyMem_New(char *, new_len);
            if (array == NULL)
            {
                PyErr_NoMemory();
***************
*** 2558,2564 ****
            {
                while (i)
                    vim_free(array[--i]);
!               vim_free(array);
                return FAIL;
            }
        }
--- 2582,2588 ----
            {
                while (i)
                    vim_free(array[--i]);
!               PyMem_Free(array);
                return FAIL;
            }
        }
***************
*** 2635,2641 ****
         * been dealt with (either freed, or the responsibility passed
         * to vim.
         */
!       vim_free(array);
  
        /* Adjust marks. Invalidate any which lie in the
         * changed range, and move any in the remainder of the buffer.
--- 2659,2665 ----
         * been dealt with (either freed, or the responsibility passed
         * to vim.
         */
!       PyMem_Free(array);
  
        /* Adjust marks. Invalidate any which lie in the
         * changed range, and move any in the remainder of the buffer.
***************
*** 2717,2723 ****
        char    **array;
        buf_T   *savebuf;
  
!       array = (char **)alloc((unsigned)(size * sizeof(char *)));
        if (array == NULL)
        {
            PyErr_NoMemory();
--- 2741,2747 ----
        char    **array;
        buf_T   *savebuf;
  
!       array = PyMem_New(char *, size);
        if (array == NULL)
        {
            PyErr_NoMemory();
***************
*** 2733,2739 ****
            {
                while (i)
                    vim_free(array[--i]);
!               vim_free(array);
                return FAIL;
            }
        }
--- 2757,2763 ----
            {
                while (i)
                    vim_free(array[--i]);
!               PyMem_Free(array);
                return FAIL;
            }
        }
***************
*** 2768,2774 ****
        /* Free the array of lines. All of its contents have now
         * been freed.
         */
!       vim_free(array);
  
        restore_buffer(savebuf);
        update_screen(VALID);
--- 2792,2798 ----
        /* Free the array of lines. All of its contents have now
         * been freed.
         */
!       PyMem_Free(array);
  
        restore_buffer(savebuf);
        update_screen(VALID);
***************
*** 3179,3184 ****
--- 3203,3247 ----
        return NULL;
  }
  
+     static int
+ BufferSetattr(BufferObject *self, char *name, PyObject *valObject)
+ {
+     if (CheckBuffer(self))
+       return -1;
+ 
+     if (strcmp(name, "name") == 0)
+     {
+       char_u  *val;
+       aco_save_T      aco;
+       int     r;
+       PyObject        *todecref;
+ 
+       if (!(val = StringToChars(valObject, &todecref)))
+           return -1;
+ 
+       VimTryStart();
+       /* Using aucmd_*: autocommands will be executed by rename_buffer */
+       aucmd_prepbuf(&aco, self->buf);
+       r = rename_buffer(val);
+       aucmd_restbuf(&aco);
+       Py_XDECREF(todecref);
+       if (VimTryEnd())
+           return -1;
+ 
+       if (r == FAIL)
+       {
+           PyErr_SetVim(_("failed to rename buffer"));
+           return -1;
+       }
+       return 0;
+     }
+     else
+     {
+       PyErr_SetString(PyExc_AttributeError, name);
+       return -1;
+     }
+ }
+ 
      static PyObject *
  BufferAppend(BufferObject *self, PyObject *args)
  {
***************
*** 4040,4046 ****
        if (result == NULL)
            return -1;
  
!       if (set_string_copy(result, tv) == -1)
        {
            Py_XDECREF(bytes);
            return -1;
--- 4103,4109 ----
        if (result == NULL)
            return -1;
  
!       if (set_string_copy(result, tv))
        {
            Py_XDECREF(bytes);
            return -1;
***************
*** 4169,4179 ****
--- 4232,4244 ----
      BufferType.tp_methods = BufferMethods;
  #if PY_MAJOR_VERSION >= 3
      BufferType.tp_getattro = (getattrofunc)BufferGetattro;
+     BufferType.tp_setattro = (setattrofunc)BufferSetattro;
      BufferType.tp_alloc = call_PyType_GenericAlloc;
      BufferType.tp_new = call_PyType_GenericNew;
      BufferType.tp_free = call_PyObject_Free;
  #else
      BufferType.tp_getattr = (getattrfunc)BufferGetattr;
+     BufferType.tp_setattr = (setattrfunc)BufferSetattr;
  #endif
  
      vim_memset(&WindowType, 0, sizeof(WindowType));
*** ../vim-7.3.1041/src/if_python3.c    2013-05-29 21:33:34.000000000 +0200
--- src/if_python3.c    2013-05-29 21:40:05.000000000 +0200
***************
*** 638,669 ****
  
  #define PYINITIALISED py3initialised
  
- #define DICTKEY_DECL PyObject *bytes = NULL;
- 
- #define DICTKEY_GET(err) \
-     if (PyBytes_Check(keyObject)) \
-     { \
-       if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
-           return err; \
-     } \
-     else if (PyUnicode_Check(keyObject)) \
-     { \
-       bytes = PyString_AsBytes(keyObject); \
-       if (bytes == NULL) \
-           return err; \
-       if (PyString_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \
-           return err; \
-     } \
-     else \
-     { \
-       PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
-       return err; \
-     }
- 
- #define DICTKEY_UNREF \
-     if (bytes != NULL) \
-       Py_XDECREF(bytes);
- 
  #define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self)
  
  #define WIN_PYTHON_REF(win) win->w_python3_ref
--- 638,643 ----
***************
*** 696,701 ****
--- 670,676 ----
  static PyObject *OutputGetattro(PyObject *, PyObject *);
  static int OutputSetattro(PyObject *, PyObject *, PyObject *);
  static PyObject *BufferGetattro(PyObject *, PyObject *);
+ static int BufferSetattro(PyObject *, PyObject *, PyObject *);
  static PyObject *TabPageGetattro(PyObject *, PyObject *);
  static PyObject *WindowGetattro(PyObject *, PyObject *);
  static int WindowSetattro(PyObject *, PyObject *, PyObject *);
***************
*** 1108,1113 ****
--- 1083,1096 ----
        return PyObject_GenericGetAttr(self, nameobj);
  }
  
+     static int
+ BufferSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
+ {
+     GET_ATTR_STRING(name, nameobj);
+ 
+     return BufferSetattr((BufferObject *)(self), name, val);
+ }
+ 
      static PyObject *
  BufferDir(PyObject *self UNUSED)
  {
*** ../vim-7.3.1041/src/if_python.c     2013-05-29 21:33:34.000000000 +0200
--- src/if_python.c     2013-05-29 21:40:05.000000000 +0200
***************
*** 676,693 ****
  static int initialised = 0;
  #define PYINITIALISED initialised
  
- #define DICTKEY_GET(err) \
-     if (!PyString_Check(keyObject)) \
-     { \
-       PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
-       return err; \
-     } \
-     if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
-       return err;
- 
- #define DICTKEY_UNREF
- #define DICTKEY_DECL
- 
  #define DESTRUCTOR_FINISH(self) self->ob_type->tp_free((PyObject*)self);
  
  #define WIN_PYTHON_REF(win) win->w_python_ref
--- 676,681 ----
***************
*** 926,932 ****
      else
      {
        /* Need to make a copy, value may change when setting new locale. */
!       saved_locale = (char *)vim_strsave((char_u *)saved_locale);
        (void)setlocale(LC_NUMERIC, "C");
      }
  #endif
--- 914,920 ----
      else
      {
        /* Need to make a copy, value may change when setting new locale. */
!       saved_locale = (char *) PY_STRSAVE(saved_locale);
        (void)setlocale(LC_NUMERIC, "C");
      }
  #endif
***************
*** 953,959 ****
      if (saved_locale != NULL)
      {
        (void)setlocale(LC_NUMERIC, saved_locale);
!       vim_free(saved_locale);
      }
  #endif
  
--- 941,947 ----
      if (saved_locale != NULL)
      {
        (void)setlocale(LC_NUMERIC, saved_locale);
!       PyMem_Free(saved_locale);
      }
  #endif
  
*** ../vim-7.3.1041/src/proto/ex_cmds.pro       2012-04-25 17:32:14.000000000 
+0200
--- src/proto/ex_cmds.pro       2013-05-29 21:40:05.000000000 +0200
***************
*** 19,24 ****
--- 19,25 ----
  void do_fixdel __ARGS((exarg_T *eap));
  void print_line_no_prefix __ARGS((linenr_T lnum, int use_number, int list));
  void print_line __ARGS((linenr_T lnum, int use_number, int list));
+ int rename_buffer __ARGS((char_u *new_fname));
  void ex_file __ARGS((exarg_T *eap));
  void ex_update __ARGS((exarg_T *eap));
  void ex_write __ARGS((exarg_T *eap));
*** ../vim-7.3.1041/src/testdir/test86.in       2013-05-21 22:23:51.000000000 
+0200
--- src/testdir/test86.in       2013-05-29 21:56:41.000000000 +0200
***************
*** 476,481 ****
--- 476,485 ----
  :py b=vim.current.buffer
  :wincmd w
  :mark a
+ :augroup BUFS
+ :   autocmd BufFilePost * python cb.append(vim.eval('expand("<abuf>")') + 
':BufFilePost:' + vim.eval('bufnr("%")'))
+ :   autocmd BufFilePre * python cb.append(vim.eval('expand("<abuf>")') + 
':BufFilePre:' + vim.eval('bufnr("%")'))
+ :augroup END
  py << EOF
  cb = vim.current.buffer
  # Tests BufferAppend and BufferItem
***************
*** 496,504 ****
  b[0]='bar'
  b[0:0]=['baz']
  vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
  # Test CheckBuffer
! vim.command('bwipeout! ' + str(b.number))
! for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
      try:
          exec(expr)
      except vim.error:
--- 500,519 ----
  b[0]='bar'
  b[0:0]=['baz']
  vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
+ # Test assigning to name property
+ old_name = cb.name
+ cb.name = 'foo'
+ cb.append(cb.name[-11:])
+ b.name = 'bar'
+ cb.append(b.name[-11:])
+ cb.name = old_name
+ cb.append(cb.name[-17:])
  # Test CheckBuffer
! for _b in vim.buffers:
!     if _b is not cb:
!         vim.command('bwipeout! ' + str(_b.number))
! del _b
! for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")', 'b.name = 
"!"'):
      try:
          exec(expr)
      except vim.error:
***************
*** 507,513 ****
--- 522,533 ----
          # Usually a SEGV here
          # Should not happen in any case
          cb.append('No exception for ' + expr)
+ vim.command('cd .')
  EOF
+ :augroup BUFS
+ :   autocmd!
+ :augroup END
+ :augroup! BUFS
  :"
  :" Test vim.buffers object
  :set hidden
***************
*** 586,592 ****
      else:
          return repr(w)
  
! def Cursor(w, start=len(cb)):
      if w.buffer is cb:
          return repr((start - w.cursor[0], w.cursor[1]))
      else:
--- 606,614 ----
      else:
          return repr(w)
  
! start = len(cb)
! 
! def Cursor(w):
      if w.buffer is cb:
          return repr((start - w.cursor[0], w.cursor[1]))
      else:
*** ../vim-7.3.1041/src/testdir/test86.ok       2013-05-21 22:38:14.000000000 
+0200
--- src/testdir/test86.ok       2013-05-29 21:57:30.000000000 +0200
***************
*** 319,332 ****
  Second line
  Third line
  foo
  i:<buffer test86.in>
  i2:<buffer test86.in>
  i:<buffer a>
  i3:<buffer test86.in>
  1:<buffer test86.in>=<buffer test86.in>
! 6:<buffer a>=<buffer a>
! 7:<buffer b>=<buffer b>
! 8:<buffer c>=<buffer c>
  4
  i4:<buffer test86.in>
  i4:<buffer test86.in>
--- 319,341 ----
  Second line
  Third line
  foo
+ 1:BufFilePre:1
+ 6:BufFilePost:1
+ testdir/foo
+ 5:BufFilePre:5
+ 5:BufFilePost:5
+ testdir/bar
+ 1:BufFilePre:1
+ 7:BufFilePost:1
+ testdir/test86.in
  i:<buffer test86.in>
  i2:<buffer test86.in>
  i:<buffer a>
  i3:<buffer test86.in>
  1:<buffer test86.in>=<buffer test86.in>
! 8:<buffer a>=<buffer a>
! 9:<buffer b>=<buffer b>
! 10:<buffer c>=<buffer c>
  4
  i4:<buffer test86.in>
  i4:<buffer test86.in>
***************
*** 335,341 ****
  Current tab pages:
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
    Windows:
!     <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor 
is at (27, 0)
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
    Windows:
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at 
(1, 0)
--- 344,350 ----
  Current tab pages:
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
    Windows:
!     <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor 
is at (36, 0)
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
    Windows:
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at 
(1, 0)
*** ../vim-7.3.1041/src/testdir/test87.in       2013-05-21 22:23:51.000000000 
+0200
--- src/testdir/test87.in       2013-05-29 21:58:50.000000000 +0200
***************
*** 463,468 ****
--- 463,472 ----
  :py3 b=vim.current.buffer
  :wincmd w
  :mark a
+ :augroup BUFS
+ :   autocmd BufFilePost * python3 cb.append(vim.eval('expand("<abuf>")') + 
':BufFilePost:' + vim.eval('bufnr("%")'))
+ :   autocmd BufFilePre * python3 cb.append(vim.eval('expand("<abuf>")') + 
':BufFilePre:' + vim.eval('bufnr("%")'))
+ :augroup END
  py3 << EOF
  cb = vim.current.buffer
  # Tests BufferAppend and BufferItem
***************
*** 483,490 ****
  b[0]='bar'
  b[0:0]=['baz']
  vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
  # Test CheckBuffer
! vim.command('bwipeout! ' + str(b.number))
  for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
      try:
          exec(expr)
--- 487,505 ----
  b[0]='bar'
  b[0:0]=['baz']
  vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
+ # Test assigning to name property
+ old_name = cb.name
+ cb.name = 'foo'
+ cb.append(cb.name[-11:])
+ b.name = 'bar'
+ cb.append(b.name[-11:])
+ cb.name = old_name
+ cb.append(cb.name[-17:])
  # Test CheckBuffer
! for _b in vim.buffers:
!     if _b is not cb:
!         vim.command('bwipeout! ' + str(_b.number))
! del _b
  for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
      try:
          exec(expr)
***************
*** 494,499 ****
--- 509,515 ----
          # Usually a SEGV here
          # Should not happen in any case
          cb.append('No exception for ' + expr)
+ vim.command('cd .')
  EOF
  :"
  :" Test vim.buffers object
*** ../vim-7.3.1041/src/testdir/test87.ok       2013-05-21 22:38:14.000000000 
+0200
--- src/testdir/test87.ok       2013-05-29 21:59:04.000000000 +0200
***************
*** 308,321 ****
  Second line
  Third line
  foo
  i:<buffer test87.in>
  i2:<buffer test87.in>
  i:<buffer a>
  i3:<buffer test87.in>
  1:<buffer test87.in>=<buffer test87.in>
! 6:<buffer a>=<buffer a>
! 7:<buffer b>=<buffer b>
! 8:<buffer c>=<buffer c>
  4
  i4:<buffer test87.in>
  i4:<buffer test87.in>
--- 308,330 ----
  Second line
  Third line
  foo
+ 1:BufFilePre:1
+ 6:BufFilePost:1
+ testdir/foo
+ 5:BufFilePre:5
+ 5:BufFilePost:5
+ testdir/bar
+ 1:BufFilePre:1
+ 7:BufFilePost:1
+ testdir/test87.in
  i:<buffer test87.in>
  i2:<buffer test87.in>
  i:<buffer a>
  i3:<buffer test87.in>
  1:<buffer test87.in>=<buffer test87.in>
! 8:<buffer a>=<buffer a>
! 9:<buffer b>=<buffer b>
! 10:<buffer c>=<buffer c>
  4
  i4:<buffer test87.in>
  i4:<buffer test87.in>
***************
*** 324,330 ****
  Current tab pages:
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
    Windows:
!     <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor 
is at (27, 0)
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
    Windows:
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at 
(1, 0)
--- 333,339 ----
  Current tab pages:
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
    Windows:
!     <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor 
is at (36, 0)
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
    Windows:
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at 
(1, 0)
*** ../vim-7.3.1041/src/version.c       2013-05-29 21:37:29.000000000 +0200
--- src/version.c       2013-05-29 22:01:11.000000000 +0200
***************
*** 730,731 ****
--- 730,733 ----
  {   /* Add new patch number below this line */
+ /**/
+     1042,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
19. All of your friends have an @ in their names.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

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


Raspunde prin e-mail lui