Skip to content

Commit

Permalink
Merged from the latest developing branch.
Browse files Browse the repository at this point in the history
git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1540 2a77ed30-b011-0410-a7ad-c7884a0aa172
  • Loading branch information
edyfox committed Jun 25, 2009
1 parent 4f92679 commit bc7e564
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 62 deletions.
12 changes: 10 additions & 2 deletions runtime/doc/autocmd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ BufDelete Before deleting a buffer from the buffer list.
NOTE: When this autocommand is executed, the
current buffer "%" may be different from the
buffer being deleted "<afile>" and "<abuf>".
Don't change to another buffer, it will cause
problems.
*BufEnter*
BufEnter After entering a buffer. Useful for setting
options for a file type. Also executed when
Expand Down Expand Up @@ -397,6 +399,8 @@ BufUnload Before unloading a buffer. This is when the
NOTE: When this autocommand is executed, the
current buffer "%" may be different from the
buffer being unloaded "<afile>".
Don't change to another buffer, it will cause
problems.
*BufWinEnter*
BufWinEnter After a buffer is displayed in a window. This
can be when the buffer is loaded (after
Expand Down Expand Up @@ -428,6 +432,8 @@ BufWipeout Before completely deleting a buffer. The
NOTE: When this autocommand is executed, the
current buffer "%" may be different from the
buffer being deleted "<afile>".
Don't change to another buffer, it will cause
problems.
*BufWrite* *BufWritePre*
BufWrite or BufWritePre Before writing the whole buffer to a file.
*BufWriteCmd*
Expand Down Expand Up @@ -748,8 +754,10 @@ SwapExists Detected an existing swap file when starting
'a' abort, like hitting CTRL-C
When set to an empty string the user will be
asked, as if there was no SwapExists autocmd.
Note: Do not try to change the buffer, the
results are unpredictable.
*E812*
It is not allowed to change to another buffer,
change a buffer name or change directory
here.
*Syntax*
Syntax When the 'syntax' option has been set. The
pattern is matched against the syntax name.
Expand Down
4 changes: 2 additions & 2 deletions runtime/doc/if_mzsch.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*if_mzsch.txt* For Vim version 7.2. Last change: 2009 May 26
*if_mzsch.txt* For Vim version 7.2. Last change: 2009 Jun 24


VIM REFERENCE MANUAL by Sergey Khorev
Expand Down Expand Up @@ -231,7 +231,7 @@ Windows *mzscheme-window*
(set-cursor (line . col) [window]) Set cursor position.

==============================================================================
5. Dynamic loading *mzscheme-dynamic* *E812*
5. Dynamic loading *mzscheme-dynamic* *E815*

On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
output then includes |+mzscheme/dyn|.
Expand Down
6 changes: 3 additions & 3 deletions src/ex_getln.c
Original file line number Diff line number Diff line change
Expand Up @@ -4874,14 +4874,14 @@ ExpandUserList(xp, num_file, file)
/* Loop over the items in the list. */
for (li = retlist->lv_first; li != NULL; li = li->li_next)
{
if (li->li_tv.v_type != VAR_STRING)
continue; /* Skip non-string items */
if (li->li_tv.v_type != VAR_STRING || li->li_tv.vval.v_string == NULL)
continue; /* Skip non-string items and empty strings */

if (ga_grow(&ga, 1) == FAIL)
break;

((char_u **)ga.ga_data)[ga.ga_len] =
vim_strsave(li->li_tv.vval.v_string);
vim_strsave(li->li_tv.vval.v_string);
++ga.ga_len;
}
list_unref(retlist);
Expand Down
19 changes: 9 additions & 10 deletions src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
#endif
#ifdef UNIX
/* Set swap file protection bits after creating it. */
if (swap_mode > 0 && curbuf->b_ml.ml_mfp->mf_fname != NULL)
if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL
&& curbuf->b_ml.ml_mfp->mf_fname != NULL)
(void)mch_setperm(curbuf->b_ml.ml_mfp->mf_fname, (long)swap_mode);
#endif
}
Expand Down Expand Up @@ -6627,7 +6628,10 @@ buf_check_timestamp(buf, focus)
mesg = _("W16: Warning: Mode of file \"%s\" has changed since editing started");
mesg2 = _("See \":help W16\" for more info.");
}
/* Else: only timestamp changed, ignored */
else
/* Only timestamp changed, store it to avoid a warning
* in check_mtime() later. */
buf->b_mtime_read = buf->b_mtime;
}
}
}
Expand Down Expand Up @@ -8432,9 +8436,9 @@ aucmd_prepbuf(aco, buf)
* effects, insert it in a the current tab page.
* Anything related to a window (e.g., setting folds) may have
* unexpected results. */
curwin = aucmd_win;
curwin->w_buffer = buf;
aucmd_win->w_buffer = buf;
++buf->b_nwindows;
win_init_empty(aucmd_win); /* set cursor and topline to safe values */

