To: vim-dev@vim.org Subject: Patch 6.1.364 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.364 Problem: That the FileChangedShell autocommand event never nests makes it difficult to reload a file in a normal way. Solution: Allow nesting for the FileChangedShell event but do not allow triggering itself again. Also avoid autocommands for the cmdline window in rare cases. Files: src/ex_getln.c, src/fileio.c, src/window.c *** ../vim61.363/src/ex_getln.c Mon Feb 24 11:29:15 2003 --- src/ex_getln.c Sat Feb 22 12:36:16 2003 *************** *** 4397,4403 **** # ifdef FEAT_AUTOCMD /* Don't execute autocommands while creating the window. */ ! ++autocmd_busy; # endif /* Create a window for the command-line buffer. */ if (win_split((int)p_cwh, WSP_BOT) == FAIL) --- 4397,4403 ---- # ifdef FEAT_AUTOCMD /* Don't execute autocommands while creating the window. */ ! ++autocmd_block; # endif /* Create a window for the command-line buffer. */ if (win_split((int)p_cwh, WSP_BOT) == FAIL) *************** *** 4421,4427 **** # ifdef FEAT_AUTOCMD /* Do execute autocommands for setting the filetype (load syntax). */ ! --autocmd_busy; # endif histtype = hist_char2type(ccline.cmdfirstc); --- 4421,4427 ---- # ifdef FEAT_AUTOCMD /* Do execute autocommands for setting the filetype (load syntax). */ ! --autocmd_block; # endif histtype = hist_char2type(ccline.cmdfirstc); *************** *** 4542,4548 **** # ifdef FEAT_AUTOCMD /* Don't execute autocommands while deleting the window. */ ! ++autocmd_busy; # endif wp = curwin; bp = curbuf; --- 4542,4548 ---- # ifdef FEAT_AUTOCMD /* Don't execute autocommands while deleting the window. */ ! ++autocmd_block; # endif wp = curwin; bp = curbuf; *************** *** 4554,4560 **** win_size_restore(&winsizes); # ifdef FEAT_AUTOCMD ! --autocmd_busy; # endif } --- 4554,4560 ---- win_size_restore(&winsizes); # ifdef FEAT_AUTOCMD ! --autocmd_block; # endif } *** ../vim61.363/src/fileio.c Mon Feb 24 11:29:15 2003 --- src/fileio.c Sat Feb 22 12:41:02 2003 *************** *** 6785,6791 **** } ac->next = NULL; *prev_ac = ac; ! ac->nested = (event == EVENT_FILECHANGEDSHELL ? FALSE : nested); } } --- 6794,6800 ---- } ac->next = NULL; *prev_ac = ac; ! ac->nested = nested; } } *************** *** 7084,7089 **** --- 7093,7099 ---- void *save_funccalp; char_u *save_cmdarg; #endif + static int filechangeshell_busy = FALSE; /* * Quickly return if there are no autocommands for this event or *************** *** 7100,7105 **** --- 7110,7121 ---- return retval; /* + * FileChangedShell never nests, because it can create an endless loop. + */ + if (filechangeshell_busy && event == EVENT_FILECHANGEDSHELL) + return retval; + + /* * Ignore events in 'eventignore'. */ if (event_ignored(event)) *************** *** 7255,7260 **** --- 7271,7277 ---- * Note that we are applying autocmds. Some commands need to know. */ autocmd_busy = TRUE; + filechangeshell_busy = (event == EVENT_FILECHANGEDSHELL); ++nesting; /* Remember that FileType was triggered. Used for did_filetype(). */ *************** *** 7300,7305 **** --- 7317,7323 ---- --RedrawingDisabled; autocmd_busy = save_autocmd_busy; + filechangeshell_busy = FALSE; autocmd_nested = save_autocmd_nested; vim_free(sourcing_name); sourcing_name = save_sourcing_name; *** ../vim61.363/src/window.c Sun Feb 16 20:29:05 2003 --- src/window.c Sat Feb 22 12:41:30 2003 *************** *** 1170,1176 **** * Don't execute autocommands while creating the windows. Must do that * when putting the buffers in the windows. */ ! ++autocmd_busy; #endif /* todo is number of windows left to create */ --- 1170,1176 ---- * Don't execute autocommands while creating the windows. Must do that * when putting the buffers in the windows. */ ! ++autocmd_block; #endif /* todo is number of windows left to create */ *************** *** 1192,1198 **** } #ifdef FEAT_AUTOCMD ! --autocmd_busy; #endif /* return actual number of windows */ --- 1192,1198 ---- } #ifdef FEAT_AUTOCMD ! --autocmd_block; #endif /* return actual number of windows */ *** ../vim61.363/src/version.c Wed Feb 26 21:05:18 2003 --- src/version.c Wed Feb 26 21:07:15 2003 *************** *** 608,609 **** --- 612,615 ---- { /* Add new patch number below this line */ + /**/ + 364, /**/ -- BEDEVERE: Oooooh! LAUNCELOT: No "Aaaaarrrrrrggghhh ... " at the back of the throat. BEDEVERE: No! "Oooooh!" in surprise and alarm! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///