summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-08-16 17:35:00 +0000
committerBram Moolenaar <Bram@vim.org>2006-08-16 17:35:00 +0000
commitf30e74c11333c37d777b929ea77f5716cc977d27 (patch)
treef5f92c2a1804ccd02aa88290d59cd29de0fe788e /src
parenta7ecc563e8af7ed663ed5b174acd89257ea50fba (diff)
downloadvim-git-f30e74c11333c37d777b929ea77f5716cc977d27.tar.gz
updated for version 7.0-060v7.0.060
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c14
-rw-r--r--src/eval.c13
-rw-r--r--src/fileio.c44
-rw-r--r--src/if_perl.xs41
-rw-r--r--src/if_ruby.c45
-rw-r--r--src/quickfix.c42
-rw-r--r--src/structs.h6
-rw-r--r--src/version.c2
8 files changed, 49 insertions, 158 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 6a7fa2f54..6ffa1cb14 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5420,11 +5420,7 @@ buf_contents_changed(buf)
buf_T *newbuf;
int differ = TRUE;
linenr_T lnum;
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
-#else
- buf_T *old_curbuf = curbuf;
-#endif
exarg_T ea;
/* Allocate a buffer without putting it in the buffer list. */
@@ -5439,13 +5435,8 @@ buf_contents_changed(buf)
return TRUE;
}
-#ifdef FEAT_AUTOCMD
/* set curwin/curbuf to buf and save a few things */
aucmd_prepbuf(&aco, newbuf);
-#else
- curbuf = newbuf;
- curwin->w_buffer = newbuf;
-#endif
if (ml_open(curbuf) == OK
&& readfile(buf->b_ffname, buf->b_fname,
@@ -5466,13 +5457,8 @@ buf_contents_changed(buf)
}
vim_free(ea.cmd);
-#ifdef FEAT_AUTOCMD
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
-#else
- curbuf = old_curbuf;
- curwin->w_buffer = old_curbuf;
-#endif
if (curbuf != newbuf) /* safety check */
wipe_buffer(newbuf, FALSE);
diff --git a/src/eval.c b/src/eval.c
index 642f7ea10..29bec6f46 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -14184,11 +14184,7 @@ f_setbufvar(argvars, rettv)
typval_T *rettv;
{
buf_T *buf;
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
-#else
- buf_T *save_curbuf;
-#endif
char_u *varname, *bufvarname;
typval_T *varp;
char_u nbuf[NUMBUFLEN];
@@ -14205,12 +14201,7 @@ f_setbufvar(argvars, rettv)
if (buf != NULL && varname != NULL && varp != NULL)
{
/* set curbuf to be our buf, temporarily */
-#ifdef FEAT_AUTOCMD
aucmd_prepbuf(&aco, buf);
-#else
- save_curbuf = curbuf;
- curbuf = buf;
-#endif
if (*varname == '&')
{
@@ -14237,11 +14228,7 @@ f_setbufvar(argvars, rettv)
}
/* reset notion of buffer */
-#ifdef FEAT_AUTOCMD
aucmd_restbuf(&aco);
-#else
- curbuf = save_curbuf;
-#endif
}
}
diff --git a/src/fileio.c b/src/fileio.c
index 9f24f6943..cde44d6a8 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6450,17 +6450,10 @@ buf_reload(buf, orig_mode)
int old_ro = buf->b_p_ro;
buf_T *savebuf;
int saved = OK;
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
/* set curwin/curbuf for "buf" and save some things */
aucmd_prepbuf(&aco, buf);
-#else
- buf_T *save_curbuf = curbuf;
-
- curbuf = buf;
- curwin->w_buffer = buf;
-#endif
/* We only want to read the text from the file, not reset the syntax
* highlighting, clear marks, diff status, etc. Force the fileformat
@@ -6573,14 +6566,9 @@ buf_reload(buf, orig_mode)
curbuf->b_p_ro |= old_ro;
}
-#ifdef FEAT_AUTOCMD
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* Careful: autocommands may have made "buf" invalid! */
-#else
- curwin->w_buffer = save_curbuf;
- curbuf = save_curbuf;
-#endif
}
/*ARGSUSED*/
@@ -8088,6 +8076,7 @@ ex_doautoall(eap)
* Search a window for the current buffer. Save the cursor position and
* screen offset.
* Set "curbuf" and "curwin" to match "buf".
+ * When FEAT_AUTOCMD is not defined another version is used, see below.
*/
void
aucmd_prepbuf(aco, buf)
@@ -8151,6 +8140,7 @@ aucmd_prepbuf(aco, buf)
/*
* Cleanup after executing autocommands for a (hidden) buffer.
* Restore the window as it was (if possible).
+ * When FEAT_AUTOCMD is not defined another version is used, see below.
*/
void
aucmd_restbuf(aco)
@@ -9063,8 +9053,38 @@ theend:
return retval;
}
+#else /* FEAT_AUTOCMD */
+
+/*
+ * Prepare for executing commands for (hidden) buffer "buf".
+ * This is the non-autocommand version, it simply saves "curbuf" and sets
+ * "curbuf" and "curwin" to match "buf".
+ */
+ void
+aucmd_prepbuf(aco, buf)
+ aco_save_T *aco; /* structure to save values in */
+ buf_T *buf; /* new curbuf */
+{
+ aco->save_buf = buf;
+ curbuf = buf;
+ curwin->w_buffer = buf;
+}
+
+/*
+ * Restore after executing commands for a (hidden) buffer.
+ * This is the non-autocommand version.
+ */
+ void
+aucmd_restbuf(aco)
+ aco_save_T *aco; /* structure holding saved values */
+{
+ curbuf = aco->save_buf;
+ curwin->w_buffer = curbuf;
+}
+
#endif /* FEAT_AUTOCMD */
+
#if defined(FEAT_AUTOCMD) || defined(FEAT_WILDIGN) || defined(PROTO)
/*
* Try matching a filename with a "pattern" ("prog" is NULL), or use the
diff --git a/src/if_perl.xs b/src/if_perl.xs
index e5259ce35..38ac456e8 100644
--- a/src/if_perl.xs
+++ b/src/if_perl.xs
@@ -1068,30 +1068,20 @@ Set(vimbuf, ...)
line = SvPV(ST(i),PL_na);
if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL)
{
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
/* set curwin/curbuf for "vimbuf" and save some things */
aucmd_prepbuf(&aco, vimbuf);
-#else
- buf_T *save_curbuf = curbuf;
- curbuf = vimbuf;
- curwin->w_buffer = vimbuf;
-#endif
if (u_savesub(lnum) == OK)
{
ml_replace(lnum, (char_u *)line, TRUE);
changed_bytes(lnum, 0);
}
-#ifdef FEAT_AUTOCMD
+
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* Careful: autocommands may have made "vimbuf" invalid! */
-#else
- curwin->w_buffer = save_curbuf;
- curbuf = save_curbuf;
-#endif
}
}
}
@@ -1128,31 +1118,23 @@ Delete(vimbuf, ...)
{
if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count)
{
- buf_T *save_curbuf = curbuf;
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
/* set curwin/curbuf for "vimbuf" and save some things */
aucmd_prepbuf(&aco, vimbuf);
-#else
- curbuf = vimbuf;
- curwin->w_buffer = vimbuf;
-#endif
+
if (u_savedel(lnum, 1) == OK)
{
ml_delete(lnum, 0);
deleted_lines_mark(lnum, 1L);
- if (save_curbuf == curbuf)
+ if (aco.save_buf == curbuf)
check_cursor();
}
-#ifdef FEAT_AUTOCMD
+
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* Careful: autocommands may have made "vimbuf" invalid! */
-#else
- curwin->w_buffer = save_curbuf;
- curbuf = save_curbuf;
-#endif
+
update_curbuf(VALID);
}
}
@@ -1179,30 +1161,21 @@ Append(vimbuf, ...)
line = SvPV(ST(i),PL_na);
if (lnum >= 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL)
{
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
/* set curwin/curbuf for "vimbuf" and save some things */
aucmd_prepbuf(&aco, vimbuf);
-#else
- buf_T *save_curbuf = curbuf;
- curbuf = vimbuf;
- curwin->w_buffer = vimbuf;
-#endif
if (u_inssub(lnum + 1) == OK)
{
ml_append(lnum, (char_u *)line, (colnr_T)0, FALSE);
appended_lines_mark(lnum, 1L);
}
-#ifdef FEAT_AUTOCMD
+
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* Careful: autocommands may have made "vimbuf" invalid! */
-#else
- curwin->w_buffer = save_curbuf;
- curbuf = save_curbuf;
-#endif
+
update_curbuf(VALID);
}
}
diff --git a/src/if_ruby.c b/src/if_ruby.c
index 3685db0bc..a67906aba 100644
--- a/src/if_ruby.c
+++ b/src/if_ruby.c
@@ -644,21 +644,12 @@ static VALUE buffer_aref(VALUE self, VALUE num)
static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
{
char *line = STR2CSTR(str);
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
-#else
- buf_T *save_curbuf = curbuf;
-#endif
if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL)
{
-#ifdef FEAT_AUTOCMD
/* set curwin/curbuf for "buf" and save some things */
aucmd_prepbuf(&aco, buf);
-#else
- curbuf = buf;
- curwin->w_buffer = buf;
-#endif
if (u_savesub(n) == OK) {
ml_replace(n, (char_u *)line, TRUE);
@@ -668,14 +659,10 @@ static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
#endif
}
-#ifdef FEAT_AUTOCMD
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* Careful: autocommands may have made "buf" invalid! */
-#else
- curwin->w_buffer = save_curbuf;
- curbuf = save_curbuf;
-#endif
+
update_curbuf(NOT_VALID);
}
else
@@ -699,21 +686,12 @@ static VALUE buffer_delete(VALUE self, VALUE num)
{
buf_T *buf = get_buf(self);
long n = NUM2LONG(num);
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
-#else
- buf_T *save_curbuf = curbuf;
-#endif
if (n > 0 && n <= buf->b_ml.ml_line_count)
{
-#ifdef FEAT_AUTOCMD
/* set curwin/curbuf for "buf" and save some things */
aucmd_prepbuf(&aco, buf);
-#else
- curbuf = buf;
- curwin->w_buffer = buf;
-#endif
if (u_savedel(n, 1) == OK) {
ml_delete(n, 0);
@@ -725,14 +703,10 @@ static VALUE buffer_delete(VALUE self, VALUE num)
changed();
}
-#ifdef FEAT_AUTOCMD
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* Careful: autocommands may have made "buf" invalid! */
-#else
- curwin->w_buffer = save_curbuf;
- curbuf = save_curbuf;
-#endif
+
update_curbuf(NOT_VALID);
}
else
@@ -747,21 +721,12 @@ static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
buf_T *buf = get_buf(self);
char *line = STR2CSTR(str);
long n = NUM2LONG(num);
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
-#else
- buf_T *save_curbuf = curbuf;
-#endif
if (n >= 0 && n <= buf->b_ml.ml_line_count && line != NULL)
{
-#ifdef FEAT_AUTOCMD
/* set curwin/curbuf for "buf" and save some things */
aucmd_prepbuf(&aco, buf);
-#else
- curbuf = buf;
- curwin->w_buffer = buf;
-#endif
if (u_inssub(n + 1) == OK) {
ml_append(n, (char_u *) line, (colnr_T) 0, FALSE);
@@ -773,14 +738,10 @@ static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
changed();
}
-#ifdef FEAT_AUTOCMD
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* Careful: autocommands may have made "buf" invalid! */
-#else
- curwin->w_buffer = save_curbuf;
- curbuf = save_curbuf;
-#endif
+
update_curbuf(NOT_VALID);
}
else {
diff --git a/src/quickfix.c b/src/quickfix.c
index 8c3dbbff6..6e3fa6afe 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2463,32 +2463,19 @@ qf_update_buffer(qi)
qf_info_T *qi;
{
buf_T *buf;
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
-#else
- buf_T *save_curbuf;
-#endif
/* Check if a buffer for the quickfix list exists. Update it. */
buf = qf_find_buf(qi);
if (buf != NULL)
{
-#ifdef FEAT_AUTOCMD
/* set curwin/curbuf to buf and save a few things */
aucmd_prepbuf(&aco, buf);
-#else
- save_curbuf = curbuf;
- curbuf = buf;
-#endif
qf_fill_buffer(qi);
-#ifdef FEAT_AUTOCMD
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
-#else
- curbuf = save_curbuf;
-#endif
(void)qf_win_pos_update(qi, 0);
}
@@ -2977,10 +2964,8 @@ ex_vimgrep(eap)
#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
char_u *save_ei = NULL;
#endif
-#ifndef FEAT_AUTOCMD
- buf_T *save_curbuf;
-#else
aco_save_T aco;
+#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
int flags = 0;
colnr_T col;
@@ -3201,24 +3186,13 @@ ex_vimgrep(eap)
* need to be done now, in that buffer. And the modelines
* need to be done (again). But not the window-local
* options! */
-#if defined(FEAT_AUTOCMD)
aucmd_prepbuf(&aco, buf);
-#else
- save_curbuf = curbuf;
- curbuf = buf;
- curwin->w_buffer = curbuf;
-#endif
#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
buf->b_fname, TRUE, buf);
#endif
do_modelines(OPT_NOWIN);
-#if defined(FEAT_AUTOCMD)
aucmd_restbuf(&aco);
-#else
- curbuf = save_curbuf;
- curwin->w_buffer = curbuf;
-#endif
}
}
}
@@ -3319,11 +3293,7 @@ load_dummy_buffer(fname)
{
buf_T *newbuf;
int failed = TRUE;
-#ifdef FEAT_AUTOCMD
aco_save_T aco;
-#else
- buf_T *old_curbuf = curbuf;
-#endif
/* Allocate a buffer without putting it in the buffer list. */
newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
@@ -3333,13 +3303,8 @@ load_dummy_buffer(fname)
/* Init the options. */
buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
-#ifdef FEAT_AUTOCMD
/* set curwin/curbuf to buf and save a few things */
aucmd_prepbuf(&aco, newbuf);
-#else
- curbuf = newbuf;
- curwin->w_buffer = newbuf;
-#endif
/* Need to set the filename for autocommands. */
(void)setfname(curbuf, fname, NULL, FALSE);
@@ -3370,13 +3335,8 @@ load_dummy_buffer(fname)
}
}
-#ifdef FEAT_AUTOCMD
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
-#else
- curbuf = old_curbuf;
- curwin->w_buffer = old_curbuf;
-#endif
if (!buf_valid(newbuf))
return NULL;
diff --git a/src/structs.h b/src/structs.h
index 6710b7218..64bbb96bc 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2213,18 +2213,20 @@ typedef int vimmenu_T;
/*
* Struct to save values in before executing autocommands for a buffer that is
- * not the current buffer.
+ * not the current buffer. Without FEAT_AUTOCMD only "curbuf" is remembered.
*/
typedef struct
{
buf_T *save_buf; /* saved curbuf */
+#ifdef FEAT_AUTOCMD
buf_T *new_curbuf; /* buffer to be used */
win_T *save_curwin; /* saved curwin, NULL if it didn't change */
win_T *new_curwin; /* new curwin if save_curwin != NULL */
pos_T save_cursor; /* saved cursor pos of save_curwin */
linenr_T save_topline; /* saved topline of save_curwin */
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
int save_topfill; /* saved topfill of save_curwin */
+# endif
#endif
} aco_save_T;
diff --git a/src/version.c b/src/version.c
index 6174ddfb8..5cfc2346e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 60,
+/**/
59,
/**/
58,