home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.2 / 7.2.203 < prev    next >
Encoding:
Internet Message Format  |  2009-06-15  |  39.5 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 7.2.203
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.2.203
  11. Problem:    When reloading a buffer or doing anything else with a buffer that
  12.         is not displayed in a visible window, autocommands may be applied
  13.         to the current window, folds messed up, etc.
  14. Solution:   Instead of using the current window for the hidden buffer use a
  15.         special window, splitting the current one temporarily.
  16. Files:        src/fileio.c, src/globals.h, src/gui.c, src/if_perl.xs,
  17.         src/proto/gui.pro, src/proto/window.pro, src/screen.c,
  18.         src/structs.h, src/window.c
  19.  
  20.  
  21. *** ../vim-7.2.202/src/fileio.c    2009-06-16 15:35:46.000000000 +0200
  22. --- src/fileio.c    2009-06-11 21:22:37.000000000 +0200
  23. ***************
  24. *** 8365,8371 ****
  25.   
  26.           /* Execute the modeline settings, but don't set window-local
  27.            * options if we are using the current window for another buffer. */
  28. !         do_modelines(aco.save_curwin == NULL ? OPT_NOWIN : 0);
  29.   
  30.           /* restore the current window */
  31.           aucmd_restbuf(&aco);
  32. --- 8365,8371 ----
  33.   
  34.           /* Execute the modeline settings, but don't set window-local
  35.            * options if we are using the current window for another buffer. */
  36. !         do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
  37.   
  38.           /* restore the current window */
  39.           aucmd_restbuf(&aco);
  40. ***************
  41. *** 8381,8388 ****
  42.   
  43.   /*
  44.    * Prepare for executing autocommands for (hidden) buffer "buf".
  45. !  * Search a window for the current buffer.  Save the cursor position and
  46. !  * screen offset.
  47.    * Set "curbuf" and "curwin" to match "buf".
  48.    * When FEAT_AUTOCMD is not defined another version is used, see below.
  49.    */
  50. --- 8381,8388 ----
  51.   
  52.   /*
  53.    * Prepare for executing autocommands for (hidden) buffer "buf".
  54. !  * Search for a visible window containing the current buffer.  If there isn't
  55. !  * one then use "aucmd_win".
  56.    * Set "curbuf" and "curwin" to match "buf".
  57.    * When FEAT_AUTOCMD is not defined another version is used, see below.
  58.    */
  59. ***************
  60. *** 8392,8399 ****
  61.       buf_T    *buf;        /* new curbuf */
  62.   {
  63.       win_T    *win;
  64. !     aco->new_curbuf = buf;
  65.   
  66.       /* Find a window that is for the new buffer */
  67.       if (buf == curbuf)        /* be quick when buf is curbuf */
  68. --- 8392,8400 ----
  69.       buf_T    *buf;        /* new curbuf */
  70.   {
  71.       win_T    *win;
  72. ! #ifdef FEAT_WINDOWS
  73. !     int        save_ea;
  74. ! #endif
  75.   
  76.       /* Find a window that is for the new buffer */
  77.       if (buf == curbuf)        /* be quick when buf is curbuf */
  78. ***************
  79. *** 8407,8448 ****
  80.       win = NULL;
  81.   #endif
  82.   
  83. !     /*
  84. !      * Prefer to use an existing window for the buffer, it has the least side
  85. !      * effects (esp. if "buf" is curbuf).
  86. !      * Otherwise, use curwin for "buf".  It might make some items in the
  87. !      * window invalid.  At least save the cursor and topline.
  88. !      */
  89.       if (win != NULL)
  90.       {
  91. !     /* there is a window for "buf", make it the curwin */
  92. !     aco->save_curwin = curwin;
  93.       curwin = win;
  94. -     aco->save_buf = win->w_buffer;
  95. -     aco->new_curwin = win;
  96.       }
  97.       else
  98.       {
  99. !     /* there is no window for "buf", use curwin */
  100. !     aco->save_curwin = NULL;
  101. !     aco->save_buf = curbuf;
  102. !     --curbuf->b_nwindows;
  103.       curwin->w_buffer = buf;
  104.       ++buf->b_nwindows;
  105.   
  106. !     /* save cursor and topline, set them to safe values */
  107. !     aco->save_cursor = curwin->w_cursor;
  108. !     curwin->w_cursor.lnum = 1;
  109. !     curwin->w_cursor.col = 0;
  110. !     aco->save_topline = curwin->w_topline;
  111. !     curwin->w_topline = 1;
  112. ! #ifdef FEAT_DIFF
  113. !     aco->save_topfill = curwin->w_topfill;
  114. !     curwin->w_topfill = 0;
  115.   #endif
  116.       }
  117.       curbuf = buf;
  118.   }
  119.   
  120.   /*
  121. --- 8408,8460 ----
  122.       win = NULL;
  123.   #endif
  124.   
  125. !     /* Allocate "aucmd_win" when needed.  If this fails (out of memory) fall
  126. !      * back to using the current window. */
  127. !     if (win == NULL && aucmd_win == NULL)
  128. !     {
  129. !     win_alloc_aucmd_win();
  130. !     if (aucmd_win == NULL)
  131. !         win = curwin;
  132. !     }
  133. !     aco->save_curwin = curwin;
  134. !     aco->save_curbuf = curbuf;
  135.       if (win != NULL)
  136.       {
  137. !     /* There is a window for "buf" in the current tab page, make it the
  138. !      * curwin.  This is preferred, it has the least side effects (esp. if
  139. !      * "buf" is curbuf). */
  140.       curwin = win;
  141.       }
  142.       else
  143.       {
  144. !     /* There is no window for "buf", use "aucmd_win".  To minimize the side
  145. !      * effects, insert it in a the current tab page.
  146. !      * Anything related to a window (e.g., setting folds) may have
  147. !      * unexpected results. */
  148. !     curwin = aucmd_win;
  149.       curwin->w_buffer = buf;
  150.       ++buf->b_nwindows;
  151.   
  152. ! #ifdef FEAT_WINDOWS
  153. !     /* Split the current window, put the aucmd_win in the upper half. */
  154. !     make_snapshot(SNAP_AUCMD_IDX);
  155. !     save_ea = p_ea;
  156. !     p_ea = FALSE;
  157. !     (void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
  158. !     (void)win_comp_pos();   /* recompute window positions */
  159. !     p_ea = save_ea;
  160. ! #endif
  161. !     /* set cursor and topline to safe values */
  162. !     curwin_init();
  163. ! #ifdef FEAT_VERTSPLIT
  164. !     curwin->w_wincol = 0;
  165. !     curwin->w_width = Columns;
  166.   #endif
  167.       }
  168.       curbuf = buf;
  169. +     aco->new_curwin = curwin;
  170. +     aco->new_curbuf = curbuf;
  171.   }
  172.   
  173.   /*
  174. ***************
  175. *** 8454,8474 ****
  176.   aucmd_restbuf(aco)
  177.       aco_save_T    *aco;        /* structure holding saved values */
  178.   {
  179. !     if (aco->save_curwin != NULL)
  180.       {
  181.       /* restore curwin */
  182.   #ifdef FEAT_WINDOWS
  183.       if (win_valid(aco->save_curwin))
  184.   #endif
  185.       {
  186. !         /* restore the buffer which was previously edited by curwin, if
  187. !          * it's still the same window and it's valid */
  188.           if (curwin == aco->new_curwin
  189. !             && buf_valid(aco->save_buf)
  190. !             && aco->save_buf->b_ml.ml_mfp != NULL)
  191.           {
  192.           --curbuf->b_nwindows;
  193. !         curbuf = aco->save_buf;
  194.           curwin->w_buffer = curbuf;
  195.           ++curbuf->b_nwindows;
  196.           }
  197. --- 8466,8551 ----
  198.   aucmd_restbuf(aco)
  199.       aco_save_T    *aco;        /* structure holding saved values */
  200.   {
  201. ! #ifdef FEAT_WINDOWS
  202. !     int dummy;
  203. ! #endif
  204. !     if (aco->new_curwin == aucmd_win)
  205. !     {
  206. !     --curbuf->b_nwindows;
  207. ! #ifdef FEAT_WINDOWS
  208. !     /* Find "aucmd_win", it can't be closed, but it may be in another tab
  209. !      * page. */
  210. !     if (curwin != aucmd_win)
  211. !     {
  212. !         tabpage_T    *tp;
  213. !         win_T    *wp;
  214. !         FOR_ALL_TAB_WINDOWS(tp, wp)
  215. !         {
  216. !         if (wp == aucmd_win)
  217. !         {
  218. !             if (tp != curtab)
  219. !             goto_tabpage_tp(tp);
  220. !             win_goto(aucmd_win);
  221. !             break;
  222. !         }
  223. !         }
  224. !     }
  225. !     /* Remove the window and frame from the tree of frames. */
  226. !     (void)winframe_remove(curwin, &dummy, NULL);
  227. !     win_remove(curwin, NULL);
  228. !     last_status(FALSE);        /* may need to remove last status line */
  229. !     restore_snapshot(SNAP_AUCMD_IDX, FALSE);
  230. !     (void)win_comp_pos();   /* recompute window positions */
  231. !     if (win_valid(aco->save_curwin))
  232. !         curwin = aco->save_curwin;
  233. !     else
  234. !         /* Hmm, original window disappeared.  Just use the first one. */
  235. !         curwin = firstwin;
  236. ! # ifdef FEAT_EVAL
  237. !     vars_clear(&aucmd_win->w_vars.dv_hashtab);  /* free all w: variables */
  238. ! # endif
  239. ! #else
  240. !     curwin = aco->save_curwin;
  241. ! #endif
  242. !     curbuf = curwin->w_buffer;
  243. !     /* the buffer contents may have changed */
  244. !     check_cursor();
  245. !     if (curwin->w_topline > curbuf->b_ml.ml_line_count)
  246. !     {
  247. !         curwin->w_topline = curbuf->b_ml.ml_line_count;
  248. ! #ifdef FEAT_DIFF
  249. !         curwin->w_topfill = 0;
  250. ! #endif
  251. !     }
  252. ! #if defined(FEAT_GUI)
  253. !     /* Hide the scrollbars from the aucmd_win and update. */
  254. !     gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_LEFT], FALSE);
  255. !     gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_RIGHT], FALSE);
  256. !     gui_may_update_scrollbars();
  257. ! #endif
  258. !     }
  259. !     else
  260.       {
  261.       /* restore curwin */
  262.   #ifdef FEAT_WINDOWS
  263.       if (win_valid(aco->save_curwin))
  264.   #endif
  265.       {
  266. !         /* Restore the buffer which was previously edited by curwin, if
  267. !          * it was chagned, we are still the same window and the buffer is
  268. !          * valid. */
  269.           if (curwin == aco->new_curwin
  270. !             && curbuf != aco->new_curbuf
  271. !             && buf_valid(aco->new_curbuf)
  272. !             && aco->new_curbuf->b_ml.ml_mfp != NULL)
  273.           {
  274.           --curbuf->b_nwindows;
  275. !         curbuf = aco->new_curbuf;
  276.           curwin->w_buffer = curbuf;
  277.           ++curbuf->b_nwindows;
  278.           }
  279. ***************
  280. *** 8477,8510 ****
  281.           curbuf = curwin->w_buffer;
  282.       }
  283.       }
  284. -     else
  285. -     {
  286. -     /* restore buffer for curwin if it still exists and is loaded */
  287. -     if (buf_valid(aco->save_buf) && aco->save_buf->b_ml.ml_mfp != NULL)
  288. -     {
  289. -         --curbuf->b_nwindows;
  290. -         curbuf = aco->save_buf;
  291. -         curwin->w_buffer = curbuf;
  292. -         ++curbuf->b_nwindows;
  293. -         curwin->w_cursor = aco->save_cursor;
  294. -         check_cursor();
  295. -         /* check topline < line_count, in case lines got deleted */
  296. -         if (aco->save_topline <= curbuf->b_ml.ml_line_count)
  297. -         {
  298. -         curwin->w_topline = aco->save_topline;
  299. - #ifdef FEAT_DIFF
  300. -         curwin->w_topfill = aco->save_topfill;
  301. - #endif
  302. -         }
  303. -         else
  304. -         {
  305. -         curwin->w_topline = curbuf->b_ml.ml_line_count;
  306. - #ifdef FEAT_DIFF
  307. -         curwin->w_topfill = 0;
  308. - #endif
  309. -         }
  310. -     }
  311. -     }
  312.   }
  313.   
  314.   static int    autocmd_nested = FALSE;
  315. --- 8554,8559 ----
  316. ***************
  317. *** 9419,9427 ****
  318.       aco_save_T    *aco;        /* structure to save values in */
  319.       buf_T    *buf;        /* new curbuf */
  320.   {
  321. !     aco->save_buf = curbuf;
  322.       curbuf = buf;
  323.       curwin->w_buffer = buf;
  324.   }
  325.   
  326.   /*
  327. --- 9468,9478 ----
  328.       aco_save_T    *aco;        /* structure to save values in */
  329.       buf_T    *buf;        /* new curbuf */
  330.   {
  331. !     aco->save_curbuf = curbuf;
  332. !     --curbuf->b_nwindows;
  333.       curbuf = buf;
  334.       curwin->w_buffer = buf;
  335. +     ++curbuf->b_nwindows;
  336.   }
  337.   
  338.   /*
  339. ***************
  340. *** 9432,9439 ****
  341.   aucmd_restbuf(aco)
  342.       aco_save_T    *aco;        /* structure holding saved values */
  343.   {
  344. !     curbuf = aco->save_buf;
  345.       curwin->w_buffer = curbuf;
  346.   }
  347.   
  348.   #endif    /* FEAT_AUTOCMD */
  349. --- 9483,9492 ----
  350.   aucmd_restbuf(aco)
  351.       aco_save_T    *aco;        /* structure holding saved values */
  352.   {
  353. !     --curbuf->b_nwindows;
  354. !     curbuf = aco->save_curbuf;
  355.       curwin->w_buffer = curbuf;
  356. +     ++curbuf->b_nwindows;
  357.   }
  358.   
  359.   #endif    /* FEAT_AUTOCMD */
  360. *** ../vim-7.2.202/src/globals.h    2009-06-16 15:23:07.000000000 +0200
  361. --- src/globals.h    2009-06-12 21:10:30.000000000 +0200
  362. ***************
  363. *** 539,544 ****
  364. --- 539,548 ----
  365.   
  366.   EXTERN win_T    *curwin;    /* currently active window */
  367.   
  368. + #ifdef FEAT_AUTOCMD
  369. + EXTERN win_T    *aucmd_win;    /* window used in aucmd_prepbuf() */
  370. + #endif
  371.   /*
  372.    * The window layout is kept in a tree of frames.  topframe points to the top
  373.    * of the tree.
  374. *** ../vim-7.2.202/src/gui.c    2009-05-21 23:25:38.000000000 +0200
  375. --- src/gui.c    2009-06-11 20:58:05.000000000 +0200
  376. ***************
  377. *** 3879,3884 ****
  378. --- 3879,3899 ----
  379.    * Scrollbar stuff:
  380.    */
  381.   
  382. + /*
  383. +  * Called when something in the window layout has changed.
  384. +  */
  385. +     void
  386. + gui_may_update_scrollbars()
  387. + {
  388. +     if (gui.in_use && starting == 0)
  389. +     {
  390. +     out_flush();
  391. +     gui_init_which_components(NULL);
  392. +     gui_update_scrollbars(TRUE);
  393. +     }
  394. +     need_mouse_correct = TRUE;
  395. + }
  396.       void
  397.   gui_update_scrollbars(force)
  398.       int        force;        /* Force all scrollbars to get updated */
  399. *** ../vim-7.2.202/src/if_perl.xs    2008-12-03 13:18:16.000000000 +0100
  400. --- src/if_perl.xs    2009-06-03 17:52:51.000000000 +0200
  401. ***************
  402. *** 1234,1240 ****
  403.               {
  404.               ml_delete(lnum, 0);
  405.               deleted_lines_mark(lnum, 1L);
  406. !             if (aco.save_buf == curbuf)
  407.                   check_cursor();
  408.               }
  409.   
  410. --- 1236,1242 ----
  411.               {
  412.               ml_delete(lnum, 0);
  413.               deleted_lines_mark(lnum, 1L);
  414. !             if (aco.save_curbuf == curbuf)
  415.                   check_cursor();
  416.               }
  417.   
  418. *** ../vim-7.2.202/src/proto/gui.pro    2007-05-05 19:42:19.000000000 +0200
  419. --- src/proto/gui.pro    2009-06-11 20:58:08.000000000 +0200
  420. ***************
  421. *** 43,48 ****
  422. --- 43,49 ----
  423.   void gui_create_scrollbar __ARGS((scrollbar_T *sb, int type, win_T *wp));
  424.   scrollbar_T *gui_find_scrollbar __ARGS((long ident));
  425.   void gui_drag_scrollbar __ARGS((scrollbar_T *sb, long value, int still_dragging));
  426. + void gui_may_update_scrollbars __ARGS((void));
  427.   void gui_update_scrollbars __ARGS((int force));
  428.   int gui_do_scroll __ARGS((void));
  429.   int gui_do_horiz_scroll __ARGS((void));
  430. *** ../vim-7.2.202/src/proto/window.pro    2007-07-26 22:57:45.000000000 +0200
  431. --- src/proto/window.pro    2009-06-10 21:20:39.000000000 +0200
  432. ***************
  433. *** 1,6 ****
  434. --- 1,7 ----
  435.   /* window.c */
  436.   void do_window __ARGS((int nchar, long Prenum, int xchar));
  437.   int win_split __ARGS((int size, int flags));
  438. + int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
  439.   int win_valid __ARGS((win_T *win));
  440.   int win_count __ARGS((void));
  441.   int make_windows __ARGS((int count, int vertical));
  442. ***************
  443. *** 10,18 ****
  444. --- 11,21 ----
  445.   void win_close __ARGS((win_T *win, int free_buf));
  446.   void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
  447.   void win_free_all __ARGS((void));
  448. + win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
  449.   void close_others __ARGS((int message, int forceit));
  450.   void curwin_init __ARGS((void));
  451.   int win_alloc_first __ARGS((void));
  452. + void win_alloc_aucmd_win __ARGS((void));
  453.   void win_init_size __ARGS((void));
  454.   void free_tabpage __ARGS((tabpage_T *tp));
  455.   int win_new_tabpage __ARGS((int after));
  456. ***************
  457. *** 30,35 ****
  458. --- 33,40 ----
  459.   void win_enter __ARGS((win_T *wp, int undo_sync));
  460.   win_T *buf_jump_open_win __ARGS((buf_T *buf));
  461.   win_T *buf_jump_open_tab __ARGS((buf_T *buf));
  462. + void win_append __ARGS((win_T *after, win_T *wp));
  463. + void win_remove __ARGS((win_T *wp, tabpage_T *tp));
  464.   int win_alloc_lines __ARGS((win_T *wp));
  465.   void win_free_lsize __ARGS((win_T *wp));
  466.   void shell_new_rows __ARGS((void));
  467. ***************
  468. *** 58,63 ****
  469. --- 63,70 ----
  470.   int min_rows __ARGS((void));
  471.   int only_one_window __ARGS((void));
  472.   void check_lnums __ARGS((int do_curwin));
  473. + void make_snapshot __ARGS((int idx));
  474. + void restore_snapshot __ARGS((int idx, int close_curwin));
  475.   int win_hasvertsplit __ARGS((void));
  476.   int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
  477.   int match_delete __ARGS((win_T *wp, int id, int perr));
  478. *** ../vim-7.2.202/src/screen.c    2009-05-17 13:30:58.000000000 +0200
  479. --- src/screen.c    2009-06-10 16:41:45.000000000 +0200
  480. ***************
  481. *** 7495,7500 ****
  482. --- 7495,7504 ----
  483.   #endif
  484.       }
  485.       }
  486. + #ifdef FEAT_AUTOCMD
  487. +     if (aucmd_win != NULL && win_alloc_lines(aucmd_win) == FAIL)
  488. +     outofmem = TRUE;
  489. + #endif
  490.   #ifdef FEAT_WINDOWS
  491.   give_up:
  492.   #endif
  493. *** ../vim-7.2.202/src/structs.h    2009-05-16 16:36:25.000000000 +0200
  494. --- src/structs.h    2009-06-13 12:51:56.000000000 +0200
  495. ***************
  496. *** 1621,1626 ****
  497. --- 1621,1634 ----
  498.   };
  499.   #endif
  500.   
  501. + #define SNAP_HELP_IDX    0
  502. + #ifdef FEAT_AUTOCMD
  503. + # define SNAP_AUCMD_IDX 1
  504. + # define SNAP_COUNT    2
  505. + #else
  506. + # define SNAP_COUNT    1
  507. + #endif
  508.   /*
  509.    * Tab pages point to the top frame of each tab page.
  510.    * Note: Most values are NOT valid for the current tab page!  Use "curwin",
  511. ***************
  512. *** 1649,1655 ****
  513.       buf_T        *(tp_diffbuf[DB_COUNT]);
  514.       int            tp_diff_invalid;    /* list of diffs is outdated */
  515.   #endif
  516. !     frame_T        *tp_snapshot;    /* window layout snapshot */
  517.   #ifdef FEAT_EVAL
  518.       dictitem_T        tp_winvar;        /* variable for "t:" Dictionary */
  519.       dict_T        tp_vars;        /* internal variables, local to tab page */
  520. --- 1657,1663 ----
  521.       buf_T        *(tp_diffbuf[DB_COUNT]);
  522.       int            tp_diff_invalid;    /* list of diffs is outdated */
  523.   #endif
  524. !     frame_T        *(tp_snapshot[SNAP_COUNT]);  /* window layout snapshots */
  525.   #ifdef FEAT_EVAL
  526.       dictitem_T        tp_winvar;        /* variable for "t:" Dictionary */
  527.       dict_T        tp_vars;        /* internal variables, local to tab page */
  528. ***************
  529. *** 2276,2291 ****
  530.    */
  531.   typedef struct
  532.   {
  533. !     buf_T    *save_buf;    /* saved curbuf */
  534.   #ifdef FEAT_AUTOCMD
  535. !     buf_T    *new_curbuf;    /* buffer to be used */
  536. !     win_T    *save_curwin;    /* saved curwin, NULL if it didn't change */
  537. !     win_T    *new_curwin;    /* new curwin if save_curwin != NULL */
  538. !     pos_T    save_cursor;    /* saved cursor pos of save_curwin */
  539. !     linenr_T    save_topline;    /* saved topline of save_curwin */
  540. ! # ifdef FEAT_DIFF
  541. !     int        save_topfill;    /* saved topfill of save_curwin */
  542. ! # endif
  543.   #endif
  544.   } aco_save_T;
  545.   
  546. --- 2284,2294 ----
  547.    */
  548.   typedef struct
  549.   {
  550. !     buf_T    *save_curbuf;    /* saved curbuf */
  551.   #ifdef FEAT_AUTOCMD
  552. !     win_T    *save_curwin;    /* saved curwin */
  553. !     win_T    *new_curwin;    /* new curwin */
  554. !     buf_T    *new_curbuf;    /* new curbuf */
  555.   #endif
  556.   } aco_save_T;
  557.   
  558. *** ../vim-7.2.202/src/window.c    2009-05-21 23:25:38.000000000 +0200
  559. --- src/window.c    2009-06-12 22:29:33.000000000 +0200
  560. ***************
  561. *** 11,18 ****
  562.   
  563.   static int path_is_url __ARGS((char_u *p));
  564.   #if defined(FEAT_WINDOWS) || defined(PROTO)
  565. - static int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
  566.   static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
  567.   static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
  568.   static void frame_setheight __ARGS((frame_T *curfrp, int height));
  569.   #ifdef FEAT_VERTSPLIT
  570. --- 11,18 ----
  571.   
  572.   static int path_is_url __ARGS((char_u *p));
  573.   #if defined(FEAT_WINDOWS) || defined(PROTO)
  574.   static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
  575. + static void win_init_some __ARGS((win_T *newp, win_T *oldp));
  576.   static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
  577.   static void frame_setheight __ARGS((frame_T *curfrp, int height));
  578.   #ifdef FEAT_VERTSPLIT
  579. ***************
  580. *** 23,30 ****
  581.   static void win_totop __ARGS((int size, int flags));
  582.   static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
  583.   static int last_window __ARGS((void));
  584.   static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
  585. - static win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
  586.   static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
  587.   static tabpage_T *alt_tabpage __ARGS((void));
  588.   static win_T *frame2win __ARGS((frame_T *frp));
  589. --- 23,30 ----
  590.   static void win_totop __ARGS((int size, int flags));
  591.   static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
  592.   static int last_window __ARGS((void));
  593. + static int one_window __ARGS((void));
  594.   static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
  595.   static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
  596.   static tabpage_T *alt_tabpage __ARGS((void));
  597.   static win_T *frame2win __ARGS((frame_T *frp));
  598. ***************
  599. *** 41,46 ****
  600. --- 41,47 ----
  601.   #endif
  602.   #endif
  603.   static int win_alloc_firstwin __ARGS((win_T *oldwin));
  604. + static void new_frame __ARGS((win_T *wp));
  605.   #if defined(FEAT_WINDOWS) || defined(PROTO)
  606.   static tabpage_T *alloc_tabpage __ARGS((void));
  607.   static int leave_tabpage __ARGS((buf_T *new_curbuf));
  608. ***************
  609. *** 49,56 ****
  610.   static int frame_minheight __ARGS((frame_T *topfrp, win_T *next_curwin));
  611.   static void win_enter_ext __ARGS((win_T *wp, int undo_sync, int no_curwin));
  612.   static void win_free __ARGS((win_T *wp, tabpage_T *tp));
  613. - static void win_append __ARGS((win_T *, win_T *));
  614. - static void win_remove __ARGS((win_T *, tabpage_T *tp));
  615.   static void frame_append __ARGS((frame_T *after, frame_T *frp));
  616.   static void frame_insert __ARGS((frame_T *before, frame_T *frp));
  617.   static void frame_remove __ARGS((frame_T *frp));
  618. --- 50,55 ----
  619. ***************
  620. *** 62,78 ****
  621.   static void frame_add_height __ARGS((frame_T *frp, int n));
  622.   static void last_status_rec __ARGS((frame_T *fr, int statusline));
  623.   
  624. - static void make_snapshot __ARGS((void));
  625.   static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
  626. ! static void clear_snapshot __ARGS((tabpage_T *tp));
  627.   static void clear_snapshot_rec __ARGS((frame_T *fr));
  628. - static void restore_snapshot __ARGS((int close_curwin));
  629.   static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
  630.   static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
  631.   
  632.   #endif /* FEAT_WINDOWS */
  633.   
  634. ! static win_T *win_alloc __ARGS((win_T *after));
  635.   static void win_new_height __ARGS((win_T *, int));
  636.   
  637.   #define URL_SLASH    1        /* path_is_url() has found "://" */
  638. --- 61,75 ----
  639.   static void frame_add_height __ARGS((frame_T *frp, int n));
  640.   static void last_status_rec __ARGS((frame_T *fr, int statusline));
  641.   
  642.   static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
  643. ! static void clear_snapshot __ARGS((tabpage_T *tp, int idx));
  644.   static void clear_snapshot_rec __ARGS((frame_T *fr));
  645.   static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
  646.   static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
  647.   
  648.   #endif /* FEAT_WINDOWS */
  649.   
  650. ! static win_T *win_alloc __ARGS((win_T *after, int hidden));
  651.   static void win_new_height __ARGS((win_T *, int));
  652.   
  653.   #define URL_SLASH    1        /* path_is_url() has found "://" */
  654. ***************
  655. *** 259,265 ****
  656.   /* cursor to previous window with wrap around */
  657.       case 'W':
  658.           CHECK_CMDWIN
  659. !         if (lastwin == firstwin && Prenum != 1)    /* just one window */
  660.               beep_flush();
  661.           else
  662.           {
  663. --- 256,262 ----
  664.   /* cursor to previous window with wrap around */
  665.       case 'W':
  666.           CHECK_CMDWIN
  667. !         if (firstwin == lastwin && Prenum != 1)    /* just one window */
  668.               beep_flush();
  669.           else
  670.           {
  671. ***************
  672. *** 343,349 ****
  673.   
  674.   /* move window to new tab page */
  675.       case 'T':
  676. !         if (firstwin == lastwin)
  677.               MSG(_(m_onlyone));
  678.           else
  679.           {
  680. --- 340,346 ----
  681.   
  682.   /* move window to new tab page */
  683.       case 'T':
  684. !         if (one_window())
  685.               MSG(_(m_onlyone));
  686.           else
  687.           {
  688. ***************
  689. *** 679,687 ****
  690.       /* When creating the help window make a snapshot of the window layout.
  691.        * Otherwise clear the snapshot, it's now invalid. */
  692.       if (flags & WSP_HELP)
  693. !     make_snapshot();
  694.       else
  695. !     clear_snapshot(curtab);
  696.   
  697.       return win_split_ins(size, flags, NULL, 0);
  698.   }
  699. --- 676,684 ----
  700.       /* When creating the help window make a snapshot of the window layout.
  701.        * Otherwise clear the snapshot, it's now invalid. */
  702.       if (flags & WSP_HELP)
  703. !     make_snapshot(SNAP_HELP_IDX);
  704.       else
  705. !     clear_snapshot(curtab, SNAP_HELP_IDX);
  706.   
  707.       return win_split_ins(size, flags, NULL, 0);
  708.   }
  709. ***************
  710. *** 692,698 ****
  711.    * top/left/right/bottom.
  712.    * return FAIL for failure, OK otherwise
  713.    */
  714. !     static int
  715.   win_split_ins(size, flags, newwin, dir)
  716.       int        size;
  717.       int        flags;
  718. --- 689,695 ----
  719.    * top/left/right/bottom.
  720.    * return FAIL for failure, OK otherwise
  721.    */
  722. !     int
  723.   win_split_ins(size, flags, newwin, dir)
  724.       int        size;
  725.       int        flags;
  726. ***************
  727. *** 893,906 ****
  728.       {
  729.       /* new window below/right of current one */
  730.       if (newwin == NULL)
  731. !         wp = win_alloc(oldwin);
  732.       else
  733.           win_append(oldwin, wp);
  734.       }
  735.       else
  736.       {
  737.       if (newwin == NULL)
  738. !         wp = win_alloc(oldwin->w_prev);
  739.       else
  740.           win_append(oldwin->w_prev, wp);
  741.       }
  742. --- 890,903 ----
  743.       {
  744.       /* new window below/right of current one */
  745.       if (newwin == NULL)
  746. !         wp = win_alloc(oldwin, FALSE);
  747.       else
  748.           win_append(oldwin, wp);
  749.       }
  750.       else
  751.       {
  752.       if (newwin == NULL)
  753. !         wp = win_alloc(oldwin->w_prev, FALSE);
  754.       else
  755.           win_append(oldwin->w_prev, wp);
  756.       }
  757. ***************
  758. *** 910,915 ****
  759. --- 907,919 ----
  760.       if (wp == NULL)
  761.           return FAIL;
  762.   
  763. +     new_frame(wp);
  764. +     if (wp->w_frame == NULL)
  765. +     {
  766. +         win_free(wp, NULL);
  767. +         return FAIL;
  768. +     }
  769.       /* make the contents of the new window the same as the current one */
  770.       win_init(wp, curwin, flags);
  771.       }
  772. ***************
  773. *** 970,982 ****
  774.       }
  775.   
  776.       if (newwin == NULL)
  777. !     {
  778. !     /* Create a frame for the new window. */
  779. !     frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
  780. !     frp->fr_layout = FR_LEAF;
  781. !     frp->fr_win = wp;
  782. !     wp->w_frame = frp;
  783. !     }
  784.       else
  785.       frp = newwin->w_frame;
  786.       frp->fr_parent = curfrp->fr_parent;
  787. --- 974,980 ----
  788.       }
  789.   
  790.       if (newwin == NULL)
  791. !     frp = wp->w_frame;
  792.       else
  793.       frp = newwin->w_frame;
  794.       frp->fr_parent = curfrp->fr_parent;
  795. ***************
  796. *** 1156,1161 ****
  797. --- 1154,1160 ----
  798.       return OK;
  799.   }
  800.   
  801.   /*
  802.    * Initialize window "newp" from window "oldp".
  803.    * Used when splitting a window and when creating a new tab page.
  804. ***************
  805. *** 1204,1217 ****
  806.       if (oldp->w_localdir != NULL)
  807.       newp->w_localdir = vim_strsave(oldp->w_localdir);
  808.   
  809. !     /* Use the same argument list. */
  810. !     newp->w_alist = oldp->w_alist;
  811. !     ++newp->w_alist->al_refcount;
  812. !     newp->w_arg_idx = oldp->w_arg_idx;
  813. !     /*
  814. !      * copy tagstack and options from existing window
  815. !      */
  816.       for (i = 0; i < oldp->w_tagstacklen; i++)
  817.       {
  818.       newp->w_tagstack[i] = oldp->w_tagstack[i];
  819. --- 1203,1209 ----
  820.       if (oldp->w_localdir != NULL)
  821.       newp->w_localdir = vim_strsave(oldp->w_localdir);
  822.   
  823. !     /* copy tagstack and folds */
  824.       for (i = 0; i < oldp->w_tagstacklen; i++)
  825.       {
  826.       newp->w_tagstack[i] = oldp->w_tagstack[i];
  827. ***************
  828. *** 1221,1230 ****
  829.       }
  830.       newp->w_tagstackidx = oldp->w_tagstackidx;
  831.       newp->w_tagstacklen = oldp->w_tagstacklen;
  832. -     win_copy_options(oldp, newp);
  833.   # ifdef FEAT_FOLDING
  834.       copyFoldingState(oldp, newp);
  835.   # endif
  836.   }
  837.   
  838.   #endif /* FEAT_WINDOWS */
  839. --- 1213,1241 ----
  840.       }
  841.       newp->w_tagstackidx = oldp->w_tagstackidx;
  842.       newp->w_tagstacklen = oldp->w_tagstacklen;
  843.   # ifdef FEAT_FOLDING
  844.       copyFoldingState(oldp, newp);
  845.   # endif
  846. +     win_init_some(newp, oldp);
  847. + }
  848. + /*
  849. +  * Initialize window "newp" from window"old".
  850. +  * Only the essential things are copied.
  851. +  */
  852. +     static void
  853. + win_init_some(newp, oldp)
  854. +     win_T    *newp;
  855. +     win_T    *oldp;
  856. + {
  857. +     /* Use the same argument list. */
  858. +     newp->w_alist = oldp->w_alist;
  859. +     ++newp->w_alist->al_refcount;
  860. +     newp->w_arg_idx = oldp->w_arg_idx;
  861. +     /* copy options from existing window */
  862. +     win_copy_options(oldp, newp);
  863.   }
  864.   
  865.   #endif /* FEAT_WINDOWS */
  866. ***************
  867. *** 1565,1579 ****
  868.   #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
  869.       /* When 'guioptions' includes 'L' or 'R' may have to remove or add
  870.        * scrollbars.  Have to update them anyway. */
  871. !     if (gui.in_use)
  872. !     {
  873. !     out_flush();
  874. !     gui_init_which_components(NULL);
  875. !     gui_update_scrollbars(TRUE);
  876. !     }
  877. !     need_mouse_correct = TRUE;
  878.   #endif
  879.   }
  880.   
  881.   /*
  882. --- 1576,1583 ----
  883.   #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
  884.       /* When 'guioptions' includes 'L' or 'R' may have to remove or add
  885.        * scrollbars.  Have to update them anyway. */
  886. !     gui_may_update_scrollbars();
  887.   #endif
  888.   }
  889.   
  890.   /*
  891. ***************
  892. *** 2048,2060 ****
  893.   }
  894.   
  895.   /*
  896. !  * Return TRUE if the current window is the only window that exists.
  897.    * Returns FALSE if there is a window, possibly in another tab page.
  898.    */
  899.       static int
  900.   last_window()
  901.   {
  902. !     return (lastwin == firstwin && first_tabpage->tp_next == NULL);
  903.   }
  904.   
  905.   /*
  906. --- 2052,2091 ----
  907.   }
  908.   
  909.   /*
  910. !  * Return TRUE if the current window is the only window that exists (ignoring
  911. !  * "aucmd_win").
  912.    * Returns FALSE if there is a window, possibly in another tab page.
  913.    */
  914.       static int
  915.   last_window()
  916.   {
  917. !     return (one_window() && first_tabpage->tp_next == NULL);
  918. ! }
  919. ! /*
  920. !  * Return TRUE if there is only one window other than "aucmd_win" in the
  921. !  * current tab page.
  922. !  */
  923. !     static int
  924. ! one_window()
  925. ! {
  926. ! #ifdef FEAT_AUTOCMD
  927. !     win_T    *wp;
  928. !     int        seen_one = FALSE;
  929. !     FOR_ALL_WINDOWS(wp)
  930. !     {
  931. !     if (wp != aucmd_win)
  932. !     {
  933. !         if (seen_one)
  934. !         return FALSE;
  935. !         seen_one = TRUE;
  936. !     }
  937. !     }
  938. !     return TRUE;
  939. ! #else
  940. !     return firstwin == lastwin;
  941. ! #endif
  942.   }
  943.   
  944.   /*
  945. ***************
  946. *** 2083,2088 ****
  947. --- 2114,2132 ----
  948.       return;
  949.       }
  950.   
  951. + #ifdef FEAT_AUTOCMD
  952. +     if (win == aucmd_win)
  953. +     {
  954. +     EMSG(_("E813: Cannot close autocmd window"));
  955. +     return;
  956. +     }
  957. +     if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
  958. +     {
  959. +     EMSG(_("E814: Cannot close window, only autocmd window would remain"));
  960. +     return;
  961. +     }
  962. + #endif
  963.       /*
  964.        * When closing the last window in a tab page first go to another tab
  965.        * page and then close the window and the tab page.  This avoids that
  966. ***************
  967. *** 2112,2118 ****
  968.       if (win->w_buffer->b_help)
  969.       help_window = TRUE;
  970.       else
  971. !     clear_snapshot(curtab);
  972.   
  973.   #ifdef FEAT_AUTOCMD
  974.       if (win == curwin)
  975. --- 2156,2162 ----
  976.       if (win->w_buffer->b_help)
  977.       help_window = TRUE;
  978.       else
  979. !     clear_snapshot(curtab, SNAP_HELP_IDX);
  980.   
  981.   #ifdef FEAT_AUTOCMD
  982.       if (win == curwin)
  983. ***************
  984. *** 2229,2235 ****
  985.       /* After closing the help window, try restoring the window layout from
  986.        * before it was opened. */
  987.       if (help_window)
  988. !     restore_snapshot(close_curwin);
  989.   
  990.   #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
  991.       /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
  992. --- 2273,2279 ----
  993.       /* After closing the help window, try restoring the window layout from
  994.        * before it was opened. */
  995.       if (help_window)
  996. !     restore_snapshot(SNAP_HELP_IDX, close_curwin);
  997.   
  998.   #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
  999.       /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
  1000. ***************
  1001. *** 2344,2349 ****
  1002. --- 2388,2401 ----
  1003.   
  1004.       while (firstwin != NULL)
  1005.       (void)win_free_mem(firstwin, &dummy, NULL);
  1006. + # ifdef FEAT_AUTOCMD
  1007. +     if (aucmd_win != NULL)
  1008. +     {
  1009. +     (void)win_free_mem(aucmd_win, &dummy, NULL);
  1010. +     aucmd_win = NULL;
  1011. +     }
  1012. + # endif
  1013.   }
  1014.   #endif
  1015.   
  1016. ***************
  1017. *** 2351,2357 ****
  1018.    * Remove a window and its frame from the tree of frames.
  1019.    * Returns a pointer to the window that got the freed up space.
  1020.    */
  1021. !     static win_T *
  1022.   winframe_remove(win, dirp, tp)
  1023.       win_T    *win;
  1024.       int        *dirp UNUSED;    /* set to 'v' or 'h' for direction if 'ea' */
  1025. --- 2403,2409 ----
  1026.    * Remove a window and its frame from the tree of frames.
  1027.    * Returns a pointer to the window that got the freed up space.
  1028.    */
  1029. !     win_T *
  1030.   winframe_remove(win, dirp, tp)
  1031.       win_T    *win;
  1032.       int        *dirp UNUSED;    /* set to 'v' or 'h' for direction if 'ea' */
  1033. ***************
  1034. *** 3090,3096 ****
  1035.       win_T    *nextwp;
  1036.       int        r;
  1037.   
  1038. !     if (lastwin == firstwin)
  1039.       {
  1040.       if (message
  1041.   #ifdef FEAT_AUTOCMD
  1042. --- 3142,3148 ----
  1043.       win_T    *nextwp;
  1044.       int        r;
  1045.   
  1046. !     if (one_window())
  1047.       {
  1048.       if (message
  1049.   #ifdef FEAT_AUTOCMD
  1050. ***************
  1051. *** 3194,3202 ****
  1052. --- 3246,3275 ----
  1053.       first_tabpage->tp_topframe = topframe;
  1054.       curtab = first_tabpage;
  1055.   #endif
  1056.       return OK;
  1057.   }
  1058.   
  1059. + #if defined(FEAT_AUTOCMD) || defined(PROTO)
  1060. + /*
  1061. +  * Init "aucmd_win".  This can only be done after the first
  1062. +  * window is fully initialized, thus it can't be in win_alloc_first().
  1063. +  */
  1064. +     void
  1065. + win_alloc_aucmd_win()
  1066. + {
  1067. +     aucmd_win = win_alloc(NULL, TRUE);
  1068. +     if (aucmd_win != NULL)
  1069. +     {
  1070. +     win_init_some(aucmd_win, curwin);
  1071. + # ifdef FEAT_SCROLLBIND
  1072. +     aucmd_win->w_p_scb = FALSE;
  1073. + # endif
  1074. +     new_frame(aucmd_win);
  1075. +     }
  1076. + }
  1077. + #endif
  1078.   /*
  1079.    * Allocate the first window or the first window in a new tab page.
  1080.    * When "oldwin" is NULL create an empty buffer for it.
  1081. ***************
  1082. *** 3208,3214 ****
  1083.   win_alloc_firstwin(oldwin)
  1084.       win_T    *oldwin;
  1085.   {
  1086. !     curwin = win_alloc(NULL);
  1087.       if (oldwin == NULL)
  1088.       {
  1089.       /* Very first window, need to create an empty buffer for it and
  1090. --- 3281,3287 ----
  1091.   win_alloc_firstwin(oldwin)
  1092.       win_T    *oldwin;
  1093.   {
  1094. !     curwin = win_alloc(NULL, FALSE);
  1095.       if (oldwin == NULL)
  1096.       {
  1097.       /* Very first window, need to create an empty buffer for it and
  1098. ***************
  1099. *** 3236,3256 ****
  1100.       }
  1101.   #endif
  1102.   
  1103. !     topframe = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
  1104. !     if (topframe == NULL)
  1105.       return FAIL;
  1106. !     topframe->fr_layout = FR_LEAF;
  1107.   #ifdef FEAT_VERTSPLIT
  1108.       topframe->fr_width = Columns;
  1109.   #endif
  1110.       topframe->fr_height = Rows - p_ch;
  1111.       topframe->fr_win = curwin;
  1112. -     curwin->w_frame = topframe;
  1113.   
  1114.       return OK;
  1115.   }
  1116.   
  1117.   /*
  1118.    * Initialize the window and frame size to the maximum.
  1119.    */
  1120.       void
  1121. --- 3309,3344 ----
  1122.       }
  1123.   #endif
  1124.   
  1125. !     new_frame(curwin);
  1126. !     if (curwin->w_frame == NULL)
  1127.       return FAIL;
  1128. !     topframe = curwin->w_frame;
  1129.   #ifdef FEAT_VERTSPLIT
  1130.       topframe->fr_width = Columns;
  1131.   #endif
  1132.       topframe->fr_height = Rows - p_ch;
  1133.       topframe->fr_win = curwin;
  1134.   
  1135.       return OK;
  1136.   }
  1137.   
  1138.   /*
  1139. +  * Create a frame for window "wp".
  1140. +  */
  1141. +     static void
  1142. + new_frame(win_T *wp)
  1143. + {
  1144. +     frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
  1145. +     wp->w_frame = frp;
  1146. +     if (frp != NULL)
  1147. +     {
  1148. +     frp->fr_layout = FR_LEAF;
  1149. +     frp->fr_win = wp;
  1150. +     }
  1151. + }
  1152. + /*
  1153.    * Initialize the window and frame size to the maximum.
  1154.    */
  1155.       void
  1156. ***************
  1157. *** 3300,3309 ****
  1158.   free_tabpage(tp)
  1159.       tabpage_T    *tp;
  1160.   {
  1161.   # ifdef FEAT_DIFF
  1162.       diff_clear(tp);
  1163.   # endif
  1164. !     clear_snapshot(tp);
  1165.   #ifdef FEAT_EVAL
  1166.       vars_clear(&tp->tp_vars.dv_hashtab);    /* free all t: variables */
  1167.   #endif
  1168. --- 3388,3400 ----
  1169.   free_tabpage(tp)
  1170.       tabpage_T    *tp;
  1171.   {
  1172. +     int idx;
  1173.   # ifdef FEAT_DIFF
  1174.       diff_clear(tp);
  1175.   # endif
  1176. !     for (idx = 0; idx < SNAP_COUNT; ++idx)
  1177. !     clear_snapshot(tp, idx);
  1178.   #ifdef FEAT_EVAL
  1179.       vars_clear(&tp->tp_vars.dv_hashtab);    /* free all t: variables */
  1180.   #endif
  1181. ***************
  1182. *** 3370,3381 ****
  1183.   #if defined(FEAT_GUI)
  1184.       /* When 'guioptions' includes 'L' or 'R' may have to remove or add
  1185.        * scrollbars.  Have to update them anyway. */
  1186. !     if (gui.in_use && starting == 0)
  1187. !     {
  1188. !         gui_init_which_components(NULL);
  1189. !         gui_update_scrollbars(TRUE);
  1190. !     }
  1191. !     need_mouse_correct = TRUE;
  1192.   #endif
  1193.   
  1194.       redraw_all_later(CLEAR);
  1195. --- 3461,3467 ----
  1196.   #if defined(FEAT_GUI)
  1197.       /* When 'guioptions' includes 'L' or 'R' may have to remove or add
  1198.        * scrollbars.  Have to update them anyway. */
  1199. !     gui_may_update_scrollbars();
  1200.   #endif
  1201.   
  1202.       redraw_all_later(CLEAR);
  1203. ***************
  1204. *** 3593,3604 ****
  1205.   #if defined(FEAT_GUI)
  1206.       /* When 'guioptions' includes 'L' or 'R' may have to remove or add
  1207.        * scrollbars.  Have to update them anyway. */
  1208. !     if (gui.in_use && starting == 0)
  1209. !     {
  1210. !     gui_init_which_components(NULL);
  1211. !     gui_update_scrollbars(TRUE);
  1212. !     }
  1213. !     need_mouse_correct = TRUE;
  1214.   #endif
  1215.   
  1216.       redraw_all_later(CLEAR);
  1217. --- 3679,3685 ----
  1218.   #if defined(FEAT_GUI)
  1219.       /* When 'guioptions' includes 'L' or 'R' may have to remove or add
  1220.        * scrollbars.  Have to update them anyway. */
  1221. !     gui_may_update_scrollbars();
  1222.   #endif
  1223.   
  1224.       redraw_all_later(CLEAR);
  1225. ***************
  1226. *** 4150,4160 ****
  1227.   #endif
  1228.   
  1229.   /*
  1230. !  * allocate a window structure and link it in the window list
  1231.    */
  1232.       static win_T *
  1233. ! win_alloc(after)
  1234.       win_T    *after UNUSED;
  1235.   {
  1236.       win_T    *newwin;
  1237.   
  1238. --- 4231,4243 ----
  1239.   #endif
  1240.   
  1241.   /*
  1242. !  * Allocate a window structure and link it in the window list when "hidden" is
  1243. !  * FALSE.
  1244.    */
  1245.       static win_T *
  1246. ! win_alloc(after, hidden)
  1247.       win_T    *after UNUSED;
  1248. +     int        hidden UNUSED;
  1249.   {
  1250.       win_T    *newwin;
  1251.   
  1252. ***************
  1253. *** 4180,4186 ****
  1254.        * link the window in the window list
  1255.        */
  1256.   #ifdef FEAT_WINDOWS
  1257. !     win_append(after, newwin);
  1258.   #endif
  1259.   #ifdef FEAT_VERTSPLIT
  1260.       newwin->w_wincol = 0;
  1261. --- 4263,4270 ----
  1262.        * link the window in the window list
  1263.        */
  1264.   #ifdef FEAT_WINDOWS
  1265. !     if (!hidden)
  1266. !         win_append(after, newwin);
  1267.   #endif
  1268.   #ifdef FEAT_VERTSPLIT
  1269.       newwin->w_wincol = 0;
  1270. ***************
  1271. *** 4314,4320 ****
  1272.   /*
  1273.    * Append window "wp" in the window list after window "after".
  1274.    */
  1275. !     static void
  1276.   win_append(after, wp)
  1277.       win_T    *after, *wp;
  1278.   {
  1279. --- 4398,4404 ----
  1280.   /*
  1281.    * Append window "wp" in the window list after window "after".
  1282.    */
  1283. !     void
  1284.   win_append(after, wp)
  1285.       win_T    *after, *wp;
  1286.   {
  1287. ***************
  1288. *** 4340,4346 ****
  1289.   /*
  1290.    * Remove a window from the window list.
  1291.    */
  1292. !     static void
  1293.   win_remove(wp, tp)
  1294.       win_T    *wp;
  1295.       tabpage_T    *tp;        /* tab page "win" is in, NULL for current */
  1296. --- 4424,4430 ----
  1297.   /*
  1298.    * Remove a window from the window list.
  1299.    */
  1300. !     void
  1301.   win_remove(wp, tp)
  1302.       win_T    *wp;
  1303.       tabpage_T    *tp;        /* tab page "win" is in, NULL for current */
  1304. ***************
  1305. *** 6040,6045 ****
  1306. --- 6124,6130 ----
  1307.   /*
  1308.    * Return TRUE if there is only one window (in the current tab page), not
  1309.    * counting a help or preview window, unless it is the current window.
  1310. +  * Does not count "aucmd_win".
  1311.    */
  1312.       int
  1313.   only_one_window()
  1314. ***************
  1315. *** 6053,6063 ****
  1316.       return FALSE;
  1317.   
  1318.       for (wp = firstwin; wp != NULL; wp = wp->w_next)
  1319. !     if (!((wp->w_buffer->b_help && !curbuf->b_help)
  1320.   # ifdef FEAT_QUICKFIX
  1321.               || wp->w_p_pvw
  1322.   # endif
  1323.            ) || wp == curwin)
  1324.           ++count;
  1325.       return (count <= 1);
  1326.   #else
  1327. --- 6138,6152 ----
  1328.       return FALSE;
  1329.   
  1330.       for (wp = firstwin; wp != NULL; wp = wp->w_next)
  1331. !     if ((!((wp->w_buffer->b_help && !curbuf->b_help)
  1332.   # ifdef FEAT_QUICKFIX
  1333.               || wp->w_p_pvw
  1334.   # endif
  1335.            ) || wp == curwin)
  1336. + # ifdef FEAT_AUTOCMD
  1337. +         && wp != aucmd_win
  1338. + # endif
  1339. +        )
  1340.           ++count;
  1341.       return (count <= 1);
  1342.   #else
  1343. ***************
  1344. *** 6112,6122 ****
  1345.   /*
  1346.    * Create a snapshot of the current frame sizes.
  1347.    */
  1348. !     static void
  1349. ! make_snapshot()
  1350.   {
  1351. !     clear_snapshot(curtab);
  1352. !     make_snapshot_rec(topframe, &curtab->tp_snapshot);
  1353.   }
  1354.   
  1355.       static void
  1356. --- 6201,6212 ----
  1357.   /*
  1358.    * Create a snapshot of the current frame sizes.
  1359.    */
  1360. !     void
  1361. ! make_snapshot(idx)
  1362. !     int idx;
  1363.   {
  1364. !     clear_snapshot(curtab, idx);
  1365. !     make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]);
  1366.   }
  1367.   
  1368.       static void
  1369. ***************
  1370. *** 6144,6154 ****
  1371.    * Remove any existing snapshot.
  1372.    */
  1373.       static void
  1374. ! clear_snapshot(tp)
  1375.       tabpage_T    *tp;
  1376.   {
  1377. !     clear_snapshot_rec(tp->tp_snapshot);
  1378. !     tp->tp_snapshot = NULL;
  1379.   }
  1380.   
  1381.       static void
  1382. --- 6234,6245 ----
  1383.    * Remove any existing snapshot.
  1384.    */
  1385.       static void
  1386. ! clear_snapshot(tp, idx)
  1387.       tabpage_T    *tp;
  1388. +     int        idx;
  1389.   {
  1390. !     clear_snapshot_rec(tp->tp_snapshot[idx]);
  1391. !     tp->tp_snapshot[idx] = NULL;
  1392.   }
  1393.   
  1394.       static void
  1395. ***************
  1396. *** 6168,6193 ****
  1397.    * This is only done if the screen size didn't change and the window layout is
  1398.    * still the same.
  1399.    */
  1400. !     static void
  1401. ! restore_snapshot(close_curwin)
  1402.       int        close_curwin;        /* closing current window */
  1403.   {
  1404.       win_T    *wp;
  1405.   
  1406. !     if (curtab->tp_snapshot != NULL
  1407.   # ifdef FEAT_VERTSPLIT
  1408. !         && curtab->tp_snapshot->fr_width == topframe->fr_width
  1409.   # endif
  1410. !         && curtab->tp_snapshot->fr_height == topframe->fr_height
  1411. !         && check_snapshot_rec(curtab->tp_snapshot, topframe) == OK)
  1412.       {
  1413. !     wp = restore_snapshot_rec(curtab->tp_snapshot, topframe);
  1414.       win_comp_pos();
  1415.       if (wp != NULL && close_curwin)
  1416.           win_goto(wp);
  1417.       redraw_all_later(CLEAR);
  1418.       }
  1419. !     clear_snapshot(curtab);
  1420.   }
  1421.   
  1422.   /*
  1423. --- 6259,6285 ----
  1424.    * This is only done if the screen size didn't change and the window layout is
  1425.    * still the same.
  1426.    */
  1427. !     void
  1428. ! restore_snapshot(idx, close_curwin)
  1429. !     int        idx;
  1430.       int        close_curwin;        /* closing current window */
  1431.   {
  1432.       win_T    *wp;
  1433.   
  1434. !     if (curtab->tp_snapshot[idx] != NULL
  1435.   # ifdef FEAT_VERTSPLIT
  1436. !         && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width
  1437.   # endif
  1438. !         && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height
  1439. !         && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK)
  1440.       {
  1441. !     wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe);
  1442.       win_comp_pos();
  1443.       if (wp != NULL && close_curwin)
  1444.           win_goto(wp);
  1445.       redraw_all_later(CLEAR);
  1446.       }
  1447. !     clear_snapshot(curtab, idx);
  1448.   }
  1449.   
  1450.   /*
  1451. *** ../vim-7.2.202/src/version.c    2009-06-16 15:35:46.000000000 +0200
  1452. --- src/version.c    2009-06-16 15:37:16.000000000 +0200
  1453. ***************
  1454. *** 678,679 ****
  1455. --- 678,681 ----
  1456.   {   /* Add new patch number below this line */
  1457. + /**/
  1458. +     203,
  1459.   /**/
  1460.  
  1461. -- 
  1462. How To Keep A Healthy Level Of Insanity:
  1463. 15. Five days in advance, tell your friends you can't attend their
  1464.     party because you're not in the mood.
  1465.  
  1466.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  1467. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  1468. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  1469.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  1470.