#ifdef FEAT_WINDOWS
/* Split the current window, put the aucmd_win in the upper half. */
Expand All @@ -8445,12 +8449,7 @@ aucmd_prepbuf(aco, buf)
(void)win_comp_pos(); /* recompute window positions */
p_ea = save_ea;
#endif
/* set cursor and topline to safe values */
curwin_init();
#ifdef FEAT_VERTSPLIT
curwin->w_wincol = 0;
curwin->w_width = Columns;
#endif
curwin = aucmd_win;
}
curbuf = buf;
aco->new_curwin = curwin;
Expand Down
2 changes: 1 addition & 1 deletion src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ gui_update_cursor(force, clear_selection)
guicolor_T fg, bg;

if (
# ifdef HAVE_GTK2
# if defined(HAVE_GTK2) && !defined(FEAT_HANGULIN)
preedit_get_status()
# else
im_get_status()
Expand Down
2 changes: 1 addition & 1 deletion src/if_mzsch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ mzscheme_init(void)
#ifdef DYNAMIC_MZSCHEME
if (!mzscheme_enabled(TRUE))
{
EMSG(_("E812: Sorry, this command is disabled, the MzScheme libraries could not be loaded."));
EMSG(_("E815: Sorry, this command is disabled, the MzScheme libraries could not be loaded."));
return -1;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/misc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -9193,7 +9193,7 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
else if (vim_strpbrk(p, (char_u *)"$~") != NULL)
{
vim_free(p);
ga_clear(&ga);
ga_clear_strings(&ga);
i = mch_expand_wildcards(num_pat, pat, num_file, file,
flags);
recursive = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/netbeans.c
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ coloncmd(char *cmd, ...)
va_list ap;

va_start(ap, cmd);
vsprintf(buf, cmd, ap);
vim_vsnprintf(buf, sizeof(buf), cmd, ap, NULL);
va_end(ap);

nbdebug((" COLONCMD %s\n", buf));
Expand Down
12 changes: 9 additions & 3 deletions src/os_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,15 @@
*/

#ifdef MACOS_X_UNIX
# define SIGPROTOARG (int)
# define SIGDEFARG(s) (s) int s;
# define SIGDUMMYARG 0
# ifndef SIGPROTOARG
# define SIGPROTOARG (int)
# endif
# ifndef SIGDEFARG
# define SIGDEFARG(s) (s) int s UNUSED;
# endif
# ifndef SIGDUMMYARG
# define SIGDUMMYARG 0
# endif
# undef HAVE_AVAIL_MEM
# ifndef HAVE_CONFIG_H
# define RETSIGTYPE void
Expand Down
1 change: 1 addition & 0 deletions src/proto/window.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void win_free_all __ARGS((void));
win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
void close_others __ARGS((int message, int forceit));
void curwin_init __ARGS((void));
void win_init_empty __ARGS((win_T *wp));
int win_alloc_first __ARGS((void));
void win_alloc_aucmd_win __ARGS((void));
void win_init_size __ARGS((void));
Expand Down
19 changes: 10 additions & 9 deletions src/quickfix.c
Original file line number Diff line number Diff line change
Expand Up @@ -3411,14 +3411,15 @@ load_dummy_buffer(fname)
/* Init the options. */
buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);

/* set curwin/curbuf to buf and save a few things */
aucmd_prepbuf(&aco, newbuf);
/* need to open the memfile before putting the buffer in a window */
if (ml_open(newbuf) == OK)
{
/* set curwin/curbuf to buf and save a few things */
aucmd_prepbuf(&aco, newbuf);

/* Need to set the filename for autocommands. */
(void)setfname(curbuf, fname, NULL, FALSE);
/* Need to set the filename for autocommands. */
(void)setfname(curbuf, fname, NULL, FALSE);

if (ml_open(curbuf) == OK)
{
/* Create swap file now to avoid the ATTENTION message. */
check_need_swap(TRUE);

Expand All @@ -3441,10 +3442,10 @@ load_dummy_buffer(fname)
newbuf = curbuf;
}
}
}

/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
}

