Permalink
Browse files

updated for version 7.3.1042

Problem:    Python: can't assign to vim.Buffer.name.
Solution:   Python patch 3. (ZyX)
  • Loading branch information...
brammool committed May 29, 2013
1 parent 7d5332d commit d6562c281554b2a706a5d481c544372ffba0ca06
Showing with 262 additions and 152 deletions.
  1. +6 −1 runtime/doc/if_pyth.txt
  2. +55 −45 src/ex_cmds.c
  3. +119 −54 src/if_py_both.h
  4. +2 −14 src/if_python.c
  5. +9 −26 src/if_python3.c
  6. +1 −0 src/proto/ex_cmds.pro
  7. +25 −3 src/testdir/test86.in
  8. +13 −4 src/testdir/test86.ok
  9. +17 −1 src/testdir/test87.in
  10. +13 −4 src/testdir/test87.ok
  11. +2 −0 src/version.c
View
@@ -250,7 +250,7 @@ vim.windows *python-windows*
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.
+ 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,6 +361,11 @@ The buffer object attributes are:
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
View
@@ -784,6 +784,7 @@ do_move(line1, line2, dest)
*/
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,6 +800,7 @@ do_move(line1, line2, dest)
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,16 +2416,65 @@ print_line(lnum, use_number, list)
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]".
*/
void
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
@@ -2437,49 +2488,8 @@ ex_file(eap)
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;
+ if (rename_buffer(eap->arg) == FAIL)
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);
Oops, something went wrong.

0 comments on commit d6562c2

Please sign in to comment.