if (!buf_valid(newbuf))
return NULL;
Expand Down
8 changes: 5 additions & 3 deletions src/testdir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

VIMPROG = ../vim

# Uncomment this line for using valgrind.
# The output goes into a file "valgrind.$PID" (sorry, no test number).
# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --logfile=valgrind
# Uncomment this line to use valgrind for memory leaks and extra warnings.
# The output goes into a file "valgrind.testN"
# Vim should be compiled with EXITFREE to avoid false warnings.
# This will make testing about 10 times as slow.
# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --log-file=valgrind.$*

SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test7.out test8.out test9.out test10.out test11.out \
Expand Down
18 changes: 18 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,24 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
218,
/**/
217,
/**/
216,
/**/
215,
/**/
214,
/**/
213,
/**/
212,
/**/
211,
/**/
210,
/**/
209,
/**/
Expand Down
62 changes: 36 additions & 26 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2354,13 +2354,6 @@ win_free_mem(win, dirp, tp)
frame_T *frp;
win_T *wp;

#ifdef FEAT_FOLDING
clearFolding(win);
#endif

/* reduce the reference count to the argument list. */
alist_unlink(win->w_alist);

/* Remove the window and its frame from the tree of frames. */
frp = win->w_frame;
wp = winframe_remove(win, dirp, tp);
Expand All @@ -2386,16 +2379,16 @@ win_free_all()
tabpage_close(TRUE);
# endif

while (firstwin != NULL)
(void)win_free_mem(firstwin, &dummy, NULL);

# ifdef FEAT_AUTOCMD
if (aucmd_win != NULL)
{
(void)win_free_mem(aucmd_win, &dummy, NULL);
aucmd_win = NULL;
}
# endif

while (firstwin != NULL)
(void)win_free_mem(firstwin, &dummy, NULL);
}
#endif

Expand Down Expand Up @@ -3204,27 +3197,34 @@ close_others(message, forceit)
void
curwin_init()
{
redraw_win_later(curwin, NOT_VALID);
curwin->w_lines_valid = 0;
curwin->w_cursor.lnum = 1;
curwin->w_curswant = curwin->w_cursor.col = 0;
win_init_empty(curwin);
}

void
win_init_empty(wp)
win_T *wp;
{
redraw_win_later(wp, NOT_VALID);
wp->w_lines_valid = 0;
wp->w_cursor.lnum = 1;
wp->w_curswant = wp->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
wp->w_cursor.coladd = 0;
#endif
curwin->w_pcmark.lnum = 1; /* pcmark not cleared but set to line 1 */
curwin->w_pcmark.col = 0;
curwin->w_prev_pcmark.lnum = 0;
curwin->w_prev_pcmark.col = 0;
curwin->w_topline = 1;
wp->w_pcmark.lnum = 1; /* pcmark not cleared but set to line 1 */
wp->w_pcmark.col = 0;
wp->w_prev_pcmark.lnum = 0;
wp->w_prev_pcmark.col = 0;
wp->w_topline = 1;
#ifdef FEAT_DIFF
curwin->w_topfill = 0;
wp->w_topfill = 0;
#endif
curwin->w_botline = 2;
wp->w_botline = 2;
#ifdef FEAT_FKMAP
if (curwin->w_p_rl)
curwin->w_farsi = W_CONV + W_R_L;
if (wp->w_p_rl)
wp->w_farsi = W_CONV + W_R_L;
else
curwin->w_farsi = W_CONV;
wp->w_farsi = W_CONV;
#endif
}

Expand Down Expand Up @@ -4325,6 +4325,13 @@ win_free(wp, tp)
{
int i;

#ifdef FEAT_FOLDING
clearFolding(wp);
#endif

/* reduce the reference count to the argument list. */
alist_unlink(wp->w_alist);

#ifdef FEAT_AUTOCMD
/* Don't execute autocommands while the window is halfway being deleted.
* gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
Expand Down Expand Up @@ -4387,7 +4394,10 @@ win_free(wp, tp)
}
#endif /* FEAT_GUI */

win_remove(wp, tp);
#ifdef FEAT_AUTOCMD
if (wp != aucmd_win)
#endif
win_remove(wp, tp);
vim_free(wp);

#ifdef FEAT_AUTOCMD
Expand Down

0 comments on commit bc7e564

Please sign in to comment.