diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-03-04 18:08:14 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-03-04 18:08:14 +0100 |
commit | f2bd8ef2b4507d02c6043affff8f7e85e3414d5f (patch) | |
tree | f14cb8e7ff09975920f3a813d7de4851a2972661 /src | |
parent | 3f54fd319f6641b4bed478bcc90cdb39ede68e31 (diff) | |
download | vim-git-f2bd8ef2b4507d02c6043affff8f7e85e3414d5f.tar.gz |
patch 8.0.1564: too many #ifdefsv8.0.1564
Problem: Too many #ifdefs.
Solution: Graduate the +autocmd feature. Takes away 450 #ifdefs and
increases code size of tiny Vim by only 40 Kbyte.
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 224 | ||||
-rw-r--r-- | src/diff.c | 10 | ||||
-rw-r--r-- | src/edit.c | 91 | ||||
-rw-r--r-- | src/eval.c | 8 | ||||
-rw-r--r-- | src/evalfunc.c | 6 | ||||
-rw-r--r-- | src/ex_cmds.c | 134 | ||||
-rw-r--r-- | src/ex_cmds2.c | 52 | ||||
-rw-r--r-- | src/ex_docmd.c | 110 | ||||
-rw-r--r-- | src/ex_getln.c | 51 | ||||
-rw-r--r-- | src/feature.h | 9 | ||||
-rw-r--r-- | src/fileio.c | 143 | ||||
-rw-r--r-- | src/getchar.c | 6 | ||||
-rw-r--r-- | src/globals.h | 16 | ||||
-rw-r--r-- | src/gui.c | 35 | ||||
-rw-r--r-- | src/gui_mac.c | 2 | ||||
-rw-r--r-- | src/if_cscope.c | 8 | ||||
-rw-r--r-- | src/if_xcmdsrv.c | 2 | ||||
-rw-r--r-- | src/main.c | 69 | ||||
-rw-r--r-- | src/mbyte.c | 19 | ||||
-rw-r--r-- | src/memline.c | 6 | ||||
-rw-r--r-- | src/menu.c | 2 | ||||
-rw-r--r-- | src/misc1.c | 6 | ||||
-rw-r--r-- | src/misc2.c | 6 | ||||
-rw-r--r-- | src/move.c | 2 | ||||
-rw-r--r-- | src/netbeans.c | 6 | ||||
-rw-r--r-- | src/normal.c | 32 | ||||
-rw-r--r-- | src/ops.c | 8 | ||||
-rw-r--r-- | src/option.c | 81 | ||||
-rw-r--r-- | src/option.h | 4 | ||||
-rw-r--r-- | src/os_amiga.c | 2 | ||||
-rw-r--r-- | src/os_mswin.c | 2 | ||||
-rw-r--r-- | src/os_unix.c | 5 | ||||
-rw-r--r-- | src/os_win32.c | 2 | ||||
-rw-r--r-- | src/quickfix.c | 77 | ||||
-rw-r--r-- | src/screen.c | 8 | ||||
-rw-r--r-- | src/search.c | 16 | ||||
-rw-r--r-- | src/spell.c | 12 | ||||
-rw-r--r-- | src/structs.h | 28 | ||||
-rw-r--r-- | src/syntax.c | 8 | ||||
-rw-r--r-- | src/tag.c | 10 | ||||
-rw-r--r-- | src/term.c | 8 | ||||
-rw-r--r-- | src/terminal.c | 16 | ||||
-rw-r--r-- | src/ui.c | 4 | ||||
-rw-r--r-- | src/undo.c | 8 | ||||
-rw-r--r-- | src/userfunc.c | 2 | ||||
-rw-r--r-- | src/version.c | 6 | ||||
-rw-r--r-- | src/vim.h | 14 | ||||
-rw-r--r-- | src/window.c | 107 |
48 files changed, 326 insertions, 1157 deletions
diff --git a/src/buffer.c b/src/buffer.c index a3a7e00c4..328557741 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -63,9 +63,7 @@ static void insert_sign(buf_T *buf, signlist_T *prev, signlist_T *next, int id, static char *msg_loclist = N_("[Location List]"); static char *msg_qflist = N_("[Quickfix List]"); #endif -#ifdef FEAT_AUTOCMD static char *e_auabort = N_("E855: Autocommands caused command to abort"); -#endif /* Number of times free_buffer() was called. */ static int buf_free_count = 0; @@ -116,17 +114,15 @@ read_buffer( else if (retval == OK) unchanged(curbuf, FALSE); -#ifdef FEAT_AUTOCMD if (retval == OK) { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, - curbuf, &retval); -# else + curbuf, &retval); +#else apply_autocmds(EVENT_STDINREADPOST, NULL, NULL, FALSE, curbuf); -# endif - } #endif + } } return retval; } @@ -143,9 +139,7 @@ open_buffer( int flags) /* extra flags for readfile() */ { int retval = OK; -#ifdef FEAT_AUTOCMD bufref_T old_curbuf; -#endif #ifdef FEAT_SYN_HL long old_tw = curbuf->b_p_tw; #endif @@ -188,12 +182,10 @@ open_buffer( return FAIL; } -#ifdef FEAT_AUTOCMD /* The autocommands in readfile() may change the buffer, but only AFTER * reading the file. */ set_bufref(&old_curbuf, curbuf); modified_was_set = FALSE; -#endif /* mark cursor position as being invalid */ curwin->w_valid = 0; @@ -289,11 +281,9 @@ open_buffer( * the changed flag. Unless in readonly mode: "ls | gview -". * When interrupted and 'cpoptions' contains 'i' set changed flag. */ if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL) -#ifdef FEAT_AUTOCMD || modified_was_set /* ":set modified" used in autocmd */ -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL) -# endif #endif ) changed(); @@ -315,25 +305,22 @@ open_buffer( foldUpdateAll(curwin); #endif -#ifdef FEAT_AUTOCMD /* need to set w_topline, unless some autocommand already did that. */ if (!(curwin->w_valid & VALID_TOPLINE)) { curwin->w_topline = 1; -# ifdef FEAT_DIFF +#ifdef FEAT_DIFF curwin->w_topfill = 0; -# endif +#endif } -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf, &retval); -# else +#else apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); -# endif #endif if (retval == OK) { -#ifdef FEAT_AUTOCMD /* * The autocommands may have changed the current buffer. Apply the * modelines to the correct buffer, if it still exists and is loaded. @@ -344,22 +331,19 @@ open_buffer( /* Go to the buffer that was opened. */ aucmd_prepbuf(&aco, old_curbuf.br_buf); -#endif do_modelines(0); curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED); -#ifdef FEAT_AUTOCMD -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf, - &retval); -# else + &retval); +#else apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf); -# endif +#endif /* restore curwin/curbuf and a few other things */ aucmd_restbuf(&aco); } -#endif } return retval; @@ -454,14 +438,12 @@ close_buffer( int action, int abort_if_last UNUSED) { -#ifdef FEAT_AUTOCMD int is_curbuf; int nwindows; bufref_T bufref; int is_curwin = (curwin != NULL && curwin->w_buffer == buf); win_T *the_curwin = curwin; tabpage_T *the_curtab = curtab; -#endif int unload_buf = (action != 0); int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE); int wipe_buf = (action == DOBUF_WIPE); @@ -510,7 +492,6 @@ close_buffer( } #endif -#ifdef FEAT_AUTOCMD /* Disallow deleting the buffer when it is locked (already being closed or * halfway a command that relies on it). Unloading is allowed. */ if (buf->b_locked > 0 && (del_buf || wipe_buf)) @@ -518,7 +499,6 @@ close_buffer( EMSG(_("E937: Attempt to delete a buffer that is in use")); return; } -#endif /* check no autocommands closed the window */ if (win != NULL && win_valid_any_tab(win)) @@ -534,7 +514,6 @@ close_buffer( win->w_cursor.col, TRUE); } -#ifdef FEAT_AUTOCMD set_bufref(&bufref, buf); /* When the buffer is no longer in a window, trigger BufWinLeave */ @@ -570,10 +549,10 @@ aucmd_abort: /* Autocommands made this the only window. */ goto aucmd_abort; } -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return; -# endif +#endif } /* If the buffer was in curwin and the window has changed, go back to that @@ -587,7 +566,6 @@ aucmd_abort: } nwindows = buf->b_nwindows; -#endif /* decrease the link count from windows (unless not in any window) */ if (buf->b_nwindows > 0) @@ -620,23 +598,20 @@ aucmd_abort: * Free all things allocated for this buffer. * Also calls the "BufDelete" autocommands when del_buf is TRUE. */ -#ifdef FEAT_AUTOCMD /* Remember if we are closing the current buffer. Restore the number of * windows, so that autocommands in buf_freeall() don't get confused. */ is_curbuf = (buf == curbuf); buf->b_nwindows = nwindows; -#endif buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0)); -#ifdef FEAT_AUTOCMD /* Autocommands may have deleted the buffer. */ if (!bufref_valid(&bufref)) return; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return; -# endif +#endif /* * It's possible that autocommands change curbuf to the one being deleted. @@ -655,7 +630,6 @@ aucmd_abort: * Decrement the count for the close we do here. */ if (buf->b_nwindows > 0) --buf->b_nwindows; -#endif /* * Remove the buffer from the list. @@ -732,7 +706,6 @@ buf_clear_file(buf_T *buf) void buf_freeall(buf_T *buf, int flags) { -#ifdef FEAT_AUTOCMD int is_curbuf = (buf == curbuf); bufref_T bufref; int is_curwin = (curwin != NULL && curwin->w_buffer == buf); @@ -778,10 +751,10 @@ buf_freeall(buf_T *buf, int flags) unblock_autocmds(); } -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return; -# endif +#endif /* * It's possible that autocommands change curbuf to the one being deleted. @@ -791,7 +764,6 @@ buf_freeall(buf_T *buf, int flags) */ if (buf == curbuf && !is_curbuf) return; -#endif #ifdef FEAT_DIFF diff_buf_delete(buf); /* Can't use 'diff' for unloaded buffer. */ #endif @@ -870,7 +842,6 @@ free_buffer(buf_T *buf) buf_hashtab_remove(buf); -#ifdef FEAT_AUTOCMD aubuflocal_remove(buf); if (autocmd_busy) @@ -881,7 +852,6 @@ free_buffer(buf_T *buf) au_pending_free_buf = buf; } else -#endif vim_free(buf); } @@ -994,7 +964,7 @@ goto_buffer( # if defined(HAS_SWAP_EXISTS_ACTION) if (swap_exists_action == SEA_QUIT && *eap->cmd == 's') { -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) cleanup_T cs; /* Reset the error/interrupt/exception state here so that @@ -1007,7 +977,7 @@ goto_buffer( swap_exists_action = SEA_NONE; swap_exists_did_quit = TRUE; -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) /* Restore the error/interrupt/exception state if not discarded by a * new aborting error, interrupt, or uncaught exception. */ leave_cleanup(&cs); @@ -1027,17 +997,17 @@ goto_buffer( void handle_swap_exists(bufref_T *old_curbuf) { -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) cleanup_T cs; # endif -#ifdef FEAT_SYN_HL +# ifdef FEAT_SYN_HL long old_tw = curbuf->b_p_tw; -#endif +# endif buf_T *buf; if (swap_exists_action == SEA_QUIT) { -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) /* Reset the error/interrupt/exception state here so that * aborting() returns FALSE when closing a buffer. */ enter_cleanup(&cs); @@ -1057,14 +1027,14 @@ handle_swap_exists(bufref_T *old_curbuf) if (buf != NULL) { enter_buffer(buf); -#ifdef FEAT_SYN_HL +# ifdef FEAT_SYN_HL if (old_tw != curbuf->b_p_tw) check_colorcolumn(curwin); -#endif +# endif } /* If "old_curbuf" is NULL we are in big trouble here... */ -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) /* Restore the error/interrupt/exception state if not discarded by a * new aborting error, interrupt, or uncaught exception. */ leave_cleanup(&cs); @@ -1072,7 +1042,7 @@ handle_swap_exists(bufref_T *old_curbuf) } else if (swap_exists_action == SEA_RECOVER) { -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) /* Reset the error/interrupt/exception state here so that * aborting() returns FALSE when closing a buffer. */ enter_cleanup(&cs); @@ -1085,7 +1055,7 @@ handle_swap_exists(bufref_T *old_curbuf) cmdline_row = msg_row; do_modelines(0); -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) /* Restore the error/interrupt/exception state if not discarded by a * new aborting error, interrupt, or uncaught exception. */ leave_cleanup(&cs); @@ -1400,23 +1370,21 @@ do_buffer( if (!forceit && bufIsChanged(buf)) { -#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) +# if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if ((p_confirm || cmdmod.confirm) && p_write) { dialog_changed(buf, FALSE); -# ifdef FEAT_AUTOCMD if (!bufref_valid(&bufref)) /* Autocommand deleted buffer, oops! It's not changed * now. */ return FAIL; -# endif /* If it's still changed fail silently, the dialog already * mentioned why it fails. */ if (bufIsChanged(buf)) return FAIL; } else -#endif +# endif { EMSGN(_("E89: No write since last change for buffer %ld (add ! to override)"), buf->b_fnum); @@ -1444,9 +1412,7 @@ do_buffer( * a window with this buffer. */ while (buf == curbuf -#ifdef FEAT_AUTOCMD && !(curwin->w_closing || curwin->w_buffer->b_locked > 0) -#endif && (!ONE_WINDOW || first_tabpage->tp_next != NULL)) { if (win_close(curwin, FALSE) == FAIL) @@ -1476,15 +1442,10 @@ do_buffer( */ buf = NULL; /* selected buffer */ bp = NULL; /* used when no loaded buffer found */ -#ifdef FEAT_AUTOCMD if (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf)) buf = au_new_curbuf.br_buf; -# ifdef FEAT_JUMPLIST - else -# endif -#endif #ifdef FEAT_JUMPLIST - if (curwin->w_jumplistlen > 0) + else if (curwin->w_jumplistlen > 0) { int jumpidx; @@ -1603,17 +1564,13 @@ do_buffer( #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if ((p_confirm || cmdmod.confirm) && p_write) { -# ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf); -# endif dialog_changed(curbuf, FALSE); -# ifdef FEAT_AUTOCMD if (!bufref_valid(&bufref)) /* Autocommand deleted buffer, oops! */ return FAIL; -# endif } if (bufIsChanged(curbuf)) #endif @@ -1634,7 +1591,7 @@ do_buffer( } #endif -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (aborting()) /* autocmds may abort script processing */ return FAIL; #endif @@ -1678,17 +1635,15 @@ set_curbuf(buf_T *buf, int action) set_bufref(&prevbufref, prevbuf); set_bufref(&newbufref, buf); -#ifdef FEAT_AUTOCMD /* Autocommands may delete the curren buffer and/or the buffer we wan to go * to. In those cases don't close the buffer. */ if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf) || (bufref_valid(&prevbufref) && bufref_valid(&newbufref) -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL && !aborting() -# endif - )) #endif + )) { #ifdef FEAT_SYN_HL if (prevbuf == curwin->w_buffer) @@ -1696,7 +1651,7 @@ set_curbuf(buf_T *buf, int action) #endif if (unload) close_windows(prevbuf, FALSE); -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (bufref_valid(&prevbufref) && !aborting()) #else if (bufref_valid(&prevbufref)) @@ -1714,16 +1669,14 @@ set_curbuf(buf_T *buf, int action) curwin = previouswin; } } -#ifdef FEAT_AUTOCMD /* An autocommand may have deleted "buf", already entered it (e.g., when * it did ":bunload") or aborted the script processing. * If curwin->w_buffer is null, enter_buffer() will make it valid again */ if ((buf_valid(buf) && buf != curbuf -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL && !aborting() -# endif - ) || curwin->w_buffer == NULL) #endif + ) || curwin->w_buffer == NULL) { enter_buffer(buf); #ifdef FEAT_SYN_HL @@ -1773,9 +1726,7 @@ enter_buffer(buf_T *buf) curwin->w_cursor.coladd = 0; #endif curwin->w_set_curswant = TRUE; -#ifdef FEAT_AUTOCMD curwin->w_topline_was_set = FALSE; -#endif /* mark cursor position as being invalid */ curwin->w_valid = 0; @@ -1783,13 +1734,11 @@ enter_buffer(buf_T *buf) /* Make sure the buffer is loaded. */ if (curbuf->b_ml.ml_mfp == NULL) /* need to load the file */ { -#ifdef FEAT_AUTOCMD /* If there is no filetype, allow for detecting one. Esp. useful for * ":ball" used in a autocommand. If there already is a filetype we * might prefer to keep it. */ if (*curbuf->b_p_ft == NUL) did_filetype = FALSE; -#endif open_buffer(FALSE, NULL, 0); } @@ -1798,14 +1747,12 @@ enter_buffer(buf_T *buf) if (!msg_silent) need_fileinfo = TRUE; /* display file info after redraw */ (void)buf_check_timestamp(curbuf, FALSE); /* check if file changed */ -#ifdef FEAT_AUTOCMD curwin->w_topline = 1; -# ifdef FEAT_DIFF +#ifdef FEAT_DIFF curwin->w_topfill = 0; -# endif +#endif apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf); -#endif } /* If autocommands did not change the cursor position, restore cursor lnum @@ -1817,10 +1764,8 @@ enter_buffer(buf_T *buf) #ifdef FEAT_TITLE maketitle(); #endif -#ifdef FEAT_AUTOCMD /* when autocmds didn't change it */ if (curwin->w_topline == 1 && !curwin->w_topline_was_set) -#endif scroll_cursor_halfway(FALSE); /* redisplay at correct position */ #ifdef FEAT_NETBEANS_INTG @@ -1948,11 +1893,9 @@ buflist_new( if ((flags & BLN_LISTED) && !buf->b_p_bl) { -#ifdef FEAT_AUTOCMD bufref_T bufref; -#endif + buf->b_p_bl = TRUE; -#ifdef FEAT_AUTOCMD set_bufref(&bufref, buf); if (!(flags & BLN_DUMMY)) { @@ -1960,7 +1903,6 @@ buflist_new( && !bufref_valid(&bufref)) return NULL; } -#endif } return buf; } @@ -1981,21 +1923,17 @@ buflist_new( && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY())) { buf = curbuf; -#ifdef FEAT_AUTOCMD /* It's like this buffer is deleted. Watch out for autocommands that * change curbuf! If that happens, allocate a new buffer anyway. */ if (curbuf->b_p_bl) apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf); if (buf == curbuf) apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf); -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return NULL; -# endif #endif -#ifdef FEAT_AUTOCMD if (buf == curbuf) -#endif { /* Make sure 'bufhidden' and 'buftype' are empty */ clear_string_option(&buf->b_p_bh); @@ -2049,7 +1987,7 @@ buflist_new( buf_freeall(buf, 0); if (buf != curbuf) /* autocommands deleted the buffer! */ return NULL; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (aborting()) /* autocmds may abort script processing */ return NULL; #endif @@ -2128,7 +2066,6 @@ buflist_new( clrallmarks(buf); /* clear marks */ fmarks_check_names(buf); /* check file marks for this file */ buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; /* init 'buflisted' */ -#ifdef FEAT_AUTOCMD if (!(flags & BLN_DUMMY)) { bufref_T bufref; @@ -2146,12 +2083,11 @@ buflist_new( && !bufref_valid(&bufref)) return NULL; } -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return NULL; -# endif - } #endif + } return buf; } @@ -2230,9 +2166,7 @@ free_buf_options( #ifdef FEAT_SEARCHPATH clear_string_option(&buf->b_p_sua); #endif -#ifdef FEAT_AUTOCMD clear_string_option(&buf->b_p_ft); -#endif #ifdef FEAT_CINDENT clear_string_option(&buf->b_p_cink); clear_string_option(&buf->b_p_cino); @@ -2315,10 +2249,8 @@ buflist_getfile( text_locked_msg(); return FAIL; } -#ifdef FEAT_AUTOCMD if (curbuf_locked()) return FAIL; -#endif /* altfpos may be changed by getfile(), get it now */ if (lnum == 0) @@ -4368,7 +4300,6 @@ build_stl_str_hl( : _("[Help]")); break; -#ifdef FEAT_AUTOCMD case STL_FILETYPE: if (*wp->w_buffer->b_p_ft != NUL && STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 3) @@ -4391,7 +4322,6 @@ build_stl_str_hl( str = tmp; } break; -#endif #if defined(FEAT_QUICKFIX) case STL_PREVIEWFLAG: @@ -5013,20 +4943,18 @@ do_arg_all( if (!buf_hide(buf) && buf->b_nwindows <= 1 && bufIsChanged(buf)) { -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf); -#endif + (void)autowrite(buf, FALSE); -#ifdef FEAT_AUTOCMD + /* check if autocommands removed the window */ if (!win_valid(wp) || !bufref_valid(&bufref)) { wpnext = firstwin; /* start all over... */ continue; } -#endif } /* don't close last window */ if (ONE_WINDOW @@ -5035,11 +4963,10 @@ do_arg_all( else { win_close(wp, !buf_hide(buf) && !bufIsChanged(buf)); -#ifdef FEAT_AUTOCMD + /* check if autocommands removed the next window */ if (!win_valid(wpnext)) wpnext = firstwin; /* start all over... */ -#endif } } } @@ -5049,11 +4976,10 @@ do_arg_all( if (had_tab == 0 || tpnext == NULL) break; -# ifdef FEAT_AUTOCMD /* check if autocommands removed the next tab page */ if (!valid_tabpage(tpnext)) tpnext = first_tabpage; /* start all over...*/ -# endif + goto_tabpage_tp(tpnext, TRUE, TRUE); } @@ -5064,11 +4990,9 @@ do_arg_all( if (count > opened_len || count <= 0) count = opened_len; -#ifdef FEAT_AUTOCMD /* Don't execute Win/Buf Enter/Leave autocommands here. */ ++autocmd_no_enter; ++autocmd_no_leave; -#endif last_curwin = curwin; last_curtab = curtab; win_enter(lastwin, FALSE); @@ -5114,10 +5038,8 @@ do_arg_all( if (split_ret == FAIL) continue; } -#ifdef FEAT_AUTOCMD else /* first window: do autocmd for leaving this buffer */ --autocmd_no_leave; -#endif /* * edit file "i" @@ -5133,10 +5055,8 @@ do_arg_all( ((buf_hide(curwin->w_buffer) || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF, curwin); -#ifdef FEAT_AUTOCMD if (use_firstwin) ++autocmd_no_leave; -#endif use_firstwin = FALSE; } ui_breakcheck(); @@ -5149,9 +5069,8 @@ do_arg_all( /* Remove the "lock" on the argument list. */ alist_unlink(alist); -#ifdef FEAT_AUTOCMD --autocmd_no_enter; -#endif + /* restore last referenced tabpage's curwin */ if (last_curtab != new_curtab) { @@ -5166,9 +5085,7 @@ do_arg_all( if (win_valid(new_curwin)) win_enter(new_curwin, FALSE); -#ifdef FEAT_AUTOCMD --autocmd_no_leave; -#endif vim_free(opened); } @@ -5223,18 +5140,13 @@ ex_buffer_all(exarg_T *eap) - tabline_height() : wp->w_width != Columns) || (had_tab > 0 && wp != firstwin)) && !ONE_WINDOW -#ifdef FEAT_AUTOCMD - && !(wp->w_closing || wp->w_buffer->b_locked > 0) -#endif - ) + && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { win_close(wp, FALSE); -#ifdef FEAT_AUTOCMD wpnext = firstwin; /* just in case an autocommand does something strange with windows */ tpnext = first_tabpage; /* start all over...*/ open_wins = 0; -#endif } else ++open_wins; @@ -5251,14 +5163,10 @@ ex_buffer_all(exarg_T *eap) * open one. Otherwise move the window to the right position. * Watch out for autocommands that delete buffers or windows! */ -#ifdef FEAT_AUTOCMD /* Don't execute Win/Buf Enter/Leave autocommands here. */ ++autocmd_no_enter; -#endif win_enter(lastwin, FALSE); -#ifdef FEAT_AUTOCMD ++autocmd_no_leave; -#endif for (buf = firstbuf; buf != NULL && open_wins < count; buf = buf->b_next) { /* Check if this buffer needs a window */ @@ -5286,11 +5194,10 @@ ex_buffer_all(exarg_T *eap) if (wp == NULL && split_ret == OK) { -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf); -#endif + /* Split the window and put the buffer in it */ p_ea_save = p_ea; p_ea = TRUE; /* use space from all windows */ @@ -5305,20 +5212,18 @@ ex_buffer_all(exarg_T *eap) swap_exists_action = SEA_DIALOG; #endif set_curbuf(buf, DOBUF_GOTO); -#ifdef FEAT_AUTOCMD if (!bufref_valid(&bufref)) { /* autocommands deleted the buffer!!! */ #if defined(HAS_SWAP_EXISTS_ACTION) swap_exists_action = SEA_NONE; -# endif +#endif break; } -#endif #if defined(HAS_SWAP_EXISTS_ACTION) if (swap_exists_action == SEA_QUIT) { -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) cleanup_T cs; /* Reset the error/interrupt/exception state here so that @@ -5332,7 +5237,7 @@ ex_buffer_all(exarg_T *eap) swap_exists_action = SEA_NONE; swap_exists_did_quit = TRUE; -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) /* Restore the error/interrupt/exception state if not * discarded by a new aborting error, interrupt, or uncaught * exception. */ @@ -5359,13 +5264,9 @@ ex_buffer_all(exarg_T *eap) if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) cmdmod.tab = 9999; } -#ifdef FEAT_AUTOCMD --autocmd_no_enter; -#endif win_enter(firstwin, FALSE); /* back to first window */ -#ifdef FEAT_AUTOCMD --autocmd_no_leave; -#endif /* * Close superfluous windows. @@ -5374,15 +5275,12 @@ ex_buffer_all(exarg_T *eap) { r = (buf_hide(wp->w_buffer) || !bufIsChanged(wp->w_buffer) || autowrite(wp->w_buffer, FALSE) == OK); -#ifdef FEAT_AUTOCMD if (!win_valid(wp)) { /* BufWrite Autocommands made the window invalid, start over */ wp = lastwin; } - else -#endif - if (r) + else if (r) { win_close(wp, !buf_hide(wp->w_buffer)); --open_wins; @@ -6233,12 +6131,10 @@ set_buflisted(int on) if (on != curbuf->b_p_bl) { curbuf->b_p_bl = on; -#ifdef FEAT_AUTOCMD if (on) apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf); else apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf); -#endif } } @@ -6311,13 +6207,11 @@ wipe_buffer( if (buf->b_fnum == top_file_num - 1) --top_file_num; -#ifdef FEAT_AUTOCMD if (!aucmd) /* Don't trigger BufDelete autocommands here. */ block_autocmds(); -#endif + close_buffer(NULL, buf, DOBUF_WIPE, FALSE); -#ifdef FEAT_AUTOCMD + if (!aucmd) unblock_autocmds(); -#endif } diff --git a/src/diff.c b/src/diff.c index 2f5b38c7b..6f3c99b9a 100644 --- a/src/diff.c +++ b/src/diff.c @@ -872,13 +872,9 @@ diff_file( (diff_flags & DIFF_ICASE) ? "-i " : "", tmp_orig, tmp_new); append_redir(cmd, (int)len, p_srr, tmp_diff); -#ifdef FEAT_AUTOCMD block_autocmds(); /* Avoid ShellCmdPost stuff */ -#endif (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT); -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif vim_free(cmd); } } @@ -984,13 +980,9 @@ ex_diffpatch(exarg_T *eap) * cooked mode to allow the user to respond to prompts. */ vim_snprintf((char *)buf, buflen, "patch -o %s %s < %s", tmp_new, tmp_orig, esc_name); -#ifdef FEAT_AUTOCMD block_autocmds(); /* Avoid ShellCmdPost stuff */ -#endif (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED); -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif } #ifdef UNIX @@ -1052,11 +1044,9 @@ ex_diffpatch(exarg_T *eap) eap->arg = newname; ex_file(eap); -#ifdef FEAT_AUTOCMD /* Do filetype detection with the new name. */ if (au_has_group((char_u *)"filetypedetect")) do_cmdline_cmd((char_u *)":doau filetypedetect BufRead"); -#endif } } } diff --git a/src/edit.c b/src/edit.c index f0e5c5185..e20857df6 100644 --- a/src/edit.c +++ b/src/edit.c @@ -273,7 +273,7 @@ static int ins_ctrl_ey(int tc); static void ins_try_si(int c); #endif static colnr_T get_nolist_virtcol(void); -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) static char_u *do_insert_char_pre(int c); #endif @@ -388,7 +388,6 @@ edit( ins_compl_clear(); /* clear stuff for CTRL-X mode */ #endif -#ifdef FEAT_AUTOCMD /* * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". */ @@ -396,7 +395,7 @@ edit( { pos_T save_cursor = curwin->w_cursor; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (cmdchar == 'R') ptr = (char_u *)"r"; else if (cmdchar == 'V') @@ -405,7 +404,7 @@ edit( ptr = (char_u *)"i"; set_vim_var_string(VV_INSERTMODE, ptr, 1); set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */ -# endif +#endif apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf); /* Make sure the cursor didn't move. Do call check_cursor_col() in @@ -415,9 +414,9 @@ edit( * line number is still valid (lines may have been deleted). * Do not restore if v:char was set to a non-empty string. */ if (!EQUAL_POS(curwin->w_cursor, save_cursor) -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL && *get_vim_var_str(VV_CHAR) == NUL -# endif +#endif && save_cursor.lnum <= curbuf->b_ml.ml_line_count) { int save_state = State; @@ -428,7 +427,6 @@ edit( State = save_state; } } -#endif #ifdef FEAT_CONCEAL /* Check if the cursor line needs redrawing before changing State. If @@ -521,7 +519,7 @@ edit( */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) State |= LANGMAP; -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); #endif @@ -805,10 +803,8 @@ edit( c = safe_vgetc(); } while (c == K_IGNORE || c == K_NOP); -#ifdef FEAT_AUTOCMD /* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */ did_cursorhold = TRUE; -#endif #ifdef FEAT_RIGHTLEFT if (p_hkmap && KeyTyped) @@ -856,7 +852,7 @@ edit( * completion: Add to "compl_leader". */ if (ins_compl_accept_char(c)) { -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) /* Trigger InsertCharPre. */ char_u *str = do_insert_char_pre(c); char_u *p; @@ -1030,12 +1026,10 @@ doESCkey: if (ins_esc(&count, cmdchar, nomove)) { -#ifdef FEAT_AUTOCMD if (cmdchar != 'r' && cmdchar != 'v') apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL, FALSE, curbuf); did_cursorhold = FALSE; -#endif return (c == Ctrl_O); } continue; @@ -1234,12 +1228,10 @@ doESCkey: case K_IGNORE: /* Something mapped to nothing */ break; -#ifdef FEAT_AUTOCMD case K_CURSORHOLD: /* Didn't type something for a while. */ apply_autocmds(EVENT_CURSORHOLDI, NULL, NULL, FALSE, curbuf); did_cursorhold = TRUE; break; -#endif #ifdef FEAT_GUI_W32 /* On Win32 ignore <M-F4>, we get it when closing the window was @@ -1488,7 +1480,7 @@ normalchar: /* * Insert a normal character. */ -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) if (!p_paste) { /* Trigger InsertCharPre. */ @@ -1565,16 +1557,14 @@ normalchar: break; } /* end of switch (c) */ -#ifdef FEAT_AUTOCMD /* If typed something may trigger CursorHoldI again. */ if (c != K_CURSORHOLD -# ifdef FEAT_COMPL_FUNC +#ifdef FEAT_COMPL_FUNC /* but not in CTRL-X mode, a script can't restore the state */ && ctrl_x_mode == CTRL_X_NORMAL -# endif +#endif ) did_cursorhold = FALSE; -#endif /* If the cursor was moved we didn't just insert a space */ if (arrow_used) @@ -1624,25 +1614,17 @@ ins_redraw( if (char_avail()) return; -#if defined(FEAT_AUTOCMD) || defined(FEAT_CONCEAL) +#if defined(FEAT_CONCEAL) /* Trigger CursorMoved if the cursor moved. Not when the popup menu is * visible, the command might delete it. */ - if (ready && ( -# ifdef FEAT_AUTOCMD - has_cursormovedI() -# endif -# if defined(FEAT_AUTOCMD) && defined(FEAT_CONCEAL) - || -# endif -# ifdef FEAT_CONCEAL - curwin->w_p_cole > 0 + if (ready && (has_cursormovedI() +# if defined(FEAT_CONCEAL) + || curwin->w_p_cole > 0 # endif ) -# ifdef FEAT_AUTOCMD - && !EQUAL_POS(last_cursormoved, curwin->w_cursor) -# endif + && !EQUAL_POS(last_cursormoved, curwin->w_cursor) # ifdef FEAT_INS_EXPAND - && !pum_visible() + && !pum_visible() # endif ) { @@ -1654,7 +1636,6 @@ ins_redraw( if (syntax_present(curwin) && must_redraw) update_screen(0); # endif -# ifdef FEAT_AUTOCMD if (has_cursormovedI()) { /* Make sure curswant is correct, an autocommand may call @@ -1662,37 +1643,31 @@ ins_redraw( update_curswant(); apply_autocmds(EVENT_CURSORMOVEDI, NULL, NULL, FALSE, curbuf); } -# endif # ifdef FEAT_CONCEAL if (curwin->w_p_cole > 0) { -# ifdef FEAT_AUTOCMD conceal_old_cursor_line = last_cursormoved.lnum; -# endif conceal_new_cursor_line = curwin->w_cursor.lnum; conceal_update_lines = TRUE; } # endif -# ifdef FEAT_AUTOCMD last_cursormoved = curwin->w_cursor; -# endif } #endif -#ifdef FEAT_AUTOCMD /* Trigger TextChangedI if b_changedtick differs. */ if (ready && has_textchangedI() && curbuf->b_last_changedtick != CHANGEDTICK(curbuf) -# ifdef FEAT_INS_EXPAND +#ifdef FEAT_INS_EXPAND && !pum_visible() -# endif +#endif ) { apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf); curbuf->b_last_changedtick = CHANGEDTICK(curbuf); } -# ifdef FEAT_INS_EXPAND +#ifdef FEAT_INS_EXPAND /* Trigger TextChangedP if b_changedtick differs. When the popupmenu closes * TextChangedI will need to trigger for backwards compatibility, thus use * different b_last_changedtick* variables. */ @@ -1703,7 +1678,6 @@ ins_redraw( apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, FALSE, curbuf); curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf); } -# endif #endif if (must_redraw) @@ -4001,19 +3975,15 @@ ins_compl_prep(int c) if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0))) do_c_expr_indent(); #endif -#ifdef FEAT_AUTOCMD /* Trigger the CompleteDone event to give scripts a chance to act * upon the completion. */ apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf); -#endif } } -#ifdef FEAT_AUTOCMD else if (ctrl_x_mode == CTRL_X_LOCAL_MSG) /* Trigger the CompleteDone event to give scripts a chance to act * upon the (possibly failed) completion. */ apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf); -#endif /* reset continue_* if we left expansion-mode, if we stay they'll be * (re)set properly in ins_complete() */ @@ -6224,10 +6194,7 @@ insertchar( #ifdef FEAT_RIGHTLEFT && !p_ri #endif -#ifdef FEAT_AUTOCMD - && !has_insertcharpre() -#endif - ) + && !has_insertcharpre()) { #define INPUT_BUFLEN 100 char_u buf[INPUT_BUFLEN + 1]; @@ -8404,7 +8371,7 @@ ins_reg(void) ++no_u_sync; if (regname == '=') { -# ifdef FEAT_MBYTE +# ifdef HAVE_INPUT_METHOD int im_on = im_get_status(); # endif /* Sync undo when evaluating the expression calls setline() or @@ -8412,7 +8379,7 @@ ins_reg(void) u_sync_once = 2; regname = get_expr_register(); -# ifdef FEAT_MBYTE +# ifdef HAVE_INPUT_METHOD /* Restore the Input Method. */ if (im_on) im_set_active(TRUE); @@ -8541,12 +8508,12 @@ ins_ctrl_hat(void) { curbuf->b_p_iminsert = B_IMODE_LMAP; State |= LANGMAP; -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD im_set_active(FALSE); #endif } } -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD else { /* There are no ":lmap" mappings, toggle IM */ @@ -8693,7 +8660,7 @@ ins_esc( } } -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD /* Disable IM to allow typing English directly for Normal mode commands. * When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as * well). */ @@ -8843,7 +8810,6 @@ ins_insert(int replaceState) } #endif -#ifdef FEAT_AUTOCMD # ifdef FEAT_EVAL set_vim_var_string(VV_INSERTMODE, (char_u *)((State & REPLACE_FLAG) ? "i" : @@ -8853,7 +8819,6 @@ ins_insert(int replaceState) "r"), 1); # endif apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf); -#endif if (State & REPLACE_FLAG) State = INSERT | (State & LANGMAP); else @@ -10573,7 +10538,7 @@ get_nolist_virtcol(void) return curwin->w_virtcol; } -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) /* * Handle the InsertCharPre autocommand. * "c" is the character that was typed. @@ -10590,11 +10555,11 @@ do_insert_char_pre(int c) if (!has_insertcharpre()) return NULL; -#ifdef FEAT_MBYTE +# ifdef FEAT_MBYTE if (has_mbyte) buf[(*mb_char2bytes)(c, buf)] = NUL; else -#endif +# endif { buf[0] = c; buf[1] = NUL; diff --git a/src/eval.c b/src/eval.c index 98288d6b0..2da56a47a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -5125,11 +5125,9 @@ garbage_collect(int testing) FOR_ALL_TAB_WINDOWS(tp, wp) abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID, NULL, NULL); -#ifdef FEAT_AUTOCMD if (aucmd_win != NULL) abort = abort || set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID, NULL, NULL); -#endif /* tabpage-local variables */ FOR_ALL_TABPAGES(tp) @@ -6560,7 +6558,6 @@ v_throwpoint(char_u *oldval) return NULL; } -#if defined(FEAT_AUTOCMD) || defined(PROTO) /* * Set v:cmdarg. * If "eap" != NULL, use "eap" to generate the value and return the old value. @@ -6618,7 +6615,7 @@ set_cmdarg(exarg_T *eap, char_u *oldarg) if (eap->force_ff != 0) sprintf((char *)newval + STRLEN(newval), " ++ff=%s", eap->cmd + eap->force_ff); -# ifdef FEAT_MBYTE +#ifdef FEAT_MBYTE if (eap->force_enc != 0) sprintf((char *)newval + STRLEN(newval), " ++enc=%s", eap->cmd + eap->force_enc); @@ -6628,11 +6625,10 @@ set_cmdarg(exarg_T *eap, char_u *oldarg) STRCPY(newval + STRLEN(newval), " ++bad=drop"); else if (eap->bad_char != 0) sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char); -# endif +#endif vimvars[VV_CMDARG].vv_str = newval; return oldval; } -#endif /* * Get the value of internal variable "name". diff --git a/src/evalfunc.c b/src/evalfunc.c index b02c95613..48eac5737 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -2668,9 +2668,7 @@ f_delete(typval_T *argvars, typval_T *rettv) static void f_did_filetype(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { -#ifdef FEAT_AUTOCMD rettv->vval.v_number = did_filetype; -#endif } /* @@ -3053,12 +3051,10 @@ f_exists(typval_T *argvars, typval_T *rettv) } else if (*p == '#') { -#ifdef FEAT_AUTOCMD if (p[1] == '#') n = autocmd_supported(p + 2); else n = au_exists(p + 1); -#endif } else /* internal variable */ { @@ -5797,9 +5793,7 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef FEAT_ARABIC "arabic", #endif -#ifdef FEAT_AUTOCMD "autocmd", -#endif #ifdef FEAT_AUTOSERVERNAME "autoservername", #endif diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 5b8e2d522..23930ca2a 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -28,9 +28,7 @@ static int read_viminfo_up_to_marks(vir_T *virp, int forceit, int writing); #endif static int check_readonly(int *forceit, buf_T *buf); -#ifdef FEAT_AUTOCMD static void delbuf_msg(char_u *name); -#endif static int #ifdef __BORLANDC__ _RTLENTRYF @@ -1148,9 +1146,7 @@ do_bang( /* Careful: This may recursively call do_bang() again! (because of * autocommands) */ do_filter(line1, line2, eap, newcmd, do_in, do_out); -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, FALSE, curbuf); -#endif } if (free_newcmd) vim_free(newcmd); @@ -1186,9 +1182,7 @@ do_filter( linenr_T read_linecount; pos_T cursor_save; char_u *cmd_buf; -#ifdef FEAT_AUTOCMD buf_T *old_curbuf = curbuf; -#endif int shell_flags = 0; if (*cmd == NUL) /* no filter command */ @@ -1259,16 +1253,14 @@ do_filter( { msg_putchar('\n'); /* keep message from buf_write() */ --no_wait_return; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!aborting()) #endif (void)EMSG2(_(e_notcreate), itmp); /* will call wait_return */ goto filterend; } -#ifdef FEAT_AUTOCMD if (curbuf != old_curbuf) goto filterend; -#endif if (!do_out) msg_putchar('\n'); @@ -1334,7 +1326,7 @@ do_filter( if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, READ_FILTER) != OK) { -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!aborting()) #endif { @@ -1343,10 +1335,8 @@ do_filter( } goto error; } -#ifdef FEAT_AUTOCMD if (curbuf != old_curbuf) goto filterend; -#endif } read_linecount = curbuf->b_ml.ml_line_count - read_linecount; @@ -1426,13 +1416,11 @@ error: filterend: -#ifdef FEAT_AUTOCMD if (curbuf != old_curbuf) { --no_wait_return; EMSG(_("E135: *Filter* Autocommands must not change current buffer")); } -#endif if (itmp != NULL) mch_remove(itmp); if (otmp != NULL) @@ -1482,9 +1470,7 @@ do_shell( * avoid having to type return below. */ msg_putchar('\r'); /* put cursor at start of line */ -#ifdef FEAT_AUTOCMD if (!autocmd_busy) -#endif { #ifdef MSWIN if (!winstart) @@ -1497,11 +1483,7 @@ do_shell( msg_putchar('\n'); /* may shift screen one line up */ /* warning message before calling the shell */ - if (p_warn -#ifdef FEAT_AUTOCMD - && !autocmd_busy -#endif - && msg_silent == 0) + if (p_warn && !autocmd_busy && msg_silent == 0) FOR_ALL_BUFFERS(buf) if (bufIsChangedNotTerm(buf)) { @@ -1536,14 +1518,12 @@ do_shell( msg_col = 0; } -#ifdef FEAT_AUTOCMD if (autocmd_busy) { if (msg_silent == 0) redraw_later_clear(); } else -#endif { /* * For ":sh" there is no need to call wait_return(), just redraw. @@ -1612,9 +1592,7 @@ do_shell( /* display any error messages now */ display_errors(); -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf); -#endif } /* @@ -2979,16 +2957,14 @@ rename_buffer(char_u *new_fname) char_u *fname, *sfname, *xfname; buf_T *buf; -#ifdef FEAT_AUTOCMD buf = curbuf; apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); /* buffer changed, don't change name now */ if (buf != curbuf) return FAIL; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return FAIL; -# endif #endif /* * The name of the current buffer will be changed. @@ -3017,9 +2993,8 @@ rename_buffer(char_u *new_fname) } 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 return OK; @@ -3198,22 +3173,20 @@ do_write(exarg_T *eap) { if (eap->cmdidx == CMD_saveas && alt_buf != NULL) { -#ifdef FEAT_AUTOCMD buf_T *was_curbuf = curbuf; apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, alt_buf); -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (curbuf != was_curbuf || aborting()) -# else +#else if (curbuf != was_curbuf) -# endif +#endif { /* buffer changed, don't change name now */ retval = FAIL; goto theend; } -#endif /* Exchange the file names for the current and the alternate * buffer. This makes it look like we are now editing the buffer * under the new name. Must be done before buf_write(), because @@ -3229,7 +3202,7 @@ do_write(exarg_T *eap) alt_buf->b_sfname = curbuf->b_sfname; curbuf->b_sfname = fname; buf_name_changed(curbuf); -#ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, alt_buf); if (!alt_buf->b_p_bl) @@ -3237,11 +3210,11 @@ do_write(exarg_T *eap) alt_buf->b_p_bl = TRUE; apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, alt_buf); } -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (curbuf != was_curbuf || aborting()) -# else +#else if (curbuf != was_curbuf) -# endif +#endif { /* buffer changed, don't write the file */ retval = FAIL; @@ -3260,7 +3233,6 @@ do_write(exarg_T *eap) /* Autocommands may have changed buffer names, esp. when * 'autochdir' is set. */ fname = curbuf->b_sfname; -#endif } name_was_missing = curbuf->b_ffname == NULL; @@ -3489,18 +3461,14 @@ do_wqall(exarg_T *eap) } else { -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf); -#endif if (buf_write_all(buf, eap->forceit) == FAIL) ++error; -#ifdef FEAT_AUTOCMD /* an autocommand may have deleted the buffer */ if (!bufref_valid(&bufref)) buf = firstbuf; -#endif } eap->forceit = save_forceit; /* check_overwrite() may set it */ } @@ -3604,10 +3572,8 @@ getfile( if (text_locked()) return GETFILE_ERROR; -#ifdef FEAT_AUTOCMD if (curbuf_locked()) return GETFILE_ERROR; -#endif if (fnum == 0) { @@ -3702,17 +3668,15 @@ do_ecmd( { int other_file; /* TRUE if editing another file */ int oldbuf; /* TRUE if using existing buffer */ -#ifdef FEAT_AUTOCMD int auto_buf = FALSE; /* TRUE if autocommands brought us into the buffer unexpectedly */ char_u *new_name = NULL; +#if defined(FEAT_EVAL) int did_set_swapcommand = FALSE; #endif buf_T *buf; bufref_T bufref; -#if defined(FEAT_AUTOCMD) || defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) bufref_T old_curbuf; -#endif char_u *free_fname = NULL; #ifdef FEAT_BROWSE char_u *browse_file = NULL; @@ -3736,9 +3700,7 @@ do_ecmd( if (eap != NULL) command = eap->do_ecmd_cmd; -#if defined(FEAT_AUTOCMD) || defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) set_bufref(&old_curbuf, curbuf); -#endif if (fnum != 0) { @@ -3751,11 +3713,10 @@ do_ecmd( #ifdef FEAT_BROWSE if (cmdmod.browse) { -# ifdef FEAT_AUTOCMD if ( -# ifdef FEAT_GUI +# ifdef FEAT_GUI !gui.in_use && -# endif +# endif au_has_group((char_u *)"FileExplorer")) { /* No browsing supported but we do have the file explorer: @@ -3764,7 +3725,6 @@ do_ecmd( ffname = (char_u *)"."; } else -# endif { browse_file = do_browse(0, (char_u *)_("Edit File"), ffname, NULL, NULL, NULL, curbuf); @@ -3838,7 +3798,7 @@ do_ecmd( */ reset_VIsual(); -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) if ((command != NULL || newlnum > (linenr_T)0) && *get_vim_var_str(VV_SWAPCOMMAND) == NUL) { @@ -3901,12 +3861,11 @@ do_ecmd( #endif buf = buflist_new(ffname, sfname, 0L, BLN_CURBUF | ((flags & ECMD_SET_HELP) ? 0 : BLN_LISTED)); -#ifdef FEAT_AUTOCMD + /* autocommands may change curwin and curbuf */ if (oldwin != NULL) oldwin = curwin; set_bufref(&old_curbuf, curbuf); -#endif } if (buf == NULL) goto theend; @@ -3921,11 +3880,7 @@ do_ecmd( (void)buf_check_timestamp(buf, FALSE); /* Check if autocommands made the buffer invalid or changed the * current buffer. */ - if (!bufref_valid(&bufref) -#ifdef FEAT_AUTOCMD - || curbuf != old_curbuf.br_buf -#endif - ) + if (!bufref_valid(&bufref) || curbuf != old_curbuf.br_buf) goto theend; #ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ @@ -3950,7 +3905,6 @@ do_ecmd( */ if (buf != curbuf) { -#ifdef FEAT_AUTOCMD /* * Be careful: The autocommands may delete any buffer and change * the current buffer. @@ -3971,13 +3925,13 @@ do_ecmd( delbuf_msg(new_name); /* frees new_name */ goto theend; } -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ { vim_free(new_name); goto theend; } -# endif +#endif if (buf == curbuf) /* already in new buffer */ auto_buf = TRUE; else @@ -3990,7 +3944,6 @@ do_ecmd( ++buf->b_locked; if (curbuf == old_curbuf.br_buf) -#endif buf_copy_options(buf, BCO_ENTER); /* Close the link to the current buffer. This will set @@ -3999,18 +3952,17 @@ do_ecmd( close_buffer(oldwin, curbuf, (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE); -#ifdef FEAT_AUTOCMD the_curwin->w_closing = FALSE; --buf->b_locked; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL /* autocmds may abort script processing */ if (aborting() && curwin->w_buffer != NULL) { vim_free(new_name); goto theend; } -# endif +#endif /* Be careful again, like above. */ if (!bufref_valid(&au_new_curbuf)) { @@ -4021,7 +3973,6 @@ do_ecmd( if (buf == curbuf) /* already in new buffer */ auto_buf = TRUE; else -#endif { #ifdef FEAT_SYN_HL /* @@ -4054,13 +4005,10 @@ do_ecmd( #ifdef FEAT_SPELL did_get_winopts = TRUE; #endif - -#ifdef FEAT_AUTOCMD } vim_free(new_name); au_new_curbuf.br_buf = NULL; au_new_curbuf.br_buf_free_count = 0; -#endif } curwin->w_pcmark.lnum = 1; @@ -4083,9 +4031,7 @@ do_ecmd( ++RedrawingDisabled; did_inc_redrawing_disabled = TRUE; -#ifdef FEAT_AUTOCMD buf = curbuf; -#endif if ((flags & ECMD_SET_HELP) || keep_help_flag) { prepare_help_buffer(); @@ -4098,21 +4044,19 @@ do_ecmd( set_buflisted(TRUE); } -#ifdef FEAT_AUTOCMD /* If autocommands change buffers under our fingers, forget about * editing the file. */ if (buf != curbuf) goto theend; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ goto theend; -# endif +#endif /* Since we are starting to edit a file, consider the filetype to be * unset. Helps for when an autocommand changes files and expects syntax * highlighting to work in the other file. */ did_filetype = FALSE; -#endif /* * other_file oldbuf @@ -4129,14 +4073,13 @@ do_ecmd( newlnum = curwin->w_cursor.lnum; solcol = curwin->w_cursor.col; } -#ifdef FEAT_AUTOCMD buf = curbuf; if (buf->b_fname != NULL) new_name = vim_strsave(buf->b_fname); else new_name = NULL; set_bufref(&bufref, buf); -#endif + if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur) { /* Save all the text, so that the reload can be undone. @@ -4145,9 +4088,7 @@ do_ecmd( if (u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE) == FAIL) { -#ifdef FEAT_AUTOCMD vim_free(new_name); -#endif goto theend; } u_unchanged(curbuf); @@ -4158,7 +4099,7 @@ do_ecmd( } else buf_freeall(curbuf, 0); /* free all things for buffer */ -#ifdef FEAT_AUTOCMD + /* If autocommands deleted the buffer we were going to re-edit, give * up and jump to the end. */ if (!bufref_valid(&bufref)) @@ -4173,10 +4114,9 @@ do_ecmd( * the autocommands changed the buffer... */ if (buf != curbuf) goto theend; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ goto theend; -# endif #endif buf_clear_file(curbuf); curbuf->b_op_start.lnum = 0; /* clear '[ and '] marks */ @@ -4194,9 +4134,7 @@ do_ecmd( */ check_arg_idx(curwin); -#ifdef FEAT_AUTOCMD if (!auto_buf) -#endif { /* * Set cursor and init window before reading the file and executing @@ -4237,7 +4175,7 @@ do_ecmd( /* * Open the buffer and read the file. */ -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (should_abort(open_buffer(FALSE, eap, readfile_flags))) retval = FAIL; #else @@ -4250,7 +4188,6 @@ do_ecmd( handle_swap_exists(&old_curbuf); #endif } -#ifdef FEAT_AUTOCMD else { /* Read the modelines, but only to set window-local options. Any @@ -4264,7 +4201,6 @@ do_ecmd( &retval); } check_arg_idx(curwin); -#endif /* If autocommands change the cursor position or topline, we should * keep it. Also when it moves within a line. */ @@ -4342,11 +4278,7 @@ do_ecmd( * Did not read the file, need to show some info about the file. * Do this after setting the cursor. */ - if (oldbuf -#ifdef FEAT_AUTOCMD - && !auto_buf -#endif - ) + if (oldbuf && !auto_buf) { int msg_scroll_save = msg_scroll; @@ -4430,7 +4362,7 @@ do_ecmd( theend: if (did_inc_redrawing_disabled) --RedrawingDisabled; -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) if (did_set_swapcommand) set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); #endif @@ -4441,7 +4373,6 @@ theend: return retval; } -#ifdef FEAT_AUTOCMD static void delbuf_msg(char_u *name) { @@ -4451,7 +4382,6 @@ delbuf_msg(char_u *name) au_new_curbuf.br_buf = NULL; au_new_curbuf.br_buf_free_count = 0; } -#endif static int append_indent = 0; /* autoindent for first line */ @@ -5156,7 +5086,7 @@ do_sub(exarg_T *eap) */ line2 = eap->line2; for (lnum = eap->line1; lnum <= line2 && !(got_quit -#if defined(FEAT_EVAL) && defined(FEAT_AUTOCMD) +#if defined(FEAT_EVAL) || aborting() #endif ); ++lnum) @@ -6870,7 +6800,6 @@ fix_help_buffer(void) char_u *rt; int mustfree; -#ifdef FEAT_AUTOCMD /* Set filetype to "help" if still needed. */ if (STRCMP(curbuf->b_p_ft, "help") != 0) { @@ -6878,7 +6807,6 @@ fix_help_buffer(void) set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL); --curbuf_lock; } -#endif #ifdef FEAT_SYN_HL if (!syntax_present(curwin)) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 805e8c458..b1f80f9b9 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2045,17 +2045,15 @@ autowrite_all(void) FOR_ALL_BUFFERS(buf) if (bufIsChanged(buf) && !buf->b_p_ro) { -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf); -#endif + (void)buf_write_all(buf, FALSE); -#ifdef FEAT_AUTOCMD + /* an autocommand may have deleted the buffer */ if (!bufref_valid(&bufref)) buf = firstbuf; -#endif } } @@ -2067,11 +2065,9 @@ autowrite_all(void) check_changed(buf_T *buf, int flags) { int forceit = (flags & CCGD_FORCEIT); -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf); -#endif if ( !forceit && bufIsChanged(buf) @@ -2093,17 +2089,15 @@ check_changed(buf_T *buf, int flags) # endif )) ++count; -# ifdef FEAT_AUTOCMD if (!bufref_valid(&bufref)) /* Autocommand deleted buffer, oops! It's not changed now. */ return FALSE; -# endif + dialog_changed(buf, count > 1); -# ifdef FEAT_AUTOCMD + if (!bufref_valid(&bufref)) /* Autocommand deleted buffer, oops! It's not changed now. */ return FALSE; -# endif return bufIsChanged(buf); } #endif @@ -2197,11 +2191,9 @@ dialog_changed( ) && !buf2->b_p_ro) { -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf2); -#endif #ifdef FEAT_BROWSE /* May get file name, when there is none */ browse_save_fname(buf2); @@ -2210,11 +2202,10 @@ dialog_changed( buf2->b_fname, buf2->b_ffname, FALSE) == OK) /* didn't hit Cancel */ (void)buf_write_all(buf2, FALSE); -#ifdef FEAT_AUTOCMD + /* an autocommand may have deleted the buffer */ if (!bufref_valid(&bufref)) buf2 = firstbuf; -#endif } } } @@ -2370,19 +2361,15 @@ check_changed_any( FOR_ALL_TAB_WINDOWS(tp, wp) if (wp->w_buffer == buf) { -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf); -#endif + goto_tabpage_win(tp, wp); -#ifdef FEAT_AUTOCMD + /* Paranoia: did autocms wipe out the buffer with changes? */ if (!bufref_valid(&bufref)) - { goto theend; - } -#endif goto buf_found; } buf_found: @@ -2420,20 +2407,16 @@ check_fname(void) buf_write_all(buf_T *buf, int forceit) { int retval; -#ifdef FEAT_AUTOCMD buf_T *old_curbuf = curbuf; -#endif retval = (buf_write(buf, buf->b_ffname, buf->b_fname, (linenr_T)1, buf->b_ml.ml_line_count, NULL, FALSE, forceit, TRUE, FALSE)); -#ifdef FEAT_AUTOCMD if (curbuf != old_curbuf) { msg_source(HL_ATTR(HLF_W)); MSG(_("Warning: Entered other buffer unexpectedly (check autocommands)")); } -#endif return retval; } @@ -3053,7 +3036,7 @@ ex_listdo(exarg_T *eap) tabpage_T *tp; buf_T *buf = curbuf; int next_fnum = 0; -#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) +#if defined(FEAT_SYN_HL) char_u *save_ei = NULL; #endif char_u *p_shm_save; @@ -3071,7 +3054,7 @@ ex_listdo(exarg_T *eap) } #endif -#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) +#if defined(FEAT_SYN_HL) if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) /* Don't do syntax HL autocommands. Skipping the syntax file is a * great speed improvement. */ @@ -3265,7 +3248,7 @@ ex_listdo(exarg_T *eap) listcmd_busy = FALSE; } -#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) +#if defined(FEAT_SYN_HL) if (save_ei != NULL) { au_event_restore(save_ei); @@ -3660,6 +3643,8 @@ source_in_path(char_u *path, char_u *name, int flags) } +#if defined(FEAT_EVAL) || defined(PROTO) + /* * Expand wildcards in "pat" and invoke do_source() for each match. */ @@ -3800,7 +3785,6 @@ load_pack_plugin(char_u *fname) vim_snprintf((char *)pat, len, plugpat, ffname); source_all_matches(pat); -#ifdef FEAT_AUTOCMD { char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes"); @@ -3815,7 +3799,6 @@ load_pack_plugin(char_u *fname) } vim_free(cmd); } -#endif vim_free(pat); retval = OK; @@ -3911,8 +3894,9 @@ ex_packadd(exarg_T *eap) vim_free(pat); } } +#endif -#if defined(FEAT_EVAL) && defined(FEAT_AUTOCMD) +#if defined(FEAT_EVAL) || defined(PROTO) /* * ":options" */ @@ -4308,23 +4292,21 @@ do_source( goto theend; } -#ifdef FEAT_AUTOCMD /* Apply SourceCmd autocommands, they should get the file and source it. */ if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL) && apply_autocmds(EVENT_SOURCECMD, fname_exp, fname_exp, FALSE, curbuf)) { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL retval = aborting() ? FAIL : OK; -# else +#else retval = OK; -# endif +#endif goto theend; } /* Apply SourcePre autocommands, they may get the file. */ apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, FALSE, curbuf); -#endif #ifdef USE_FOPEN_NOINH cookie.fp = fopen_noinh_readbin((char *)fname_exp); diff --git a/src/ex_docmd.c b/src/ex_docmd.c index b923980e3..c0eed2d5f 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -81,14 +81,8 @@ static void ex_abclear(exarg_T *eap); # define ex_menu ex_ni # define ex_menutranslate ex_ni #endif -#ifdef FEAT_AUTOCMD static void ex_autocmd(exarg_T *eap); static void ex_doautocmd(exarg_T *eap); -#else -# define ex_autocmd ex_ni -# define ex_doautocmd ex_ni -# define ex_doautoall ex_ni -#endif #ifdef FEAT_LISTCMDS static void ex_bunload(exarg_T *eap); static void ex_buffer(exarg_T *eap); @@ -234,6 +228,10 @@ static void ex_popup(exarg_T *eap); # define ex_syntax ex_ni # define ex_ownsyntax ex_ni #endif +#ifndef FEAT_EVAL +# define ex_packadd ex_ni +# define ex_packloadall ex_ni +#endif #if !defined(FEAT_SYN_HL) || !defined(FEAT_PROFILE) # define ex_syntime ex_ni #endif @@ -390,13 +388,8 @@ static void ex_viminfo(exarg_T *eap); # define ex_viminfo ex_ni #endif static void ex_behave(exarg_T *eap); -#ifdef FEAT_AUTOCMD static void ex_filetype(exarg_T *eap); static void ex_setfiletype(exarg_T *eap); -#else -# define ex_filetype ex_ni -# define ex_setfiletype ex_ni -#endif #ifndef FEAT_DIFF # define ex_diffoff ex_ni # define ex_diffpatch ex_ni @@ -407,7 +400,7 @@ static void ex_setfiletype(exarg_T *eap); #endif static void ex_digraphs(exarg_T *eap); static void ex_set(exarg_T *eap); -#if !defined(FEAT_EVAL) || !defined(FEAT_AUTOCMD) +#if !defined(FEAT_EVAL) # define ex_options ex_ni #endif #ifdef FEAT_SEARCH_EXTRA @@ -1761,11 +1754,8 @@ do_one_cmd( /* avoid that a function call in 'statusline' does this */ && !getline_equal(fgetline, cookie, get_func_line) #endif -#ifdef FEAT_AUTOCMD /* avoid that an autocommand, e.g. QuitPre, does this */ - && !getline_equal(fgetline, cookie, getnextac) -#endif - ) + && !getline_equal(fgetline, cookie, getnextac)) --quitmore; /* @@ -1912,7 +1902,6 @@ do_one_cmd( case 'n': if (checkforcmd(&ea.cmd, "noautocmd", 3)) { -#ifdef FEAT_AUTOCMD if (cmdmod.save_ei == NULL) { /* Set 'eventignore' to "all". Restore the @@ -1921,7 +1910,6 @@ do_one_cmd( set_string_option_direct((char_u *)"ei", -1, (char_u *)"all", OPT_FREE, SID_NONE); } -#endif continue; } if (!checkforcmd(&ea.cmd, "noswapfile", 3)) @@ -2302,7 +2290,6 @@ do_one_cmd( goto doend; } -#ifdef FEAT_AUTOCMD /* If this looks like an undefined user command and there are CmdUndefined * autocommands defined, trigger the matching autocommands. */ if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip @@ -2319,9 +2306,12 @@ do_one_cmd( vim_free(p); /* If the autocommands did something and didn't cause an error, try * finding the command again. */ - p = (ret && !aborting()) ? find_command(&ea, NULL) : ea.cmd; - } + p = (ret +#ifdef FEAT_EVAL + && !aborting() #endif + ) ? find_command(&ea, NULL) : ea.cmd; + } #ifdef FEAT_USR_CMDS if (p == NULL) @@ -2421,7 +2411,6 @@ do_one_cmd( errormsg = (char_u *)_(get_text_locked_msg()); goto doend; } -#ifdef FEAT_AUTOCMD /* Disallow editing another buffer when "curbuf_lock" is set. * Do allow ":edit" (check for argument later). * Do allow ":checktime" (it's postponed). */ @@ -2431,7 +2420,6 @@ do_one_cmd( && !IS_USER_CMDIDX(ea.cmdidx) && curbuf_locked()) goto doend; -#endif if (!ni && !(ea.argt & RANGE) && ea.addr_count > 0) { @@ -2971,7 +2959,7 @@ doend: if (verbose_save >= 0) p_verbose = verbose_save; -#ifdef FEAT_AUTOCMD + if (cmdmod.save_ei != NULL) { /* Restore 'eventignore' to the value before ":noautocmd". */ @@ -2979,7 +2967,7 @@ doend: OPT_FREE, SID_NONE); free_string_option(cmdmod.save_ei); } -#endif + if (cmdmod.filter_regmatch.regprog != NULL) vim_regfree(cmdmod.filter_regmatch.regprog); @@ -4025,14 +4013,12 @@ set_one_cmd_context( } } break; -#ifdef FEAT_AUTOCMD + case CMD_autocmd: return set_context_in_autocmd(xp, arg, FALSE); - case CMD_doautocmd: case CMD_doautoall: return set_context_in_autocmd(xp, arg, TRUE); -#endif case CMD_set: set_context_in_set_cmd(xp, arg, 0); break; @@ -5500,7 +5486,6 @@ ex_abclear(exarg_T *eap) map_clear(eap->cmd, eap->arg, TRUE, TRUE); } -#if defined(FEAT_AUTOCMD) || defined(PROTO) static void ex_autocmd(exarg_T *eap) { @@ -5534,7 +5519,6 @@ ex_doautocmd(exarg_T *eap) if (call_do_modelines && did_aucmd) do_modelines(0); } -#endif #ifdef FEAT_LISTCMDS /* @@ -7234,7 +7218,6 @@ ex_quit(exarg_T *eap) else wp = curwin; -#ifdef FEAT_AUTOCMD /* Refuse to quit when locked. */ if (curbuf_locked()) return; @@ -7245,7 +7228,6 @@ ex_quit(exarg_T *eap) if (!win_valid(wp) || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) return; -#endif #ifdef FEAT_NETBEANS_INTG netbeansForcedQuit = eap->forceit; @@ -7318,13 +7300,11 @@ ex_quit_all(exarg_T *eap) text_locked_msg(); return; } -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf); /* Refuse to quit when locked or when the buffer in the last window is * being closed (can only happen in autocommands). */ if (curbuf_locked() || (curbuf->b_nwindows == 1 && curbuf->b_locked > 0)) return; -#endif exiting = TRUE; if (eap->forceit || !check_changed_any(FALSE, FALSE)) @@ -7345,11 +7325,7 @@ ex_close(exarg_T *eap) cmdwin_result = Ctrl_C; else #endif - if (!text_locked() -#ifdef FEAT_AUTOCMD - && !curbuf_locked() -#endif - ) + if (!text_locked() && !curbuf_locked()) { if (eap->addr_count == 0) ex_win_close(eap->forceit, curwin, NULL); @@ -7565,11 +7541,7 @@ ex_tabclose(exarg_T *eap) tabpage_close_other(tp, eap->forceit); return; } - else if (!text_locked() -#ifdef FEAT_AUTOCMD - && !curbuf_locked() -#endif - ) + else if (!text_locked() && !curbuf_locked()) tabpage_close(eap->forceit); } } @@ -7662,9 +7634,7 @@ tabpage_close_other(tabpage_T *tp, int forceit) break; } -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); -#endif redraw_tabline = TRUE; if (h != tabline_height()) @@ -7790,13 +7760,11 @@ ex_exit(exarg_T *eap) text_locked_msg(); return; } -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf); /* Refuse to quit when locked or when the buffer in the last window is * being closed (can only happen in autocommands). */ if (curbuf_locked() || (curbuf->b_nwindows == 1 && curbuf->b_locked > 0)) return; -#endif /* * if more files or windows we won't exit @@ -7901,10 +7869,9 @@ handle_drop( /* Postpone this while editing the command line. */ if (text_locked()) return; -#ifdef FEAT_AUTOCMD if (curbuf_locked()) return; -#endif + /* When the screen is being updated we should not change buffers and * windows structures, it may cause freed memory to be used. */ if (updating_screen) @@ -8072,9 +8039,7 @@ alist_set( if (recursive) { -#ifdef FEAT_AUTOCMD EMSG(_(e_au_recursive)); -#endif return; } ++recursive; @@ -8251,11 +8216,10 @@ ex_splitview(exarg_T *eap) && eap->cmdidx != CMD_vnew && eap->cmdidx != CMD_new) { -# ifdef FEAT_AUTOCMD if ( -# ifdef FEAT_GUI +# ifdef FEAT_GUI !gui.in_use && -# endif +# endif au_has_group((char_u *)"FileExplorer")) { /* No browsing supported but we do have the file explorer: @@ -8264,7 +8228,6 @@ ex_splitview(exarg_T *eap) eap->arg = (char_u *)"."; } else -# endif { fname = do_browse(0, (char_u *)_("Edit File in new window"), eap->arg, NULL, NULL, NULL, curbuf); @@ -8668,12 +8631,11 @@ do_exedit( #endif ) { -#ifdef FEAT_AUTOCMD /* Can't edit another file when "curbuf_lock" is set. Only ":edit" * can bring us here, others are stopped earlier. */ if (*eap->arg != NUL && curbuf_locked()) return; -#endif + n = readonlymode; if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) readonlymode = TRUE; @@ -8702,7 +8664,7 @@ do_exedit( need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1); if (!need_hide || buf_hide(curbuf)) { -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) cleanup_T cs; /* Reset the error/interrupt/exception state here so that @@ -8714,7 +8676,7 @@ do_exedit( #endif win_close(curwin, !need_hide && !buf_hide(curbuf)); -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) /* Restore the error/interrupt/exception state if not * discarded by a new aborting error, interrupt, or * uncaught exception. */ @@ -8927,7 +8889,7 @@ ex_read(exarg_T *eap) } if (i != OK) { -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!aborting()) #endif EMSG2(_(e_notopen), eap->arg); @@ -9013,10 +8975,8 @@ ex_cd(exarg_T *eap) else #endif { -#ifdef FEAT_AUTOCMD if (allbuf_locked()) return; -#endif if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged() && !eap->forceit) { @@ -9073,11 +9033,9 @@ ex_cd(exarg_T *eap) /* Echo the new current directory if the command was typed. */ if (KeyTyped || p_verbose >= 5) ex_pwd(eap); -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_DIRCHANGED, is_local_chdir ? (char_u *)"window" : (char_u *)"global", new_dir, FALSE, curbuf); -#endif } vim_free(tofree); } @@ -10588,21 +10546,15 @@ find_cmdline_var(char_u *src, int *usedlen) #define SPEC_SFILE (SPEC_CFILE + 1) "<slnum>", /* ":so" file line number */ #define SPEC_SLNUM (SPEC_SFILE + 1) -#ifdef FEAT_AUTOCMD "<afile>", /* autocommand file name */ -# define SPEC_AFILE (SPEC_SLNUM + 1) +#define SPEC_AFILE (SPEC_SLNUM + 1) "<abuf>", /* autocommand buffer number */ -# define SPEC_ABUF (SPEC_AFILE + 1) +#define SPEC_ABUF (SPEC_AFILE + 1) "<amatch>", /* autocommand match name */ -# define SPEC_AMATCH (SPEC_ABUF + 1) -#endif +#define SPEC_AMATCH (SPEC_ABUF + 1) #ifdef FEAT_CLIENTSERVER "<client>" -# ifdef FEAT_AUTOCMD -# define SPEC_CLIENT (SPEC_AMATCH + 1) -# else -# define SPEC_CLIENT (SPEC_SLNUM + 1) -# endif +# define SPEC_CLIENT (SPEC_AMATCH + 1) #endif }; @@ -10801,7 +10753,6 @@ eval_vars( break; #endif -#ifdef FEAT_AUTOCMD case SPEC_AFILE: /* file name for autocommand */ result = autocmd_fname; if (result != NULL && !autocmd_fname_full) @@ -10840,7 +10791,6 @@ eval_vars( } break; -#endif case SPEC_SFILE: /* file name for ":so" command */ result = sourcing_name; if (result == NULL) @@ -10976,7 +10926,6 @@ arg_all(void) return retval; } -#if defined(FEAT_AUTOCMD) || defined(PROTO) /* * Expand the <sfile> string in "arg". * @@ -11038,7 +10987,6 @@ expand_sfile(char_u *arg) return result; } -#endif #ifdef FEAT_SESSION static int ses_winsizes(FILE *fd, int restore_size, @@ -12070,7 +12018,6 @@ get_mapclear_arg(expand_T *xp UNUSED, int idx) return NULL; } -#ifdef FEAT_AUTOCMD static int filetype_detect = FALSE; static int filetype_plugin = FALSE; static int filetype_indent = FALSE; @@ -12184,7 +12131,6 @@ ex_setfiletype(exarg_T *eap) did_filetype = FALSE; } } -#endif static void ex_digraphs(exarg_T *eap UNUSED) @@ -12208,7 +12154,7 @@ ex_set(exarg_T *eap) flags = OPT_LOCAL; else if (eap->cmdidx == CMD_setglobal) flags = OPT_GLOBAL; -#if defined(FEAT_EVAL) && defined(FEAT_AUTOCMD) && defined(FEAT_BROWSE) +#if defined(FEAT_EVAL) && defined(FEAT_BROWSE) if (cmdmod.browse && flags == 0) ex_options(eap); else diff --git a/src/ex_getln.c b/src/ex_getln.c index f92f1dfed..6119ad216 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -146,7 +146,6 @@ static void set_search_match(pos_T *t); #endif -#ifdef FEAT_AUTOCMD static void trigger_cmd_autocmd(int typechar, int evt) { @@ -156,7 +155,6 @@ trigger_cmd_autocmd(int typechar, int evt) typestr[1] = NUL; apply_autocmds(evt, typestr, typestr, FALSE, curbuf); } -#endif /* * Abandon the command line. @@ -266,9 +264,7 @@ getcmdline( * custom status line may invoke ":normal". */ struct cmdline_info save_ccline; #endif -#ifdef FEAT_AUTOCMD int cmdline_type; -#endif #ifdef FEAT_EVAL if (firstc == -1) @@ -376,11 +372,11 @@ getcmdline( b_im_ptr = &curbuf->b_p_imsearch; if (*b_im_ptr == B_IMODE_LMAP) State |= LANGMAP; -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD im_set_active(*b_im_ptr == B_IMODE_IM); #endif } -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD else if (p_imcmdline) im_set_active(TRUE); #endif @@ -396,11 +392,9 @@ getcmdline( * terminal mode set to cooked. Need to set raw mode here then. */ settmode(TMODE_RAW); -#ifdef FEAT_AUTOCMD /* Trigger CmdlineEnter autocommands. */ cmdline_type = firstc == NUL ? '-' : firstc; trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER); -#endif #ifdef FEAT_CMDHIST init_history(); @@ -1132,7 +1126,7 @@ getcmdline( { /* ":lmap" mappings exists, toggle use of mappings. */ State ^= LANGMAP; -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD im_set_active(FALSE); /* Disable input method */ #endif if (b_im_ptr != NULL) @@ -1143,7 +1137,7 @@ getcmdline( *b_im_ptr = B_IMODE_NONE; } } -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD else { /* There are no ":lmap" mappings, toggle IM. When @@ -1946,10 +1940,8 @@ cmdline_not_changed: #endif cmdline_changed: -#ifdef FEAT_AUTOCMD /* Trigger CmdlineChanged autocommands. */ trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED); -#endif #ifdef FEAT_SEARCH_EXTRA /* @@ -2160,13 +2152,11 @@ returncmd: if (some_key_typed) need_wait_return = FALSE; -#ifdef FEAT_AUTOCMD /* Trigger CmdlineLeave autocommands. */ trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE); -#endif State = save_State; -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP) im_save_status(b_im_ptr); im_set_active(FALSE); @@ -2266,7 +2256,6 @@ get_text_locked_msg(void) return e_secure; } -#if defined(FEAT_AUTOCMD) || defined(PROTO) /* * Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is * and give an error message. @@ -2296,7 +2285,6 @@ allbuf_locked(void) } return FALSE; } -#endif static int cmdline_charsize(int idx) @@ -4983,10 +4971,8 @@ ExpandFromContext( {EXPAND_SYNTIME, get_syntime_arg, TRUE, TRUE}, #endif {EXPAND_HIGHLIGHT, get_highlight_name, TRUE, TRUE}, -#ifdef FEAT_AUTOCMD {EXPAND_EVENTS, get_event_name, TRUE, TRUE}, {EXPAND_AUGROUP, get_augroup_name, TRUE, TRUE}, -#endif #ifdef FEAT_CSCOPE {EXPAND_CSCOPE, get_cscope_name, TRUE, TRUE}, #endif @@ -6930,10 +6916,9 @@ open_cmdwin(void) /* Save current window sizes. */ win_size_save(&winsizes); -# ifdef FEAT_AUTOCMD /* Don't execute autocommands while creating the window. */ block_autocmds(); -# endif + /* don't use a new tab page */ cmdmod.tab = 0; cmdmod.noswapfile = 1; @@ -6942,9 +6927,7 @@ open_cmdwin(void) if (win_split((int)p_cwh, WSP_BOT) == FAIL) { beep_flush(); -# ifdef FEAT_AUTOCMD unblock_autocmds(); -# endif return K_IGNORE; } cmdwin_type = get_cmdline_type(); @@ -6963,12 +6946,10 @@ open_cmdwin(void) # endif RESET_BINDING(curwin); -# ifdef FEAT_AUTOCMD /* Do execute autocommands for setting the filetype (load syntax). */ unblock_autocmds(); /* But don't allow switching to another buffer. */ ++curbuf_lock; -# endif /* Showing the prompt may have set need_wait_return, reset it. */ need_wait_return = FALSE; @@ -6983,9 +6964,7 @@ open_cmdwin(void) } set_option_value((char_u *)"ft", 0L, (char_u *)"vim", OPT_LOCAL); } -# ifdef FEAT_AUTOCMD --curbuf_lock; -# endif /* Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin * sets 'textwidth' to 78). */ @@ -7031,12 +7010,10 @@ open_cmdwin(void) setmouse(); # endif -# ifdef FEAT_AUTOCMD /* Trigger CmdwinEnter autocommands. */ trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER); if (restart_edit != 0) /* autocmd with ":startinsert" */ stuffcharReadbuff(K_NOP); -# endif i = RedrawingDisabled; RedrawingDisabled = 0; @@ -7049,20 +7026,16 @@ open_cmdwin(void) RedrawingDisabled = i; -# ifdef FEAT_AUTOCMD - -# ifdef FEAT_FOLDING +# ifdef FEAT_FOLDING save_KeyTyped = KeyTyped; -# endif +# endif /* Trigger CmdwinLeave autocommands. */ trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE); -# ifdef FEAT_FOLDING +# ifdef FEAT_FOLDING /* Restore KeyTyped in case it is modified by autocommands */ KeyTyped = save_KeyTyped; -# endif - # endif /* Restore the command line info. */ @@ -7080,7 +7053,7 @@ open_cmdwin(void) } else { -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +# if defined(FEAT_EVAL) /* autocmds may abort script processing */ if (aborting() && cmdwin_result != K_IGNORE) cmdwin_result = Ctrl_C; @@ -7141,10 +7114,8 @@ open_cmdwin(void) } } -# ifdef FEAT_AUTOCMD /* Don't execute autocommands while deleting the window. */ block_autocmds(); -# endif # ifdef FEAT_CONCEAL /* Avoid command-line window first character being concealed. */ curwin->w_p_cole = 0; @@ -7162,9 +7133,7 @@ open_cmdwin(void) /* Restore window sizes. */ win_size_restore(&winsizes); -# ifdef FEAT_AUTOCMD unblock_autocmds(); -# endif } ga_clear(&winsizes); diff --git a/src/feature.h b/src/feature.h index 2d57d6704..6d35265c2 100644 --- a/src/feature.h +++ b/src/feature.h @@ -440,17 +440,10 @@ #endif /* - * +autocmd ":autocmd" command - */ -#ifdef FEAT_NORMAL -# define FEAT_AUTOCMD -#endif - -/* * +diff Displaying diffs in a nice way. * Requires +windows and +autocmd. */ -#if defined(FEAT_NORMAL) && defined(FEAT_AUTOCMD) +#if defined(FEAT_NORMAL) # define FEAT_DIFF #endif diff --git a/src/fileio.c b/src/fileio.c index 8798cff1b..7149a227b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -47,14 +47,12 @@ static int msg_add_fileformat(int eol_type); static void msg_add_eol(void); static int check_mtime(buf_T *buf, stat_T *s); static int time_differs(long t1, long t2); -#ifdef FEAT_AUTOCMD static int apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap); static int au_find_group(char_u *name); # define AUGROUP_DEFAULT -1 /* default autocmd group */ # define AUGROUP_ERROR -2 /* erroneous autocmd group */ # define AUGROUP_ALL -3 /* all autocmd groups */ -#endif #if defined(FEAT_CRYPT) || defined(FEAT_MBYTE) # define HAS_BW_FLAGS @@ -135,11 +133,8 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf); #ifdef TEMPDIRNAMES static void vim_settempdir(char_u *tempdir); #endif -#ifdef FEAT_AUTOCMD static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name"); -#endif -#ifdef FEAT_AUTOCMD /* * Set by the apply_autocmds_group function if the given event is equal to * EVENT_FILETYPE. Used by the readfile function in order to determine if @@ -149,7 +144,6 @@ static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer na * apply_autocmds_group. */ static int au_did_filetype INIT(= FALSE); -#endif void filemess( @@ -307,17 +301,13 @@ readfile( char_u conv_rest[CONV_RESTLEN]; int conv_restlen = 0; /* nr of bytes in conv_rest[] */ #endif -#ifdef FEAT_AUTOCMD buf_T *old_curbuf; char_u *old_b_ffname; char_u *old_b_fname; int using_b_ffname; int using_b_fname; -#endif -#ifdef FEAT_AUTOCMD au_did_filetype = FALSE; /* reset before triggering any autocommands */ -#endif curbuf->b_no_eol_lnum = 0; /* in case it was set by the previous read */ @@ -337,7 +327,6 @@ readfile( return FAIL; } -#ifdef FEAT_AUTOCMD /* Remember the initial values of curbuf, curbuf->b_ffname and * curbuf->b_fname to detect whether they are altered as a result of * executing nasty autocommands. Also check if "fname" and "sfname" @@ -348,7 +337,6 @@ readfile( using_b_ffname = (fname == curbuf->b_ffname) || (sfname == curbuf->b_ffname); using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname); -#endif /* After reading a file the cursor line changes but we don't want to * display the line. */ @@ -369,7 +357,6 @@ readfile( fname = sfname; #endif -#ifdef FEAT_AUTOCMD /* * The BufReadCmd and FileReadCmd events intercept the reading process by * executing the associated commands instead. @@ -404,7 +391,6 @@ readfile( curbuf->b_op_start = pos; } -#endif if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0) msg_scroll = FALSE; /* overwrite previous file message */ @@ -613,7 +599,6 @@ readfile( #endif { check_need_swap(newfile); -#ifdef FEAT_AUTOCMD /* SwapExists autocommand may mess things up */ if (curbuf != old_curbuf || (using_b_ffname @@ -624,7 +609,6 @@ readfile( EMSG(_(e_auchangedbuf)); return FAIL; } -#endif } if (dir_of_file_exists(fname)) filemess(curbuf, sfname, (char_u *)_("[New File]"), 0); @@ -641,14 +625,12 @@ readfile( if (eap != NULL) set_forced_fenc(eap); #endif -#ifdef FEAT_AUTOCMD apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname, FALSE, curbuf, eap); -#endif /* remember the current fileformat */ save_file_ff(curbuf); -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (aborting()) /* autocmds may abort script processing */ return FAIL; #endif @@ -701,7 +683,6 @@ readfile( #endif { check_need_swap(newfile); -#ifdef FEAT_AUTOCMD if (!read_stdin && (curbuf != old_curbuf || (using_b_ffname && (old_b_ffname != curbuf->b_ffname)) || (using_b_fname && (old_b_fname != curbuf->b_fname)))) @@ -711,7 +692,6 @@ readfile( close(fd); return FAIL; } -#endif #ifdef UNIX /* Set swap file protection bits after creating it. */ if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL @@ -764,7 +744,6 @@ readfile( try_dos = (vim_strchr(p_ffs, 'd') != NULL); try_unix = (vim_strchr(p_ffs, 'x') != NULL); -#ifdef FEAT_AUTOCMD if (!read_buffer) { int m = msg_scroll; @@ -834,7 +813,6 @@ readfile( return FAIL; } } -#endif /* FEAT_AUTOCMD */ /* Autocommands may add lines to the file, need to check if it is empty */ wasempty = (curbuf->b_ml.ml_flags & ML_EMPTY); @@ -2704,7 +2682,6 @@ failed: } #endif -#ifdef FEAT_AUTOCMD if (!read_stdin && !read_fifo && (!read_buffer || sfname != NULL)) { int m = msg_scroll; @@ -2746,7 +2723,6 @@ failed: return FAIL; # endif } -#endif if (recoverymode && error) return FAIL; @@ -3197,9 +3173,7 @@ buf_write( #endif /* writing everything */ int whole = (start == 1 && end == buf->b_ml.ml_line_count); -#ifdef FEAT_AUTOCMD linenr_T old_line_count = buf->b_ml.ml_line_count; -#endif int attr; int fileformat; int write_bin; @@ -3319,7 +3293,6 @@ buf_write( buf->b_op_end.lnum = end; buf->b_op_end.col = 0; -#ifdef FEAT_AUTOCMD { aco_save_T aco; int buf_ffname = FALSE; @@ -3509,7 +3482,6 @@ buf_write( if (buf_fname_s) fname = buf->b_sfname; } -#endif #ifdef FEAT_NETBEANS_INTG if (netbeans_active() && isNetbeansBuffer(buf)) @@ -5020,12 +4992,10 @@ restore_backup: ) { unchanged(buf, TRUE); -#ifdef FEAT_AUTOCMD /* b:changedtick is always incremented in unchanged() but that * should not trigger a TextChanged event. */ if (buf->b_last_changedtick + 1 == CHANGEDTICK(buf)) buf->b_last_changedtick = CHANGEDTICK(buf); -#endif u_unchanged(buf); u_update_save_nr(buf); } @@ -5194,7 +5164,6 @@ nofail: } #endif -#ifdef FEAT_AUTOCMD #ifdef FEAT_EVAL if (!should_abort(retval)) #else @@ -5232,7 +5201,6 @@ nofail: retval = FALSE; #endif } -#endif got_int |= prev_got_int; @@ -5246,37 +5214,34 @@ nofail: static int set_rw_fname(char_u *fname, char_u *sfname) { -#ifdef FEAT_AUTOCMD buf_T *buf = curbuf; /* It's like the unnamed buffer is deleted.... */ if (curbuf->b_p_bl) apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf); -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return FAIL; -# endif +#endif if (curbuf != buf) { /* We are in another buffer now, don't do the renaming. */ EMSG(_(e_auchangedbuf)); return FAIL; } -#endif if (setfname(curbuf, fname, sfname, FALSE) == OK) curbuf->b_flags |= BF_NOTEDITED; -#ifdef FEAT_AUTOCMD /* ....and a new named one is created */ apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, curbuf); if (curbuf->b_p_bl) apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf); -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ return FAIL; -# endif +#endif /* Do filetype detection now if 'filetype' is empty. */ if (*curbuf->b_p_ft == NUL) @@ -5285,7 +5250,6 @@ set_rw_fname(char_u *fname, char_u *sfname) (void)do_doautocmd((char_u *)"filetypedetect BufRead", FALSE, NULL); do_modelines(0); } -#endif return OK; } @@ -6105,8 +6069,6 @@ make_bom(char_u *buf, char_u *name) } #endif -#if defined(FEAT_VIMINFO) || defined(FEAT_BROWSE) || \ - defined(FEAT_QUICKFIX) || defined(FEAT_AUTOCMD) || defined(PROTO) /* * Try to find a shortname by comparing the fullname with the current * directory. @@ -6130,7 +6092,6 @@ shorten_fname1(char_u *full_path) vim_free(dirname); return p; } -#endif /* * Try to find a shortname by comparing the fullname with the current @@ -6781,10 +6742,7 @@ check_timestamps( } if (!stuff_empty() || global_busy || !typebuf_typed() -#ifdef FEAT_AUTOCMD - || autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0 -#endif - ) + || autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0) need_check_timestamps = TRUE; /* check later */ else { @@ -6898,14 +6856,14 @@ buf_check_timestamp( #ifdef FEAT_GUI int save_mouse_correct = need_mouse_correct; #endif -#ifdef FEAT_AUTOCMD static int busy = FALSE; int n; +#ifdef FEAT_EVAL char_u *s; +#endif bufref_T bufref; set_bufref(&bufref, buf); -#endif /* If there is no file name, the buffer is not loaded, 'buftype' is * set, we are in the middle of a save or being called recursively: ignore @@ -6914,9 +6872,7 @@ buf_check_timestamp( || buf->b_ml.ml_mfp == NULL || *buf->b_p_bt != NUL || buf->b_saving -#ifdef FEAT_AUTOCMD || busy -#endif #ifdef FEAT_NETBEANS_INTG || isNetbeansBuffer(buf) #endif @@ -6977,17 +6933,16 @@ buf_check_timestamp( else reason = "time"; -#ifdef FEAT_AUTOCMD /* * Only give the warning if there are no FileChangedShell * autocommands. * Avoid being called recursively by setting "busy". */ busy = TRUE; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL set_vim_var_string(VV_FCS_REASON, (char_u *)reason, -1); set_vim_var_string(VV_FCS_CHOICE, (char_u *)"", -1); -# endif +#endif ++allbuf_lock; n = apply_autocmds(EVENT_FILECHANGEDSHELL, buf->b_fname, buf->b_fname, FALSE, buf); @@ -6997,18 +6952,17 @@ buf_check_timestamp( { if (!bufref_valid(&bufref)) EMSG(_("E246: FileChangedShell autocommand deleted buffer")); -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL s = get_vim_var_str(VV_FCS_CHOICE); if (STRCMP(s, "reload") == 0 && *reason != 'd') reload = TRUE; else if (STRCMP(s, "ask") == 0) n = FALSE; else -# endif +#endif return 2; } if (!n) -#endif { if (*reason == 'd') mesg = _("E211: File \"%s\" no longer available"); @@ -7100,9 +7054,7 @@ buf_check_timestamp( } else { -# ifdef FEAT_AUTOCMD if (!autocmd_busy) -# endif { msg_start(); msg_puts_attr(tbuf, HL_ATTR(HLF_E) + MSG_HIST); @@ -7114,9 +7066,9 @@ buf_check_timestamp( if (emsg_silent == 0) { out_flush(); -# ifdef FEAT_GUI +#ifdef FEAT_GUI if (!focus) -# endif +#endif /* give the user some time to think about it */ ui_delay(1000L, TRUE); @@ -7151,12 +7103,10 @@ buf_check_timestamp( #endif } -#ifdef FEAT_AUTOCMD /* Trigger FileChangedShell when the file was changed in any way. */ if (bufref_valid(&bufref) && retval != 0) (void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST, buf->b_fname, buf->b_fname, FALSE, buf); -#endif #ifdef FEAT_GUI /* restore this in case an autocommand has set it; it would break * 'mousefocus' */ @@ -7240,14 +7190,12 @@ buf_reload(buf_T *buf, int orig_mode) if (saved == OK) { curbuf->b_flags |= BF_CHECK_RO; /* check for RO again */ -#ifdef FEAT_AUTOCMD keep_filetype = TRUE; /* don't detect 'filetype' */ -#endif if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, &ea, flags) != OK) { -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!aborting()) #endif EMSG2(_("E321: Could not reload \"%s\""), buf->b_fname); @@ -7296,9 +7244,7 @@ buf_reload(buf_T *buf, int orig_mode) curwin->w_cursor = old_cursor; check_cursor(); update_topline(); -#ifdef FEAT_AUTOCMD keep_filetype = FALSE; -#endif #ifdef FEAT_FOLDING { win_T *wp; @@ -7672,12 +7618,8 @@ forward_slash(char_u *fname) /* * Code for automatic commands. - * - * Only included when "FEAT_AUTOCMD" has been defined. */ -#if defined(FEAT_AUTOCMD) || defined(PROTO) - /* * The autocommands are stored in a list for each event. * Autocommands for the same pattern, that are consecutive, are joined @@ -7914,9 +7856,7 @@ static int au_get_grouparg(char_u **argp); static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd, int forceit, int group); static int apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, int force, int group, buf_T *buf, exarg_T *eap); static void auto_next_pat(AutoPatCmd *apc, int stop_at_last); -#if defined(FEAT_AUTOCMD) || defined(FEAT_WILDIGN) static int match_file_pat(char_u *pattern, regprog_T **prog, char_u *fname, char_u *sfname, char_u *tail, int allow_dirs); -#endif static event_T last_event; @@ -9014,7 +8954,6 @@ check_nomodeline(char_u **argp) * Search for a visible window containing the current buffer. If there isn't * one then use "aucmd_win". * Set "curbuf" and "curwin" to match "buf". - * When FEAT_AUTOCMD is not defined another version is used, see below. */ void aucmd_prepbuf( @@ -9067,7 +9006,9 @@ aucmd_prepbuf( aco->use_aucmd_win = TRUE; aucmd_win_used = TRUE; aucmd_win->w_buffer = buf; +#if defined(FEAT_SYN_HL) || defined(FEAT_SPELL) aucmd_win->w_s = &buf->b_s; +#endif ++buf->b_nwindows; win_init_empty(aucmd_win); /* set cursor and topline to safe values */ @@ -9108,7 +9049,6 @@ aucmd_prepbuf( /* * 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( @@ -9406,13 +9346,13 @@ has_textyankpost(void) static int apply_autocmds_group( event_T event, - char_u *fname, /* NULL or empty means use actual file name */ - char_u *fname_io, /* fname to use for <afile> on cmdline, NULL means + char_u *fname, /* NULL or empty means use actual file name */ + char_u *fname_io, /* fname to use for <afile> on cmdline, NULL means use fname */ - int force, /* when TRUE, ignore autocmd_busy */ - int group, /* group ID, or AUGROUP_ALL */ - buf_T *buf, /* buffer for <abuf> */ - exarg_T *eap) /* command arguments */ + int force, /* when TRUE, ignore autocmd_busy */ + int group, /* group ID, or AUGROUP_ALL */ + buf_T *buf, /* buffer for <abuf> */ + exarg_T *eap UNUSED) /* command arguments */ { char_u *sfname = NULL; /* short file name */ char_u *tail; @@ -10210,43 +10150,7 @@ 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_save_T *aco, /* structure to save values in */ - buf_T *buf) /* new curbuf */ -{ - aco->save_curbuf = curbuf; - --curbuf->b_nwindows; - curbuf = buf; - curwin->w_buffer = buf; - ++curbuf->b_nwindows; -} - -/* - * Restore after executing commands for a (hidden) buffer. - * This is the non-autocommand version. - */ - void -aucmd_restbuf( - aco_save_T *aco) /* structure holding saved values */ -{ - --curbuf->b_nwindows; - curbuf = aco->save_curbuf; - curwin->w_buffer = curbuf; - ++curbuf->b_nwindows; -} - -#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 * precompiled regprog "prog" ("pattern" is NULL). That avoids calling @@ -10292,7 +10196,6 @@ match_file_pat( vim_regfree(regmatch.regprog); return result; } -#endif #if defined(FEAT_WILDIGN) || defined(PROTO) /* diff --git a/src/getchar.c b/src/getchar.c index 7025f6733..285d5d5d0 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -516,7 +516,6 @@ CancelRedo(void) } } -#if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) /* * Save redobuff and old_redobuff to save_redobuff and save_old_redobuff. * Used before executing autocommands and user functions. @@ -552,7 +551,6 @@ restoreRedobuff(save_redo_T *save_redo) free_buff(&old_redobuff); old_redobuff = save_redo->sr_old_redobuff; } -#endif /* * Append "s" to the redo buffer. @@ -2891,7 +2889,7 @@ vgetorpeek(int advance) + typebuf.tb_len] != NUL) typebuf.tb_noremap[typebuf.tb_off + typebuf.tb_len++] = RM_YES; -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD /* Get IM status right after getting keys, not after the * timeout for a mapping (focus may be lost by then). */ vgetc_im_active = im_get_status(); @@ -3122,10 +3120,8 @@ fix_input_buffer(char_u *buf, int len) else #endif if (p[0] == NUL || (p[0] == K_SPECIAL -#ifdef FEAT_AUTOCMD /* timeout may generate K_CURSORHOLD */ && (i < 2 || p[1] != KS_EXTRA || p[2] != (int)KE_CURSORHOLD) -#endif #if defined(WIN3264) && !defined(FEAT_GUI) /* Win32 console passes modifiers */ && (i < 2 || p[1] != KS_MODIFIER) diff --git a/src/globals.h b/src/globals.h index 225e78a65..c62e96a2c 100644 --- a/src/globals.h +++ b/src/globals.h @@ -385,7 +385,6 @@ EXTERN guicolor_T cterm_normal_bg_gui_color INIT(= INVALCOLOR); EXTERN int is_mac_terminal INIT(= FALSE); /* recognized Terminal.app */ #endif -#ifdef FEAT_AUTOCMD EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */ EXTERN int autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */ EXTERN int autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */ @@ -405,7 +404,6 @@ EXTERN bufref_T au_new_curbuf INIT(= {NULL COMMA 0 COMMA 0}); * Free the buffer/window when autocmd_busy is being set to FALSE. */ EXTERN buf_T *au_pending_free_buf INIT(= NULL); EXTERN win_T *au_pending_free_win INIT(= NULL); -#endif #ifdef FEAT_MOUSE /* @@ -572,10 +570,8 @@ EXTERN win_T *prevwin INIT(= NULL); /* previous window */ EXTERN win_T *curwin; /* currently active window */ -#ifdef FEAT_AUTOCMD EXTERN win_T *aucmd_win; /* window used in aucmd_prepbuf() */ EXTERN int aucmd_win_used INIT(= FALSE); /* aucmd_win is being used */ -#endif /* * The window layout is kept in a tree of frames. topframe points to the top @@ -639,6 +635,7 @@ EXTERN int exiting INIT(= FALSE); EXTERN int really_exiting INIT(= FALSE); /* TRUE when we are sure to exit, e.g., after * a deadly signal */ +EXTERN int v_dying INIT(= 0); /* internal value of v:dying */ EXTERN int stdout_isatty INIT(= TRUE); /* is stdout a terminal? */ #if defined(FEAT_AUTOCHDIR) @@ -664,7 +661,6 @@ EXTERN int textlock INIT(= 0); /* non-zero when changing text and jumping to * another window or buffer is not allowed */ -#ifdef FEAT_AUTOCMD EXTERN int curbuf_lock INIT(= 0); /* non-zero when the current buffer can't be * changed. Used for FileChangedRO. */ @@ -673,7 +669,6 @@ EXTERN int allbuf_lock INIT(= 0); * changed, no buffer can be deleted and * current directory can't be changed. * Used for SwapExists et al. */ -#endif #ifdef FEAT_EVAL # define HAVE_SANDBOX EXTERN int sandbox INIT(= 0); @@ -986,15 +981,12 @@ EXTERN int emsg_silent INIT(= 0); /* don't print error messages */ EXTERN int emsg_noredir INIT(= 0); /* don't redirect error messages */ EXTERN int cmd_silent INIT(= FALSE); /* don't echo the command line */ -#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) \ - || defined(FEAT_AUTOCMD) # define HAS_SWAP_EXISTS_ACTION EXTERN int swap_exists_action INIT(= SEA_NONE); /* For dialog when swap file already * exists. */ EXTERN int swap_exists_did_quit INIT(= FALSE); /* Selected "quit" at the dialog. */ -#endif EXTERN char_u *IObuff; /* sprintf's are done in this buffer, size is IOSIZE */ @@ -1022,7 +1014,7 @@ EXTERN int stop_insert_mode; /* for ":stopinsert" and 'insertmode' */ EXTERN int KeyTyped; /* TRUE if user typed current char */ EXTERN int KeyStuffed; /* TRUE if current char from stuffbuf */ -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD EXTERN int vgetc_im_active; /* Input Method was active for last character obtained from vgetc() */ #endif @@ -1075,7 +1067,6 @@ EXTERN char_u *repeat_cmdline INIT(= NULL); /* command line for "." */ #ifdef FEAT_CMDHIST EXTERN char_u *new_last_cmdline INIT(= NULL); /* new value for last_cmdline */ #endif -#ifdef FEAT_AUTOCMD EXTERN char_u *autocmd_fname INIT(= NULL); /* fname for <afile> on cmdline */ EXTERN int autocmd_fname_full; /* autocmd_fname is full path */ EXTERN int autocmd_bufnr INIT(= 0); /* fnum for <abuf> on cmdline */ @@ -1086,7 +1077,6 @@ EXTERN pos_T last_cursormoved /* for CursorMoved event */ = INIT_POS_T(0, 0, 0) # endif ; -#endif EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */ EXTERN int postponed_split_flags INIT(= 0); /* args for win_split() */ @@ -1595,9 +1585,7 @@ EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set")); EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name")); #endif EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); -#ifdef FEAT_AUTOCMD EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior")); -#endif #ifdef FEAT_GUI_MAC EXTERN short disallow_gui INIT(= FALSE); @@ -132,13 +132,11 @@ gui_start(void) vim_free(old_term); -#ifdef FEAT_AUTOCMD /* If the GUI started successfully, trigger the GUIEnter event, otherwise * the GUIFailed event. */ gui_mch_update(); apply_autocmds(gui.in_use ? EVENT_GUIENTER : EVENT_GUIFAILED, NULL, NULL, FALSE, curbuf); -#endif --recursive; } @@ -2954,7 +2952,7 @@ gui_wait_for_chars_or_timer(long wtime) gui_wait_for_chars(long wtime, int tb_change_cnt) { int retval; -#if defined(ELAPSED_FUNC) && defined(FEAT_AUTOCMD) +#if defined(ELAPSED_FUNC) ELAPSED_TYPE start_tv; #endif @@ -2986,7 +2984,7 @@ gui_wait_for_chars(long wtime, int tb_change_cnt) return retval; } -#if defined(ELAPSED_FUNC) && defined(FEAT_AUTOCMD) +#if defined(ELAPSED_FUNC) ELAPSED_INIT(start_tv); #endif @@ -3003,11 +3001,10 @@ gui_wait_for_chars(long wtime, int tb_change_cnt) */ if (gui_wait_for_chars_or_timer(p_ut) == OK) retval = OK; -#ifdef FEAT_AUTOCMD else if (trigger_cursorhold() -# ifdef ELAPSED_FUNC +#ifdef ELAPSED_FUNC && ELAPSED_FUNC(start_tv) >= p_ut -# endif +#endif && typebuf.tb_change_cnt == tb_change_cnt) { char_u buf[3]; @@ -3020,7 +3017,6 @@ gui_wait_for_chars(long wtime, int tb_change_cnt) retval = OK; } -#endif if (retval == FAIL && typebuf.tb_change_cnt == tb_change_cnt) { @@ -5131,34 +5127,24 @@ no_console_input(void) void gui_update_screen(void) { -#ifdef FEAT_CONCEAL +# ifdef FEAT_CONCEAL linenr_T conceal_old_cursor_line = 0; linenr_T conceal_new_cursor_line = 0; int conceal_update_lines = FALSE; -#endif +# endif update_topline(); validate_cursor(); -#if defined(FEAT_AUTOCMD) || defined(FEAT_CONCEAL) /* Trigger CursorMoved if the cursor moved. */ - if (!finish_op && ( -# ifdef FEAT_AUTOCMD - has_cursormoved() -# endif -# if defined(FEAT_AUTOCMD) && defined(FEAT_CONCEAL) - || -# endif + if (!finish_op && (has_cursormoved() # ifdef FEAT_CONCEAL - curwin->w_p_cole > 0 + || curwin->w_p_cole > 0 # endif - ) - && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) + ) && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) { -# ifdef FEAT_AUTOCMD if (has_cursormoved()) apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf); -# endif # ifdef FEAT_CONCEAL if (curwin->w_p_cole > 0) { @@ -5169,11 +5155,10 @@ gui_update_screen(void) # endif last_cursormoved = curwin->w_cursor; } -#endif update_screen(0); /* may need to update the screen */ setcursor(); -# if defined(FEAT_CONCEAL) +# ifdef FEAT_CONCEAL if (conceal_update_lines && (conceal_old_cursor_line != conceal_new_cursor_line || conceal_cursor_line(curwin) diff --git a/src/gui_mac.c b/src/gui_mac.c index 6386b639a..1677d6eab 100644 --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -6232,7 +6232,7 @@ char_u *FullPathFromFSSpec_save(FSSpec file) #endif } -#if (defined(FEAT_MBYTE) || defined(PROTO)) && defined(USE_CARBONKEYHANDLER) +#if (defined(FEAT_MBYTE) && defined(USE_CARBONKEYHANDLER)) || defined(PROTO) /* * Input Method Control functions. */ diff --git a/src/if_cscope.c b/src/if_cscope.c index e4bcb51e0..986663d95 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -1147,17 +1147,15 @@ cs_find_common( return FALSE; } -# ifdef FEAT_AUTOCMD if (*qfpos != '0' && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)"cscope", curbuf->b_fname, TRUE, curbuf)) { -# ifdef FEAT_EVAL +# ifdef FEAT_EVAL if (aborting()) return FALSE; -# endif - } # endif + } } #endif @@ -1251,10 +1249,8 @@ cs_find_common( postponed_split = 0; } -# ifdef FEAT_AUTOCMD apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)"cscope", curbuf->b_fname, TRUE, curbuf); -# endif if (use_ll) /* * In the location list window, use the displayed location diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c index af2e672cb..e911fe508 100644 --- a/src/if_xcmdsrv.c +++ b/src/if_xcmdsrv.c @@ -1480,14 +1480,12 @@ server_parse_message( ga_concat(&(r->strings), str); ga_append(&(r->strings), NUL); } -#ifdef FEAT_AUTOCMD { char_u winstr[30]; sprintf((char *)winstr, "0x%x", (unsigned int)win); apply_autocmds(EVENT_REMOTEREPLY, winstr, str, TRUE, curbuf); } -#endif vim_free(tofree); } else diff --git a/src/main.c b/src/main.c index 793d54942..406635a16 100644 --- a/src/main.c +++ b/src/main.c @@ -748,10 +748,8 @@ vim_main2(void) if (exmode_active) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); TIME_MSG("BufEnter autocommands"); -#endif setpcmark(); #ifdef FEAT_QUICKFIX @@ -843,10 +841,8 @@ vim_main2(void) #ifdef FEAT_EVAL set_vim_var_nr(VV_VIM_DID_ENTER, 1L); #endif -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf); TIME_MSG("VimEnter autocommands"); -#endif #if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD) /* Adjust default register name for "unnamed" in 'clipboard'. Can only be @@ -1162,50 +1158,33 @@ main_loop( skip_redraw = FALSE; else if (do_redraw || stuff_empty()) { -# ifdef FEAT_GUI +#ifdef FEAT_GUI /* If ui_breakcheck() was used a resize may have been postponed. */ gui_may_resize_shell(); -# endif -#if defined(FEAT_AUTOCMD) || defined(FEAT_CONCEAL) +#endif /* Trigger CursorMoved if the cursor moved. */ if (!finish_op && ( -# ifdef FEAT_AUTOCMD has_cursormoved() -# endif -# if defined(FEAT_AUTOCMD) && defined(FEAT_CONCEAL) - || -# endif -# ifdef FEAT_CONCEAL - curwin->w_p_cole > 0 -# endif +#ifdef FEAT_CONCEAL + || curwin->w_p_cole > 0 +#endif ) -# ifdef FEAT_AUTOCMD - && !EQUAL_POS(last_cursormoved, curwin->w_cursor) -# endif - ) + && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) { -# ifdef FEAT_AUTOCMD if (has_cursormoved()) apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf); -# endif # ifdef FEAT_CONCEAL if (curwin->w_p_cole > 0) { -# ifdef FEAT_AUTOCMD conceal_old_cursor_line = last_cursormoved.lnum; -# endif conceal_new_cursor_line = curwin->w_cursor.lnum; conceal_update_lines = TRUE; } # endif -# ifdef FEAT_AUTOCMD last_cursormoved = curwin->w_cursor; -# endif } -#endif -#ifdef FEAT_AUTOCMD /* Trigger TextChanged if b:changedtick differs. */ if (!finish_op && has_textchanged() && curbuf->b_last_changedtick != CHANGEDTICK(curbuf)) @@ -1213,7 +1192,6 @@ main_loop( apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL, FALSE, curbuf); curbuf->b_last_changedtick = CHANGEDTICK(curbuf); } -#endif #if defined(FEAT_DIFF) && defined(FEAT_SCROLLBIND) /* Scroll-binding for diff mode may have been postponed until @@ -1292,7 +1270,7 @@ main_loop( may_clear_sb_text(); /* clear scroll-back text on next msg */ showruler(FALSE); -# if defined(FEAT_CONCEAL) +#if defined(FEAT_CONCEAL) if (conceal_update_lines && (conceal_old_cursor_line != conceal_new_cursor_line || conceal_cursor_line(curwin) @@ -1307,7 +1285,7 @@ main_loop( mch_enable_flush(); curwin->w_valid &= ~VALID_CROW; } -# endif +#endif setcursor(); cursor_on(); @@ -1405,11 +1383,10 @@ getout_preserve_modified(int exitval) void getout(int exitval) { -#ifdef FEAT_AUTOCMD + tabpage_T *tp; + tabpage_T *next_tp; buf_T *buf; win_T *wp; - tabpage_T *tp, *next_tp; -#endif exiting = TRUE; @@ -1434,8 +1411,7 @@ getout(int exitval) msg_didany = FALSE; #endif -#ifdef FEAT_AUTOCMD - if (get_vim_var_nr(VV_DYING) <= 1) + if (v_dying <= 1) { /* Trigger BufWinLeave for all windows, but only once per buffer. */ for (tp = first_tabpage; tp != NULL; tp = next_tp) @@ -1479,7 +1455,6 @@ getout(int exitval) } apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); } -#endif #ifdef FEAT_VIMINFO if (*p_viminfo != NUL) @@ -1487,10 +1462,8 @@ getout(int exitval) write_viminfo(NULL, FALSE); #endif -#ifdef FEAT_AUTOCMD - if (get_vim_var_nr(VV_DYING) <= 1) + if (v_dying <= 1) apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf); -#endif #ifdef FEAT_PROFILE profile_dump(); @@ -1507,13 +1480,11 @@ getout(int exitval) wait_return(FALSE); } -#ifdef FEAT_AUTOCMD /* Position the cursor again, the autocommands may have moved it */ -# ifdef FEAT_GUI +#ifdef FEAT_GUI if (!gui.in_use) -# endif - windgoto((int)Rows - 1, 0); #endif + windgoto((int)Rows - 1, 0); #ifdef FEAT_JOB_CHANNEL job_stop_on_exit(); @@ -2701,13 +2672,11 @@ create_windows(mparm_T *parmp UNUSED) * Commands in the .vimrc might have loaded a file or split the window. * Watch out for autocommands that delete a window. */ -#ifdef FEAT_AUTOCMD /* * Don't execute Win/Buf Enter/Leave autocommands here */ ++autocmd_no_enter; ++autocmd_no_leave; -#endif dorewind = TRUE; while (done++ < 1000) { @@ -2767,9 +2736,7 @@ create_windows(mparm_T *parmp UNUSED) else handle_swap_exists(NULL); #endif -#ifdef FEAT_AUTOCMD dorewind = TRUE; /* start again */ -#endif } ui_breakcheck(); if (got_int) @@ -2783,10 +2750,8 @@ create_windows(mparm_T *parmp UNUSED) else curwin = firstwin; curbuf = curwin->w_buffer; -#ifdef FEAT_AUTOCMD --autocmd_no_enter; --autocmd_no_leave; -#endif } } @@ -2804,13 +2769,11 @@ edit_buffers( int advance = TRUE; win_T *win; -# ifdef FEAT_AUTOCMD /* * Don't execute Win/Buf Enter/Leave autocommands here */ ++autocmd_no_enter; ++autocmd_no_leave; -# endif /* When w_arg_idx is -1 remove the window (see create_windows()). */ if (curwin->w_arg_idx == -1) @@ -2891,9 +2854,7 @@ edit_buffers( if (parmp->window_layout == WIN_TABS) goto_tabpage(1); -# ifdef FEAT_AUTOCMD --autocmd_no_enter; -# endif /* make the first window the current window */ win = firstwin; @@ -2911,9 +2872,7 @@ edit_buffers( #endif win_enter(win, FALSE); -#ifdef FEAT_AUTOCMD --autocmd_no_leave; -#endif TIME_MSG("editing files in windows"); if (parmp->window_count > 1 && parmp->window_layout != WIN_TABS) win_equal(curwin, FALSE, 'b'); /* adjust heights */ diff --git a/src/mbyte.c b/src/mbyte.c index 9b788b0d5..cb2d2d93e 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -799,11 +799,9 @@ codepage_invalid: fix_arg_enc(); #endif -#ifdef FEAT_AUTOCMD /* Fire an autocommand to let people do custom font setup. This must be * after Vim has been setup for the new encoding. */ apply_autocmds(EVENT_ENCODINGCHANGED, NULL, (char_u *)"", FALSE, curbuf); -#endif #ifdef FEAT_SPELL /* Need to reload spell dictionaries */ @@ -4792,7 +4790,8 @@ iconv_end(void) # define USE_IMSTATUSFUNC (*p_imsf != NUL) #endif -#if defined(FEAT_EVAL) && defined(FEAT_MBYTE) +#if defined(FEAT_EVAL) && defined(FEAT_MBYTE) \ + && (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM)) static void call_imactivatefunc(int active) { @@ -4811,11 +4810,7 @@ call_imstatusfunc(void) int is_active; /* FIXME: Don't execute user function in unsafe situation. */ - if (exiting -# ifdef FEAT_AUTOCMD - || is_autocmd_blocked() -# endif - ) + if (exiting || is_autocmd_blocked()) return FALSE; /* FIXME: :py print 'xxx' is shown duplicate result. * Use silent to avoid it. */ @@ -5698,11 +5693,11 @@ im_synthesize_keypress(unsigned int keyval, unsigned int state) void xim_reset(void) { -#ifdef FEAT_EVAL +# ifdef FEAT_EVAL if (USE_IMACTIVATEFUNC) call_imactivatefunc(im_is_active); else -#endif +# endif if (xic != NULL) { gtk_im_context_reset(xic); @@ -6482,11 +6477,11 @@ xim_get_status_area_height(void) #else /* !defined(FEAT_XIM) */ -# if !defined(FEAT_GUI_W32) || !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)) +# ifdef IME_WITHOUT_XIM static int im_was_set_active = FALSE; int -im_get_status() +im_get_status(void) { # if defined(FEAT_MBYTE) && defined(FEAT_EVAL) if (USE_IMSTATUSFUNC) diff --git a/src/memline.c b/src/memline.c index 7ea94ab8b..5ecb32c10 100644 --- a/src/memline.c +++ b/src/memline.c @@ -1732,13 +1732,11 @@ theend: } if (serious_error && called_from_main) ml_close(curbuf, TRUE); -#ifdef FEAT_AUTOCMD else { apply_autocmds(EVENT_BUFREADPOST, NULL, curbuf->b_fname, FALSE, curbuf); apply_autocmds(EVENT_BUFWINENTER, NULL, curbuf->b_fname, FALSE, curbuf); } -#endif return; } @@ -4071,7 +4069,7 @@ attention_message( --no_wait_return; } -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) static int do_swapexists(buf_T *buf, char_u *fname); /* @@ -4450,7 +4448,7 @@ findswapname( #if (defined(UNIX) || defined(VMS)) && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)) process_still_running = FALSE; #endif -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) /* * If there is an SwapExists autocommand and we can handle * the response, trigger it. It may return 0 to ask the diff --git a/src/menu.c b/src/menu.c index e453135ae..107cabce6 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1907,7 +1907,6 @@ show_popupmenu(void) return; mode = menu_mode_chars[mode]; -# ifdef FEAT_AUTOCMD { char_u ename[2]; @@ -1915,7 +1914,6 @@ show_popupmenu(void) ename[1] = NUL; apply_autocmds(EVENT_MENUPOPUP, ename, NULL, FALSE, curbuf); } -# endif for (menu = root_menu; menu != NULL; menu = menu->next) if (STRNCMP("PopUp", menu->name, 5) == 0 && menu->name[5] == mode) diff --git a/src/misc1.c b/src/misc1.c index 32e3c17ae..135293dd2 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -3183,12 +3183,10 @@ changed_common( if (must_redraw < VALID) must_redraw = VALID; -#ifdef FEAT_AUTOCMD /* when the cursor line is changed always trigger CursorMoved */ if (lnum <= curwin->w_cursor.lnum && lnume + (xtra < 0 ? -xtra : xtra) > curwin->w_cursor.lnum) last_cursormoved.lnum = 0; -#endif } /* @@ -3252,18 +3250,14 @@ change_warning( if (curbuf->b_did_warn == FALSE && curbufIsChanged() == 0 -#ifdef FEAT_AUTOCMD && !autocmd_busy -#endif && curbuf->b_p_ro) { -#ifdef FEAT_AUTOCMD ++curbuf_lock; apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf); --curbuf_lock; if (!curbuf->b_p_ro) return; -#endif /* * Do what msg() does, but with a column offset if the warning should * be after the mode message. diff --git a/src/misc2.c b/src/misc2.c index 1c705932d..d1484f01f 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -1099,10 +1099,8 @@ free_all_mem(void) return; entered_free_all_mem = TRUE; -# ifdef FEAT_AUTOCMD /* Don't want to trigger autocommands from here on. */ block_autocmds(); -# endif /* Close all tabs and windows. Reset 'equalalways' to avoid redraws. */ p_ea = FALSE; @@ -1157,9 +1155,7 @@ free_all_mem(void) # endif /* Obviously named calls. */ -# if defined(FEAT_AUTOCMD) free_all_autocmds(); -# endif clear_termcodes(); free_all_marks(); alist_clear(&global_alist); @@ -3403,11 +3399,9 @@ vim_chdirfile(char_u *fname, char *trigger_autocmd UNUSED) vim_strncpy(dir, fname, MAXPATHL - 1); *gettail_sep(dir) = NUL; res = mch_chdir((char *)dir) == 0 ? OK : FAIL; -#ifdef FEAT_AUTOCMD if (res == OK && trigger_autocmd != NULL) apply_autocmds(EVENT_DIRCHANGED, (char_u *)trigger_autocmd, dir, FALSE, curbuf); -#endif return res; } #endif diff --git a/src/move.c b/src/move.c index 4e5618d7b..45f7be4ed 100644 --- a/src/move.c +++ b/src/move.c @@ -538,9 +538,7 @@ set_topline(win_T *wp, linenr_T lnum) /* Approximate the value of w_botline */ wp->w_botline += lnum - wp->w_topline; wp->w_topline = lnum; -#ifdef FEAT_AUTOCMD wp->w_topline_was_set = TRUE; -#endif #ifdef FEAT_DIFF wp->w_topfill = 0; #endif diff --git a/src/netbeans.c b/src/netbeans.c index bc3b8e680..a753a4f97 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -1581,9 +1581,7 @@ nb_do_cmd( do_update = 1; buf->initDone = TRUE; nb_set_curbuf(buf->bufp); -#if defined(FEAT_AUTOCMD) apply_autocmds(EVENT_BUFREADPOST, 0, 0, FALSE, buf->bufp); -#endif /* handle any postponed key commands */ handle_key_queue(); @@ -2160,17 +2158,13 @@ nb_do_cmd( #endif ) { -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, buf->bufp); -#endif buf_write_all(buf->bufp, FALSE); -#ifdef FEAT_AUTOCMD /* an autocommand may have deleted the buffer */ if (!bufref_valid(&bufref)) buf->bufp = NULL; -#endif } } else diff --git a/src/normal.c b/src/normal.c index cea8c9f16..5aa7fe049 100644 --- a/src/normal.c +++ b/src/normal.c @@ -169,9 +169,7 @@ static void nv_nbcmd(cmdarg_T *cap); #ifdef FEAT_DND static void nv_drop(cmdarg_T *cap); #endif -#ifdef FEAT_AUTOCMD static void nv_cursorhold(cmdarg_T *cap); -#endif static void get_op_vcol(oparg_T *oap, colnr_T col, int initial); static char *e_noident = N_("E349: No identifier under cursor"); @@ -424,9 +422,7 @@ static const struct nv_cmd #ifdef FEAT_DND {K_DROP, nv_drop, NV_STS, 0}, #endif -#ifdef FEAT_AUTOCMD {K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0}, -#endif {K_PS, nv_edit, 0, 0}, }; @@ -595,7 +591,6 @@ normal_cmd( #endif } -#ifdef FEAT_AUTOCMD /* Restore counts from before receiving K_CURSORHOLD. This means after * typing "3", handling K_CURSORHOLD and then typing "2" we get "32", not * "3 * 2". */ @@ -606,7 +601,6 @@ normal_cmd( oap->prev_opcount = 0; oap->prev_count0 = 0; } -#endif mapped_len = typebuf_maplen(); @@ -737,7 +731,6 @@ getcount: } } -#ifdef FEAT_AUTOCMD if (c == K_CURSORHOLD) { /* Save the count values so that ca.opcount and ca.count0 are exactly @@ -745,9 +738,7 @@ getcount: oap->prev_opcount = ca.opcount; oap->prev_count0 = ca.count0; } - else -#endif - if (ca.opcount != 0) + else if (ca.opcount != 0) { /* * If we're in the middle of an operator (including after entering a @@ -808,10 +799,8 @@ getcount: text_locked_msg(); goto normal_end; } -#ifdef FEAT_AUTOCMD if ((nv_cmds[idx].cmd_flags & NV_NCW) && curbuf_locked()) goto normal_end; -#endif /* * In Visual/Select mode, a few keys are handled in a special way. @@ -892,17 +881,15 @@ getcount: int lit = FALSE; /* get extra character literally */ int langmap_active = FALSE; /* using :lmap mappings */ int lang; /* getting a text character */ -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD int save_smd; /* saved value of p_smd */ #endif ++no_mapping; ++allow_keys; /* no mapping for nchar, but allow key codes */ -#ifdef FEAT_AUTOCMD /* Don't generate a CursorHold event here, most commands can't handle * it, e.g., nv_replace(), nv_csearch(). */ did_cursorhold = TRUE; -#endif if (ca.cmdchar == 'g') { /* @@ -957,7 +944,7 @@ getcount: State = LANGMAP; langmap_active = TRUE; } -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD save_smd = p_smd; p_smd = FALSE; /* Don't let the IM code show the mode here */ if (lang && curbuf->b_p_iminsert == B_IMODE_IM) @@ -973,7 +960,7 @@ getcount: ++allow_keys; State = NORMAL_BUSY; } -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD if (lang) { if (curbuf->b_p_iminsert != B_IMODE_LMAP) @@ -1102,10 +1089,8 @@ getcount: if (need_flushbuf) out_flush(); #endif -#ifdef FEAT_AUTOCMD if (ca.cmdchar != K_IGNORE) did_cursorhold = FALSE; -#endif State = NORMAL; @@ -1278,10 +1263,7 @@ normal_end: #ifdef FEAT_CMDL_INFO if (oap->op_type == OP_NOP && oap->regname == 0 -# ifdef FEAT_AUTOCMD - && ca.cmdchar != K_CURSORHOLD -# endif - ) + && ca.cmdchar != K_CURSORHOLD) clear_showcmd(); #endif @@ -6264,13 +6246,11 @@ nv_gotofile(cmdarg_T *cap) text_locked_msg(); return; } -#ifdef FEAT_AUTOCMD if (curbuf_locked()) { clearop(cap->oap); return; } -#endif ptr = grab_file_name(cap->count1, &lnum); @@ -9597,7 +9577,6 @@ nv_drop(cmdarg_T *cap UNUSED) } #endif -#ifdef FEAT_AUTOCMD /* * Trigger CursorHold event. * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the @@ -9610,7 +9589,6 @@ nv_cursorhold(cmdarg_T *cap) did_cursorhold = TRUE; cap->retval |= CA_COMMAND_BUSY; /* don't call edit() now */ } -#endif /* * Calculate start/end virtual columns for operating in block mode. @@ -1651,7 +1651,7 @@ shift_delete_registers() y_regs[1].y_array = NULL; /* set register one to empty */ } -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) static void yank_do_autocmd(oparg_T *oap, yankreg_T *reg) { @@ -1866,7 +1866,7 @@ op_delete(oparg_T *oap) } } -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) if (did_yank && has_textyankpost()) yank_do_autocmd(oap, y_current); #endif @@ -3350,7 +3350,7 @@ op_yank(oparg_T *oap, int deleting, int mess) # endif #endif -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) if (!deleting && has_textyankpost()) yank_do_autocmd(oap, y_current); #endif @@ -3493,11 +3493,9 @@ do_put( return; } -#ifdef FEAT_AUTOCMD /* Autocommands may be executed when saving lines for undo, which may make * y_array invalid. Start undo now to avoid that. */ u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1); -#endif if (insert_string != NULL) { diff --git a/src/option.c b/src/option.c index 1b5144709..6fb24c536 100644 --- a/src/option.c +++ b/src/option.c @@ -114,9 +114,7 @@ #define PV_FF OPT_BUF(BV_FF) #define PV_FLP OPT_BUF(BV_FLP) #define PV_FO OPT_BUF(BV_FO) -#ifdef FEAT_AUTOCMD -# define PV_FT OPT_BUF(BV_FT) -#endif +#define PV_FT OPT_BUF(BV_FT) #define PV_IMI OPT_BUF(BV_IMI) #define PV_IMS OPT_BUF(BV_IMS) #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) @@ -319,9 +317,7 @@ static char_u *p_fenc; static char_u *p_ff; static char_u *p_fo; static char_u *p_flp; -#ifdef FEAT_AUTOCMD static char_u *p_ft; -#endif static long p_iminsert; static long p_imsearch; #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) @@ -1125,11 +1121,7 @@ static struct vimoption options[] = (char_u *)&p_ek, PV_NONE, {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, -#ifdef FEAT_AUTOCMD (char_u *)&p_ei, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM, (char_u *)&p_et, PV_ET, @@ -1174,13 +1166,8 @@ static struct vimoption options[] = #endif (char_u *)0L} SCRIPTID_INIT}, {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, -#ifdef FEAT_AUTOCMD (char_u *)&p_ft, PV_FT, {(char_u *)"", (char_u *)0L} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)0L, (char_u *)0L} -#endif SCRIPTID_INIT}, {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP, (char_u *)&p_fcs, PV_NONE, @@ -3248,11 +3235,7 @@ static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL}; #endif static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL}; static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; -#ifdef FEAT_AUTOCMD static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL}; -#else -static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL}; -#endif static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; #ifdef FEAT_FOLDING @@ -4339,7 +4322,7 @@ set_title_defaults(void) } #endif -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) static void trigger_optionsset_string( int opt_idx, @@ -4830,7 +4813,7 @@ do_set( char_u *oldval = NULL; /* previous value if *varp */ char_u *newval; char_u *origval = NULL; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) char_u *saved_origval = NULL; char_u *saved_newval = NULL; #endif @@ -5184,7 +5167,7 @@ do_set( */ *(char_u **)(varp) = newval; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!starting # ifdef FEAT_CRYPT && options[opt_idx].indir != PV_KEY @@ -5207,7 +5190,7 @@ do_set( errmsg = did_set_string_option(opt_idx, (char_u **)varp, new_value_alloced, oldval, errbuf, opt_flags); -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (errmsg == NULL) trigger_optionsset_string(opt_idx, opt_flags, saved_origval, saved_newval); @@ -5726,9 +5709,7 @@ check_buf_options(buf_T *buf) check_string_option(&buf->b_p_cino); parse_cino(buf); #endif -#ifdef FEAT_AUTOCMD check_string_option(&buf->b_p_ft); -#endif #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) check_string_option(&buf->b_p_cinw); #endif @@ -5982,7 +5963,7 @@ set_string_option( char_u *s; char_u **varp; char_u *oldval; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) char_u *saved_oldval = NULL; char_u *saved_newval = NULL; #endif @@ -6002,7 +5983,7 @@ set_string_option( oldval = *varp; *varp = s; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!starting # ifdef FEAT_CRYPT && options[opt_idx].indir != PV_KEY @@ -6017,7 +5998,7 @@ set_string_option( opt_flags)) == NULL) did_set_option(opt_idx, opt_flags, TRUE); -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) /* call autocommand after handling side effects */ if (r == NULL) trigger_optionsset_string(opt_idx, opt_flags, @@ -6029,7 +6010,6 @@ set_string_option( return r; } -#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL) /* * Return TRUE if "val" is a valid 'filetype' name. * Also used for 'syntax' and 'keymap'. @@ -6044,7 +6024,6 @@ valid_filetype(char_u *val) return FALSE; return TRUE; } -#endif /* * Handle string options that need some action to perform when changed. @@ -6068,9 +6047,7 @@ did_set_string_option( /* set when changing an option that only requires a redraw in the GUI */ int redraw_gui_only = FALSE; #endif -#ifdef FEAT_AUTOCMD int ft_changed = FALSE; -#endif /* Get the global option to compare with, otherwise we would have to check * two values for all local options. */ @@ -6351,14 +6328,12 @@ did_set_string_option( } #endif -#ifdef FEAT_AUTOCMD /* 'eventignore' */ else if (varp == &p_ei) { if (check_ei() == FAIL) errmsg = e_invarg; } -#endif #ifdef FEAT_MBYTE /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */ @@ -7468,7 +7443,6 @@ did_set_string_option( } #endif -#ifdef FEAT_AUTOCMD else if (gvarp == &p_ft) { if (!valid_filetype(*varp)) @@ -7476,7 +7450,6 @@ did_set_string_option( else ft_changed = STRCMP(oldval, *varp) != 0; } -#endif #ifdef FEAT_SYN_HL else if (gvarp == &p_syn) @@ -7593,18 +7566,17 @@ did_set_string_option( else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) set_string_option_global(opt_idx, varp); -#ifdef FEAT_AUTOCMD /* * Trigger the autocommand only after setting the flags. */ -# ifdef FEAT_SYN_HL +#ifdef FEAT_SYN_HL /* When 'syntax' is set, load the syntax of that name */ if (varp == &(curbuf->b_p_syn)) { apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname, TRUE, curbuf); } -# endif +#endif else if (varp == &(curbuf->b_p_ft)) { /* 'filetype' is set, trigger the FileType autocommand. @@ -7620,7 +7592,6 @@ did_set_string_option( varp = NULL; } } -#endif #ifdef FEAT_SPELL if (varp == &(curwin->w_s->b_p_spl)) { @@ -8280,14 +8251,12 @@ set_bool_option( #endif } -#ifdef FEAT_AUTOCMD /* when 'buflisted' changes, trigger autocommands */ else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) { apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, NULL, NULL, TRUE, curbuf); } -#endif /* when 'swf' is set, create swapfile, when reset remove swapfile */ else if ((int *)varp == &curbuf->b_p_swf) @@ -8433,9 +8402,7 @@ set_bool_option( #ifdef FEAT_TITLE redraw_titles(); #endif -#ifdef FEAT_AUTOCMD modified_was_set = value; -#endif } #ifdef BACKSLASH_IN_FILENAME @@ -8529,7 +8496,7 @@ set_bool_option( } #endif -#ifdef FEAT_MBYTE +#ifdef HAVE_INPUT_METHOD /* 'imdisable' */ else if ((int *)varp == &p_imdisable) { @@ -8739,7 +8706,7 @@ set_bool_option( options[opt_idx].flags |= P_WAS_SET; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!starting) { char_u buf_old[2], buf_new[2], buf_type[7]; @@ -9289,7 +9256,7 @@ set_num_option( options[opt_idx].flags |= P_WAS_SET; -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) if (!starting && errmsg == NULL) { char_u buf_old[11], buf_new[11], buf_type[7]; @@ -10139,22 +10106,15 @@ makeset(FILE *fd, int opt_flags, int local_only) } else /* P_STRING */ { -#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) int do_endif = FALSE; /* Don't set 'syntax' and 'filetype' again if the value is * already right, avoids reloading the syntax file. */ if ( -# if defined(FEAT_SYN_HL) - p->indir == PV_SYN -# if defined(FEAT_AUTOCMD) - || -# endif -# endif -# if defined(FEAT_AUTOCMD) - p->indir == PV_FT -# endif - ) +#if defined(FEAT_SYN_HL) + p->indir == PV_SYN || +#endif + p->indir == PV_FT) { if (fprintf(fd, "if &%s != '%s'", p->fullname, *(char_u **)(varp)) < 0 @@ -10162,17 +10122,14 @@ makeset(FILE *fd, int opt_flags, int local_only) return FAIL; do_endif = TRUE; } -#endif if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, (p->flags & P_EXPAND) != 0) == FAIL) return FAIL; -#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) if (do_endif) { if (put_line(fd, "endif") == FAIL) return FAIL; } -#endif } } } @@ -10783,9 +10740,7 @@ get_varp(struct vimoption *p) case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); #endif case PV_FF: return (char_u *)&(curbuf->b_p_ff); -#ifdef FEAT_AUTOCMD case PV_FT: return (char_u *)&(curbuf->b_p_ft); -#endif case PV_FO: return (char_u *)&(curbuf->b_p_fo); case PV_FLP: return (char_u *)&(curbuf->b_p_flp); case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); @@ -11200,10 +11155,8 @@ buf_copy_options(buf_T *buf, int flags) buf->b_p_cink = vim_strsave(p_cink); buf->b_p_cino = vim_strsave(p_cino); #endif -#ifdef FEAT_AUTOCMD /* Don't copy 'filetype', it must be detected */ buf->b_p_ft = empty_option; -#endif buf->b_p_pi = p_pi; #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) buf->b_p_cinw = vim_strsave(p_cinw); diff --git a/src/option.h b/src/option.h index 5ced8fecd..a338ba672 100644 --- a/src/option.h +++ b/src/option.h @@ -477,9 +477,7 @@ EXTERN char_u *p_efm; /* 'errorformat' */ EXTERN char_u *p_gefm; /* 'grepformat' */ EXTERN char_u *p_gp; /* 'grepprg' */ #endif -#ifdef FEAT_AUTOCMD EXTERN char_u *p_ei; /* 'eventignore' */ -#endif EXTERN int p_ek; /* 'esckeys' */ EXTERN int p_exrc; /* 'exrc' */ #ifdef FEAT_MBYTE @@ -1046,9 +1044,7 @@ enum , BV_FF , BV_FLP , BV_FO -#ifdef FEAT_AUTOCMD , BV_FT -#endif , BV_IMI , BV_IMS #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) diff --git a/src/os_amiga.c b/src/os_amiga.c index a0fb5c084..39fb222fd 100644 --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -152,7 +152,6 @@ mch_inchar( */ if (WaitForChar(raw_in, p_ut * 1000L) == 0) { -#ifdef FEAT_AUTOCMD if (trigger_cursorhold() && maxlen >= 3) { buf[0] = K_SPECIAL; @@ -160,7 +159,6 @@ mch_inchar( buf[2] = (int)KE_CURSORHOLD; return 3; } -#endif before_blocking(); } } diff --git a/src/os_mswin.c b/src/os_mswin.c index a41b4c82b..e43d3a8b9 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -2163,7 +2163,6 @@ Messaging_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) (data->dwData == COPYDATA_RESULT ? 1 : 2))) == FAIL) vim_free(str); -#ifdef FEAT_AUTOCMD else if (data->dwData == COPYDATA_REPLY) { char_u winstr[30]; @@ -2172,7 +2171,6 @@ Messaging_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) apply_autocmds(EVENT_REMOTEREPLY, winstr, str, TRUE, curbuf); } -#endif } return 1; } diff --git a/src/os_unix.c b/src/os_unix.c index ac89955f2..45fd26176 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -445,7 +445,6 @@ mch_inchar( { /* no character available within 'updatetime' */ did_start_blocking = TRUE; -#ifdef FEAT_AUTOCMD if (trigger_cursorhold() && maxlen >= 3 && !typebuf_changed(tb_change_cnt)) { @@ -454,7 +453,6 @@ mch_inchar( buf[2] = (int)KE_CURSORHOLD; return 3; } -#endif /* * If there is no character available within 'updatetime' * seconds flush all the swap files to disk. @@ -1133,16 +1131,15 @@ deathtrap SIGDEFARG(sigarg) /* Remember how often we have been called. */ ++entered; -#ifdef FEAT_AUTOCMD /* Executing autocommands is likely to use more stack space than we have * available in the signal stack. */ block_autocmds(); -#endif #ifdef FEAT_EVAL /* Set the v:dying variable. */ set_vim_var_nr(VV_DYING, (long)entered); #endif + v_dying = entered; #ifdef HAVE_STACK_LIMIT /* Since we are now using the signal stack, need to reset the stack diff --git a/src/os_win32.c b/src/os_win32.c index 91f453f2e..be1c4e0a6 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1787,7 +1787,6 @@ mch_inchar( */ if (!WaitForChar(p_ut, FALSE)) { -#ifdef FEAT_AUTOCMD if (trigger_cursorhold() && maxlen >= 3) { buf[0] = K_SPECIAL; @@ -1795,7 +1794,6 @@ mch_inchar( buf[2] = (int)KE_CURSORHOLD; return 3; } -#endif before_blocking(); } } diff --git a/src/quickfix.c b/src/quickfix.c index 803081038..23cb92696 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -3626,13 +3626,10 @@ qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) /* Set the 'filetype' to "qf" each time after filling the buffer. * This resembles reading a file into a buffer, it's more logical when * using autocommands. */ -#ifdef FEAT_AUTOCMD ++curbuf_lock; -#endif set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL); curbuf->b_p_ma = FALSE; -#ifdef FEAT_AUTOCMD keep_filetype = TRUE; /* don't detect 'filetype' */ apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, FALSE, curbuf); @@ -3640,7 +3637,7 @@ qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) FALSE, curbuf); keep_filetype = FALSE; --curbuf_lock; -#endif + /* make sure it will be redrawn */ redraw_curbuf_later(NOT_VALID); } @@ -3682,7 +3679,6 @@ ex_make(exarg_T *eap) win_T *wp = NULL; qf_info_T *qi = &ql_info; int res; -#ifdef FEAT_AUTOCMD char_u *au_name = NULL; /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */ @@ -3705,12 +3701,11 @@ ex_make(exarg_T *eap) if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, TRUE, curbuf)) { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) return; -# endif - } #endif + } #ifdef FEAT_MBYTE enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; #endif @@ -3766,7 +3761,6 @@ ex_make(exarg_T *eap) qi = GET_LOC_LIST(wp); if (res >= 0 && qi != NULL) qf_list_changed(qi, qi->qf_curlist); -#ifdef FEAT_AUTOCMD if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, @@ -3776,7 +3770,6 @@ ex_make(exarg_T *eap) else res = 0; } -#endif if (res > 0 && !eap->forceit) qf_jump(qi, 0, 0, FALSE); /* display first error */ @@ -4105,13 +4098,10 @@ ex_cfile(exarg_T *eap) char_u *enc = NULL; win_T *wp = NULL; qf_info_T *qi = &ql_info; -#ifdef FEAT_AUTOCMD char_u *au_name = NULL; int save_qfid; -#endif int res; -#ifdef FEAT_AUTOCMD switch (eap->cmdidx) { case CMD_cfile: au_name = (char_u *)"cfile"; break; @@ -4124,7 +4114,6 @@ ex_cfile(exarg_T *eap) } if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); -#endif #ifdef FEAT_MBYTE enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; #endif @@ -4164,7 +4153,6 @@ ex_cfile(exarg_T *eap) qi = GET_LOC_LIST(wp); if (res >= 0 && qi != NULL) qf_list_changed(qi, qi->qf_curlist); -#ifdef FEAT_AUTOCMD if (qi != NULL) save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; if (au_name != NULL) @@ -4174,7 +4162,6 @@ ex_cfile(exarg_T *eap) * is still valid. */ if (qi != NULL && !qflist_valid(wp, save_qfid)) return; -#endif if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)) qf_jump(qi, 0, 0, eap->forceit); /* display first error */ } @@ -4198,11 +4185,9 @@ ex_vimgrep(exarg_T *eap) int fi; qf_info_T *qi = &ql_info; int loclist_cmd = FALSE; -#ifdef FEAT_AUTOCMD int_u save_qfid; qfline_T *cur_qf_start; win_T *wp; -#endif long lnum; buf_T *buf; int duplicate_name = FALSE; @@ -4212,7 +4197,7 @@ ex_vimgrep(exarg_T *eap) buf_T *first_match_buf = NULL; time_t seconds = 0; int save_mls; -#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) +#if defined(FEAT_SYN_HL) char_u *save_ei = NULL; #endif aco_save_T aco; @@ -4222,7 +4207,6 @@ ex_vimgrep(exarg_T *eap) char_u *dirname_start = NULL; char_u *dirname_now = NULL; char_u *target_dir = NULL; -#ifdef FEAT_AUTOCMD char_u *au_name = NULL; switch (eap->cmdidx) @@ -4240,12 +4224,11 @@ ex_vimgrep(exarg_T *eap) if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, TRUE, curbuf)) { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) return; -# endif - } #endif + } if (eap->cmdidx == CMD_lgrep || eap->cmdidx == CMD_lvimgrep @@ -4325,12 +4308,10 @@ ex_vimgrep(exarg_T *eap) * ":lcd %:p:h" changes the meaning of short path names. */ mch_dirname(dirname_start, MAXPATHL); -#ifdef FEAT_AUTOCMD /* Remember the current values of the quickfix list and qf_start, so that * we can check for autocommands changing the current quickfix list. */ save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; -#endif seconds = (time_t)0; for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi) @@ -4365,7 +4346,7 @@ ex_vimgrep(exarg_T *eap) using_dummy = TRUE; redraw_for_dummy = TRUE; -#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) +#if defined(FEAT_SYN_HL) /* Don't do Filetype autocommands to avoid loading syntax and * indent scripts, a great speed improvement. */ save_ei = au_event_disable(",Filetype"); @@ -4379,7 +4360,7 @@ ex_vimgrep(exarg_T *eap) buf = load_dummy_buffer(fname, dirname_start, dirname_now); p_mls = save_mls; -#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) +#if defined(FEAT_SYN_HL) au_event_restore(save_ei); #endif } @@ -4387,7 +4368,6 @@ ex_vimgrep(exarg_T *eap) /* Use existing, loaded buffer. */ using_dummy = FALSE; -#ifdef FEAT_AUTOCMD if (loclist_cmd) { /* @@ -4419,7 +4399,6 @@ ex_vimgrep(exarg_T *eap) cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; } } -#endif if (buf == NULL) { @@ -4475,9 +4454,7 @@ ex_vimgrep(exarg_T *eap) if (got_int) break; } -#ifdef FEAT_AUTOCMD cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; -#endif if (using_dummy) { @@ -4532,7 +4509,7 @@ ex_vimgrep(exarg_T *eap) * need to be done (again). But not the window-local * options! */ aucmd_prepbuf(&aco, buf); -#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) +#if defined(FEAT_SYN_HL) apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname, TRUE, buf); #endif @@ -4552,7 +4529,6 @@ ex_vimgrep(exarg_T *eap) qf_update_buffer(qi, NULL); -#ifdef FEAT_AUTOCMD if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, TRUE, curbuf); @@ -4563,7 +4539,6 @@ ex_vimgrep(exarg_T *eap) wp = loclist_cmd ? curwin : NULL; if (!qflist_valid(wp, save_qfid)) goto theend; -#endif /* Jump to first match. */ if (qi->qf_lists[qi->qf_curlist].qf_count > 0) @@ -4748,7 +4723,7 @@ wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) { if (curbuf != buf) /* safety check */ { -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) cleanup_T cs; /* Reset the error/interrupt/exception state here so that aborting() @@ -4759,7 +4734,7 @@ wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) wipe_buffer(buf, FALSE); -#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) /* Restore the error/interrupt/exception state if not discarded by a * new aborting error, interrupt, or uncaught exception. */ leave_cleanup(&cs); @@ -5598,12 +5573,9 @@ ex_cbuffer(exarg_T *eap) { buf_T *buf = NULL; qf_info_T *qi = &ql_info; -#ifdef FEAT_AUTOCMD char_u *au_name = NULL; -#endif int res; -#ifdef FEAT_AUTOCMD switch (eap->cmdidx) { case CMD_cbuffer: au_name = (char_u *)"cbuffer"; break; @@ -5617,12 +5589,11 @@ ex_cbuffer(exarg_T *eap) if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, TRUE, curbuf)) { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) return; -# endif - } #endif + } /* Must come after autocommands. */ if (eap->cmdidx == CMD_lbuffer @@ -5670,11 +5641,9 @@ ex_cbuffer(exarg_T *eap) qf_title, NULL); if (res >= 0) qf_list_changed(qi, qi->qf_curlist); -#ifdef FEAT_AUTOCMD if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, TRUE, curbuf); -#endif if (res > 0 && (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer)) qf_jump(qi, 0, 0, eap->forceit); /* display first error */ @@ -5692,12 +5661,9 @@ ex_cexpr(exarg_T *eap) { typval_T *tv; qf_info_T *qi = &ql_info; -#ifdef FEAT_AUTOCMD char_u *au_name = NULL; -#endif int res; -#ifdef FEAT_AUTOCMD switch (eap->cmdidx) { case CMD_cexpr: au_name = (char_u *)"cexpr"; break; @@ -5711,12 +5677,11 @@ ex_cexpr(exarg_T *eap) if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, TRUE, curbuf)) { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) return; -# endif - } #endif + } if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr @@ -5742,11 +5707,9 @@ ex_cexpr(exarg_T *eap) NULL); if (res >= 0) qf_list_changed(qi, qi->qf_curlist); -#ifdef FEAT_AUTOCMD if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, TRUE, curbuf); -#endif if (res > 0 && (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr)) qf_jump(qi, 0, 0, eap->forceit); /* display first error */ @@ -5779,16 +5742,13 @@ ex_helpgrep(exarg_T *eap) qf_info_T *save_qi; int new_qi = FALSE; win_T *wp; -#ifdef FEAT_AUTOCMD char_u *au_name = NULL; -#endif #ifdef FEAT_MULTI_LANG /* Check for a specified language */ lang = check_help_lang(eap->arg); #endif -#ifdef FEAT_AUTOCMD switch (eap->cmdidx) { case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break; @@ -5798,12 +5758,11 @@ ex_helpgrep(exarg_T *eap) if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, TRUE, curbuf)) { -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL if (aborting()) return; -# endif - } #endif + } /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ save_cpo = p_cpo; @@ -5965,7 +5924,6 @@ ex_helpgrep(exarg_T *eap) qf_list_changed(qi, qi->qf_curlist); qf_update_buffer(qi, NULL); -#ifdef FEAT_AUTOCMD if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, @@ -5974,7 +5932,6 @@ ex_helpgrep(exarg_T *eap) /* autocommands made "qi" invalid */ return; } -#endif /* Jump to first match. */ if (qi->qf_lists[qi->qf_curlist].qf_count > 0) diff --git a/src/screen.c b/src/screen.c index a7ed60111..935f9810c 100644 --- a/src/screen.c +++ b/src/screen.c @@ -8767,11 +8767,9 @@ screenalloc(int doclear) tabpage_T *tp; static int entered = FALSE; /* avoid recursiveness */ static int done_outofmem_msg = FALSE; /* did outofmem message */ -#ifdef FEAT_AUTOCMD int retry_count = 0; retry: -#endif /* * Allocation of the screen buffers is done only when the size changes and * when Rows and Columns have been set and we have started doing full @@ -8823,10 +8821,8 @@ retry: */ FOR_ALL_TAB_WINDOWS(tp, wp) win_free_lsize(wp); -#ifdef FEAT_AUTOCMD if (aucmd_win != NULL) win_free_lsize(aucmd_win); -#endif new_ScreenLines = (schar_T *)lalloc((long_u)( (Rows + 1) * Columns * sizeof(schar_T)), FALSE); @@ -8859,11 +8855,9 @@ retry: goto give_up; } } -#ifdef FEAT_AUTOCMD if (aucmd_win != NULL && aucmd_win->w_lines == NULL && win_alloc_lines(aucmd_win) == FAIL) outofmem = TRUE; -#endif give_up: #ifdef FEAT_MBYTE @@ -9032,7 +9026,6 @@ give_up: entered = FALSE; --RedrawingDisabled; -#ifdef FEAT_AUTOCMD /* * Do not apply autocommands more than 3 times to avoid an endless loop * in case applying autocommands always changes Rows or Columns. @@ -9044,7 +9037,6 @@ give_up: * jump back to check if we need to allocate the screen again. */ goto retry; } -#endif } void diff --git a/src/search.c b/src/search.c index d3c651829..a4b272224 100644 --- a/src/search.c +++ b/src/search.c @@ -97,10 +97,8 @@ static char_u lastc_bytes[MB_MAXBYTES + 1]; static int lastc_bytelen = 1; /* >1 for multi-byte char */ #endif -#if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) /* copy of spats[], for keeping the search patterns while executing autocmds */ static struct spat saved_spats[2]; -#endif # ifdef FEAT_SEARCH_EXTRA /* copy of spats[RE_SEARCH], for keeping the search patterns while incremental * searching */ @@ -300,7 +298,6 @@ save_re_pat(int idx, char_u *pat, int magic) } } -#if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) /* * Save the search patterns, so they can be restored later. * Used before/after executing autocommands and user functions. @@ -318,10 +315,10 @@ save_search_patterns(void) saved_spats[1] = spats[1]; if (spats[1].pat != NULL) saved_spats[1].pat = vim_strsave(spats[1].pat); +#ifdef FEAT_SEARCH_EXTRA saved_last_idx = last_idx; -# ifdef FEAT_SEARCH_EXTRA saved_no_hlsearch = no_hlsearch; -# endif +#endif } } @@ -332,18 +329,17 @@ restore_search_patterns(void) { vim_free(spats[0].pat); spats[0] = saved_spats[0]; -# if defined(FEAT_EVAL) +#if defined(FEAT_EVAL) set_vv_searchforward(); -# endif +#endif vim_free(spats[1].pat); spats[1] = saved_spats[1]; +#ifdef FEAT_SEARCH_EXTRA last_idx = saved_last_idx; -# ifdef FEAT_SEARCH_EXTRA SET_NO_HLSEARCH(saved_no_hlsearch); -# endif +#endif } } -#endif #if defined(EXITFREE) || defined(PROTO) void diff --git a/src/spell.c b/src/spell.c index 0e08e9e7b..05a9d2cd8 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1849,9 +1849,7 @@ spell_load_lang(char_u *lang) char_u fname_enc[85]; int r; spelload_T sl; -#ifdef FEAT_AUTOCMD int round; -#endif /* Copy the language name to pass it to spell_load_cb() as a cookie. * It's truncated when an error is detected. */ @@ -1859,11 +1857,9 @@ spell_load_lang(char_u *lang) sl.sl_slang = NULL; sl.sl_nobreak = FALSE; -#ifdef FEAT_AUTOCMD /* We may retry when no spell file is found for the language, an * autocommand may load it then. */ for (round = 1; round <= 2; ++round) -#endif { /* * Find the first spell file for "lang" in 'runtimepath' and load it. @@ -1889,17 +1885,13 @@ spell_load_lang(char_u *lang) lang); r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl); -#ifdef FEAT_AUTOCMD if (r == FAIL && *sl.sl_lang != NUL && round == 1 && apply_autocmds(EVENT_SPELLFILEMISSING, lang, curbuf->b_fname, FALSE, curbuf)) continue; break; -#endif } -#ifdef FEAT_AUTOCMD break; -#endif } if (r == FAIL) @@ -2348,11 +2340,9 @@ did_set_spelllang(win_T *wp) static int recursive = FALSE; char_u *ret_msg = NULL; char_u *spl_copy; -#ifdef FEAT_AUTOCMD bufref_T bufref; set_bufref(&bufref, wp->w_buffer); -#endif /* We don't want to do this recursively. May happen when a language is * not available and the SpellFileMissing autocommand opens a new buffer @@ -2449,7 +2439,6 @@ did_set_spelllang(win_T *wp) else { spell_load_lang(lang); -#ifdef FEAT_AUTOCMD /* SpellFileMissing autocommands may do anything, including * destroying the buffer we are using... */ if (!bufref_valid(&bufref)) @@ -2457,7 +2446,6 @@ did_set_spelllang(win_T *wp) ret_msg = (char_u *)N_("E797: SpellFileMissing autocommand deleted buffer"); goto theend; } -#endif } } diff --git a/src/structs.h b/src/structs.h index fe8c03609..56af7939d 100644 --- a/src/structs.h +++ b/src/structs.h @@ -586,9 +586,7 @@ typedef struct int lockmarks; /* TRUE when ":lockmarks" was used */ int keeppatterns; /* TRUE when ":keeppatterns" was used */ int noswapfile; /* TRUE when ":noswapfile" was used */ -# ifdef FEAT_AUTOCMD char_u *save_ei; /* saved value of 'eventignore' */ -# endif regmatch_T filter_regmatch; /* set by :filter /pat/ */ int filter_force; /* set for :filter! */ } cmdmod_T; @@ -1946,10 +1944,8 @@ struct file_buffer int b_nwindows; /* nr of windows open on this buffer */ int b_flags; /* various BF_ flags */ -#ifdef FEAT_AUTOCMD int b_locked; /* Buffer is being closed or referenced, don't let autocommands wipe it out. */ -#endif /* * b_ffname has the full path of the file (NULL for no name). @@ -1986,13 +1982,11 @@ struct file_buffer incremented for each change, also for undo */ #define CHANGEDTICK(buf) ((buf)->b_ct_di.di_tv.vval.v_number) -#ifdef FEAT_AUTOCMD varnumber_T b_last_changedtick; /* b:changedtick when TextChanged or TextChangedI was last triggered. */ -# ifdef FEAT_INS_EXPAND +#ifdef FEAT_INS_EXPAND varnumber_T b_last_changedtick_pum; /* b:changedtick when TextChangedP was last triggered. */ -# endif #endif int b_saving; /* Set to TRUE if we are in the middle of @@ -2171,9 +2165,7 @@ struct file_buffer char_u *b_p_fenc; /* 'fileencoding' */ #endif char_u *b_p_ff; /* 'fileformat' */ -#ifdef FEAT_AUTOCMD char_u *b_p_ft; /* 'filetype' */ -#endif char_u *b_p_fo; /* 'formatoptions' */ char_u *b_p_flp; /* 'formatlistpat' */ int b_p_inf; /* 'infercase' */ @@ -2448,12 +2440,8 @@ struct diffblock_S #endif #define SNAP_HELP_IDX 0 -#ifdef FEAT_AUTOCMD -# define SNAP_AUCMD_IDX 1 -# define SNAP_COUNT 2 -#else -# define SNAP_COUNT 1 -#endif +#define SNAP_AUCMD_IDX 1 +#define SNAP_COUNT 2 /* * Tab pages point to the top frame of each tab page. @@ -2642,10 +2630,8 @@ struct window_S win_T *w_prev; /* link to previous window */ win_T *w_next; /* link to next window */ -#ifdef FEAT_AUTOCMD int w_closing; /* window is being closed, don't let autocommands close it too. */ -#endif frame_T *w_frame; /* frame containing this window */ @@ -2676,10 +2662,8 @@ struct window_S */ linenr_T w_topline; /* buffer line number of the line at the top of the window */ -#ifdef FEAT_AUTOCMD char w_topline_was_set; /* flag set to TRUE when topline is set, e.g. by winrestview() */ -#endif #ifdef FEAT_DIFF int w_topfill; /* number of filler lines above w_topline */ int w_old_topfill; /* w_topfill at last redraw */ @@ -2973,10 +2957,8 @@ typedef struct oparg_S int block_mode; /* current operator is Visual block mode */ colnr_T start_vcol; /* start col for block mode operator */ colnr_T end_vcol; /* end col for block mode operator */ -#ifdef FEAT_AUTOCMD long prev_opcount; /* ca.opcount saved for K_CURSORHOLD */ long prev_count0; /* ca.count0 saved for K_CURSORHOLD */ -#endif } oparg_T; /* @@ -3160,18 +3142,16 @@ typedef int vimmenu_T; /* * Struct to save values in before executing autocommands for a buffer that is - * not the current buffer. Without FEAT_AUTOCMD only "curbuf" is remembered. + * not the current buffer. */ typedef struct { buf_T *save_curbuf; /* saved curbuf */ -#ifdef FEAT_AUTOCMD int use_aucmd_win; /* using aucmd_win */ win_T *save_curwin; /* saved curwin */ win_T *new_curwin; /* new curwin */ bufref_T new_curbuf; /* new curbuf */ char_u *globaldir; /* saved value of globaldir */ -#endif } aco_save_T; /* diff --git a/src/syntax.c b/src/syntax.c index d0d4515e0..d09359ab1 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -6420,11 +6420,9 @@ ex_ownsyntax(exarg_T *eap) if (old_value != NULL) old_value = vim_strsave(old_value); -#ifdef FEAT_AUTOCMD /* Apply the "syntax" autocommand event, this finds and loads the syntax * file. */ apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, TRUE, curbuf); -#endif /* move value of b:current_syntax to w:current_syntax */ new_value = get_var_value((char_u *)"b:current_syntax"); @@ -6995,10 +6993,8 @@ static char *(highlight_init_light[]) = { CENT("Conceal ctermbg=DarkGrey ctermfg=LightGrey", "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey"), #endif -#ifdef FEAT_AUTOCMD CENT("MatchParen term=reverse ctermbg=Cyan", "MatchParen term=reverse ctermbg=Cyan guibg=Cyan"), -#endif #ifdef FEAT_GUI "Normal gui=NONE", #endif @@ -7089,10 +7085,8 @@ static char *(highlight_init_dark[]) = { CENT("ColorColumn term=reverse ctermbg=DarkRed", "ColorColumn term=reverse ctermbg=DarkRed guibg=DarkRed"), #endif -#ifdef FEAT_AUTOCMD CENT("MatchParen term=reverse ctermbg=DarkCyan", "MatchParen term=reverse ctermbg=DarkCyan guibg=DarkCyan"), -#endif #ifdef FEAT_CONCEAL CENT("Conceal ctermbg=DarkGrey ctermfg=LightGrey", "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey"), @@ -7233,9 +7227,7 @@ load_colors(char_u *name) sprintf((char *)buf, "colors/%s.vim", name); retval = source_runtime(buf, DIP_START + DIP_OPT); vim_free(buf); -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); -#endif } recursive = FALSE; @@ -1017,7 +1017,7 @@ do_tag( } } -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) /* Let the SwapExists event know what tag we are jumping to. */ vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name); set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1); @@ -1028,7 +1028,7 @@ do_tag( */ i = jumpto_tag(matches[cur_match], forceit, type != DT_CSCOPE); -#ifdef FEAT_AUTOCMD +#if defined(FEAT_EVAL) set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); #endif @@ -3174,11 +3174,7 @@ jumpto_tag( * file. Also accept a file name for which there is a matching BufReadCmd * autocommand event (e.g., http://sys/file). */ - if (mch_getperm(fname) < 0 -#ifdef FEAT_AUTOCMD - && !has_autocmd(EVENT_BUFREADCMD, fname, NULL) -#endif - ) + if (mch_getperm(fname) < 0 && !has_autocmd(EVENT_BUFREADCMD, fname, NULL)) { retval = NOTAGFILE; vim_free(nofile_fname); diff --git a/src/term.c b/src/term.c index 7dbbefa49..72b68123b 100644 --- a/src/term.c +++ b/src/term.c @@ -1985,7 +1985,6 @@ set_termname(char_u *term) scroll_region_reset(); /* In case Rows changed */ check_map_keycodes(); /* check mappings for terminal codes used */ -#ifdef FEAT_AUTOCMD { bufref_T old_curbuf; @@ -2003,7 +2002,6 @@ set_termname(char_u *term) if (bufref_valid(&old_curbuf)) curbuf = old_curbuf.br_buf; } -#endif } #ifdef FEAT_TERMRESPONSE @@ -4515,9 +4513,7 @@ check_termcode( LOG_TR("Received U7 status"); u7_status = STATUS_GOT; -# ifdef FEAT_AUTOCMD did_cursorhold = TRUE; -# endif if (col == 2) aw = "single"; else if (col == 3) @@ -4560,9 +4556,7 @@ check_termcode( LOG_TR("Received CRV response"); crv_status = STATUS_GOT; -# ifdef FEAT_AUTOCMD did_cursorhold = TRUE; -# endif /* If this code starts with CSI, you can bet that the * terminal uses 8-bit codes. */ @@ -4702,10 +4696,8 @@ check_termcode( # ifdef FEAT_EVAL set_vim_var_string(VV_TERMRESPONSE, tp, slen); # endif -# ifdef FEAT_AUTOCMD apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); -# endif key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; } diff --git a/src/terminal.c b/src/terminal.c index 53591f15c..89fafebb0 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -38,6 +38,10 @@ * in tl_scrollback are no longer used. * * TODO: + * - What to store in a session file? Shell at the prompt would be OK to + * restore, but others may not. Open the window and let the user start the + * command? Also see #2650. + * - Adding WinBar to terminal window doesn't display, text isn't shifted down. * - When using 'termguicolors' still use the 16 ANSI colors as-is. Helps for * a job that uses 16 colors while Vim is using > 256. * - in GUI vertical split causes problems. Cursor is flickering. (Hirohito @@ -46,24 +50,20 @@ * - after resizing windows overlap. (Boris Staletic, #2164) * - Redirecting output does not work on MS-Windows, Test_terminal_redir_file() * is disabled. + * - if the job in the terminal does not support the mouse, we can use the + * mouse in the Terminal window for copy/paste and scrolling. * - cursor blinks in terminal on widows with a timer. (xtal8, #2142) - * - What to store in a session file? Shell at the prompt would be OK to - * restore, but others may not. Open the window and let the user start the - * command? Also see #2650. * - When closing gvim with an active terminal buffer, the dialog suggests * saving the buffer. Should say something else. (Manas Thakur, #2215) * Also: #2223 * - Termdebug does not work when Vim build with mzscheme. gdb hangs. * - MS-Windows GUI: WinBar has tearoff item - * - Adding WinBar to terminal window doesn't display, text isn't shifted down. * - MS-Windows GUI: still need to type a key after shell exits? #1924 * - After executing a shell command the status line isn't redraw. * - implement term_setsize() * - add test for giving error for invalid 'termsize' value. * - support minimal size when 'termsize' is "rows*cols". * - support minimal size when 'termsize' is empty? - * - if the job in the terminal does not support the mouse, we can use the - * mouse in the Terminal window for copy/paste and scrolling. * - GUI: when using tabs, focus in terminal, click on tab does not work. * - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save * changes to "!shell". @@ -506,14 +506,12 @@ term_start(typval_T *argvar, jobopt_T *opt, int without_job, int forceit) * a deadlock if the job is waiting for Vim to read. */ channel_set_nonblock(term->tl_job->jv_channel, PART_IN); -#ifdef FEAT_AUTOCMD if (!opt->jo_hidden) { ++curbuf->b_locked; apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf); --curbuf->b_locked; } -#endif if (old_curbuf != NULL) { @@ -938,9 +936,7 @@ term_convert_key(term_T *term, int c, char *buf) #ifdef FEAT_DND case K_DROP: return 0; #endif -#ifdef FEAT_AUTOCMD case K_CURSORHOLD: return 0; -#endif case K_PS: vterm_keyboard_start_paste(vterm); other = TRUE; break; @@ -3299,13 +3299,11 @@ ui_focus_change( last_time = time(NULL); } -#ifdef FEAT_AUTOCMD /* * Fire the focus gained/lost autocommand. */ need_redraw |= apply_autocmds(in_focus ? EVENT_FOCUSGAINED : EVENT_FOCUSLOST, NULL, NULL, FALSE, curbuf); -#endif if (need_redraw) { @@ -3339,7 +3337,7 @@ ui_focus_change( } #endif -#if defined(FEAT_MBYTE) || defined(PROTO) +#if defined(HAVE_INPUT_METHOD) || defined(PROTO) /* * Save current Input Method status to specified place. */ diff --git a/src/undo.c b/src/undo.c index c723eba6c..09bcc91be 100644 --- a/src/undo.c +++ b/src/undo.c @@ -424,7 +424,6 @@ u_savecommon( term_change_in_curbuf(); #endif -#ifdef FEAT_AUTOCMD /* * Saving text for undo means we are going to make a change. Give a * warning for a read-only file before making the change, so that the @@ -439,7 +438,6 @@ u_savecommon( EMSG(_("E881: Line count changed unexpectedly")); return FAIL; } -#endif } #ifdef U_DEBUG @@ -2631,11 +2629,9 @@ u_undoredo(int undo) int empty_buffer; /* buffer became empty */ u_header_T *curhead = curbuf->b_u_curhead; -#ifdef FEAT_AUTOCMD /* Don't want autocommands using the undo structures here, they are * invalid till the end. */ block_autocmds(); -#endif #ifdef U_DEBUG u_check(FALSE); @@ -2664,9 +2660,7 @@ u_undoredo(int undo) if (top > curbuf->b_ml.ml_line_count || top >= bot || bot > curbuf->b_ml.ml_line_count + 1) { -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif IEMSG(_("E438: u_undo: line numbers wrong")); changed(); /* don't want UNCHANGED now */ return; @@ -2891,9 +2885,7 @@ u_undoredo(int undo) * the undone/redone change. */ curbuf->b_u_time_cur = curhead->uh_time; -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif #ifdef U_DEBUG u_check(FALSE); #endif diff --git a/src/userfunc.c b/src/userfunc.c index 58a6b78aa..f9b0e8192 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -1372,7 +1372,6 @@ call_func( else fp = find_func(rfname); -#ifdef FEAT_AUTOCMD /* Trigger FuncUndefined event, may load the function. */ if (fp == NULL && apply_autocmds(EVENT_FUNCUNDEFINED, @@ -1382,7 +1381,6 @@ call_func( /* executed an autocommand, search for the function again */ fp = find_func(rfname); } -#endif /* Try loading a package. */ if (fp == NULL && script_autoload(rfname, TRUE) && !aborting()) { diff --git a/src/version.c b/src/version.c index c780826e6..18d50af01 100644 --- a/src/version.c +++ b/src/version.c @@ -78,11 +78,7 @@ static char *(features[]) = #else "-arabic", #endif -#ifdef FEAT_AUTOCMD "+autocmd", -#else - "-autocmd", -#endif #ifdef FEAT_AUTOSERVERNAME "+autoservername", #else @@ -779,6 +775,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1564, +/**/ 1563, /**/ 1562, @@ -2118,6 +2118,20 @@ typedef enum { # define USE_MCH_ERRMSG #endif +/* Whether IME is supported when XIM is not used. */ +# if defined(FEAT_MBYTE_IME) && \ + (!defined(FEAT_GUI_W32) || !(defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) +# define IME_WITHOUT_XIM +#endif + +#if defined(FEAT_MBYTE) && (defined(FEAT_XIM) \ + || defined(IME_WITHOUT_XIM) \ + || defined(FEAT_GUI_W32) \ + || defined(MACOS_CONVERT)) +/* im_set_active() is available */ +# define HAVE_INPUT_METHOD +#endif + #ifndef FEAT_MBYTE # define after_pathsep(b, p) vim_ispathsep(*((p) - 1)) # define transchar_byte(c) transchar(c) diff --git a/src/window.c b/src/window.c index 40a4607d0..23c324b5b 100644 --- a/src/window.c +++ b/src/window.c @@ -1437,13 +1437,11 @@ make_windows( if (count > 1) last_status(TRUE); -#ifdef FEAT_AUTOCMD /* * Don't execute autocommands while creating the windows. Must do that * when putting the buffers in the windows. */ block_autocmds(); -#endif /* todo is number of windows left to create */ for (todo = count - 1; todo > 0; --todo) @@ -1461,9 +1459,7 @@ make_windows( break; } -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif /* return actual number of windows */ return (count - todo); @@ -2104,19 +2100,14 @@ close_windows( win_T *wp; tabpage_T *tp, *nexttp; int h = tabline_height(); -#ifdef FEAT_AUTOCMD int count = tabpage_index(NULL); -#endif ++RedrawingDisabled; for (wp = firstwin; wp != NULL && !ONE_WINDOW; ) { if (wp->w_buffer == buf && (!keep_curwin || wp != curwin) -#ifdef FEAT_AUTOCMD - && !(wp->w_closing || wp->w_buffer->b_locked > 0) -#endif - ) + && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { if (win_close(wp, FALSE) == FAIL) /* If closing the window fails give up, to avoid looping @@ -2137,10 +2128,7 @@ close_windows( if (tp != curtab) for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) if (wp->w_buffer == buf -#ifdef FEAT_AUTOCMD - && !(wp->w_closing || wp->w_buffer->b_locked > 0) -#endif - ) + && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { win_close_othertab(wp, FALSE, tp); @@ -2153,10 +2141,8 @@ close_windows( --RedrawingDisabled; -#ifdef FEAT_AUTOCMD if (count != tabpage_index(NULL)) apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); -#endif redraw_tabline = TRUE; if (h != tabline_height()) @@ -2181,7 +2167,6 @@ last_window(void) int one_window(void) { -#ifdef FEAT_AUTOCMD win_T *wp; int seen_one = FALSE; @@ -2195,9 +2180,6 @@ one_window(void) } } return TRUE; -#else - return ONE_WINDOW; -#endif } /* @@ -2212,9 +2194,7 @@ close_last_window_tabpage( { if (ONE_WINDOW) { -#ifdef FEAT_AUTOCMD buf_T *old_curbuf = curbuf; -#endif /* * Closing the last window in a tab page. First go to another tab @@ -2239,13 +2219,11 @@ close_last_window_tabpage( } /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do * that now. */ -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); if (old_curbuf != curbuf) apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); -#endif return TRUE; } return FALSE; @@ -2262,9 +2240,7 @@ close_last_window_tabpage( win_close(win_T *win, int free_buf) { win_T *wp; -#ifdef FEAT_AUTOCMD int other_buffer = FALSE; -#endif int close_curwin = FALSE; int dir; int help_window = FALSE; @@ -2277,7 +2253,6 @@ win_close(win_T *win, int free_buf) return FAIL; } -#ifdef FEAT_AUTOCMD if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_locked > 0)) return FAIL; /* window is already being closed */ @@ -2291,7 +2266,6 @@ win_close(win_T *win, int free_buf) EMSG(_("E814: Cannot close window, only autocmd window would remain")); return FAIL; } -#endif /* When closing the last window in a tab page first go to another tab page * and then close the window and the tab page to avoid that curwin and @@ -2306,7 +2280,6 @@ win_close(win_T *win, int free_buf) else clear_snapshot(curtab, SNAP_HELP_IDX); -#ifdef FEAT_AUTOCMD if (win == curwin) { /* @@ -2337,13 +2310,12 @@ win_close(win_T *win, int free_buf) win->w_closing = FALSE; if (last_window()) return FAIL; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL /* autocmds may abort script processing */ if (aborting()) return FAIL; -# endif - } #endif + } #ifdef FEAT_GUI /* Avoid trouble with scrollbars that are going to be deleted in @@ -2366,14 +2338,10 @@ win_close(win_T *win, int free_buf) bufref_T bufref; set_bufref(&bufref, curbuf); -#ifdef FEAT_AUTOCMD win->w_closing = TRUE; -#endif close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE); -#ifdef FEAT_AUTOCMD if (win_valid_any_tab(win)) win->w_closing = FALSE; -#endif /* Make sure curbuf is valid. It can become invalid if 'bufhidden' is * "wipe". */ if (!bufref_valid(&bufref)) @@ -2455,11 +2423,9 @@ win_close(win_T *win, int free_buf) if (close_curwin) { win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE); -#ifdef FEAT_AUTOCMD if (other_buffer) /* careful: after this wp and win may be invalid! */ apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); -#endif } /* @@ -2498,13 +2464,11 @@ win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) tabpage_T *ptp = NULL; int free_tp = FALSE; -#ifdef FEAT_AUTOCMD /* Get here with win->w_buffer == NULL when win_close() detects the tab * page changed. */ if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_locked > 0)) return; /* window is already being closed */ -#endif if (win->w_buffer != NULL) /* Close the link to the buffer. */ @@ -2586,13 +2550,11 @@ win_free_all(void) while (first_tabpage->tp_next != NULL) tabpage_close(TRUE); -# 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); @@ -3331,11 +3293,7 @@ close_others( if (one_window()) { - if (message -#ifdef FEAT_AUTOCMD - && !autocmd_busy -#endif - ) + if (message && !autocmd_busy) MSG(_(m_onlyone)); return; } @@ -3349,26 +3307,22 @@ close_others( /* Check if it's allowed to abandon this window */ r = can_abandon(wp->w_buffer, forceit); -#ifdef FEAT_AUTOCMD if (!win_valid(wp)) /* autocommands messed wp up */ { nextwp = firstwin; continue; } -#endif if (!r) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if (message && (p_confirm || cmdmod.confirm) && p_write) { dialog_changed(wp->w_buffer, FALSE); -# ifdef FEAT_AUTOCMD if (!win_valid(wp)) /* autocommands messed wp up */ { nextwp = firstwin; continue; } -# endif } if (bufIsChanged(wp->w_buffer)) #endif @@ -3443,7 +3397,6 @@ win_alloc_first(void) return OK; } -#if defined(FEAT_AUTOCMD) || defined(PROTO) /* * Init "aucmd_win". This can only be done after the first * window is fully initialized, thus it can't be in win_alloc_first(). @@ -3459,7 +3412,6 @@ win_alloc_aucmd_win(void) new_frame(aucmd_win); } } -#endif /* * Allocate the first window or the first window in a new tab page. @@ -3663,12 +3615,10 @@ win_new_tabpage(int after) #endif redraw_all_later(CLEAR); -#ifdef FEAT_AUTOCMD apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); -#endif return OK; } @@ -3710,21 +3660,17 @@ make_tabpages(int maxcount) if (count > p_tpm) count = p_tpm; -#ifdef FEAT_AUTOCMD /* * Don't execute autocommands while creating the tab pages. Must do that * when putting the buffers in the windows. */ block_autocmds(); -#endif for (todo = count - 1; todo > 0; --todo) if (win_new_tabpage(0) == FAIL) break; -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif /* return actual number of tab pages */ return (count - todo); @@ -3841,7 +3787,6 @@ leave_tabpage( tabpage_T *tp = curtab; reset_VIsual_and_resel(); /* stop Visual mode */ -#ifdef FEAT_AUTOCMD if (trigger_leave_autocmds) { if (new_curbuf != curbuf) @@ -3857,7 +3802,6 @@ leave_tabpage( if (curtab != tp) return FAIL; } -#endif #if defined(FEAT_GUI) /* Remove the scrollbars. They may be added back later. */ if (gui.in_use) @@ -3929,7 +3873,6 @@ enter_tabpage( gui_may_update_scrollbars(); #endif -#ifdef FEAT_AUTOCMD /* Apply autocommands after updating the display, when 'rows' and * 'columns' have been set correctly. */ if (trigger_enter_autocmds) @@ -3938,7 +3881,6 @@ enter_tabpage( if (old_curbuf != curbuf) apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); } -#endif redraw_all_later(CLEAR); } @@ -4131,10 +4073,8 @@ win_goto(win_T *wp) text_locked_msg(); return; } -#ifdef FEAT_AUTOCMD if (curbuf_locked()) return; -#endif if (wp->w_buffer != curbuf) reset_VIsual_and_resel(); @@ -4337,14 +4277,11 @@ win_enter_ext( int trigger_enter_autocmds UNUSED, int trigger_leave_autocmds UNUSED) { -#ifdef FEAT_AUTOCMD int other_buffer = FALSE; -#endif if (wp == curwin && !curwin_invalid) /* nothing to do */ return; -#ifdef FEAT_AUTOCMD if (!curwin_invalid && trigger_leave_autocmds) { /* @@ -4360,13 +4297,12 @@ win_enter_ext( apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); if (!win_valid(wp)) return; -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL /* autocmds may abort script processing */ if (aborting()) return; -# endif - } #endif + } /* sync undo before leaving the current buffer */ if (undo_sync && curbuf != wp->w_buffer) @@ -4417,7 +4353,6 @@ win_enter_ext( shorten_fnames(TRUE); } -#ifdef FEAT_AUTOCMD if (trigger_new_autocmds) apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); if (trigger_enter_autocmds) @@ -4426,7 +4361,6 @@ win_enter_ext( if (other_buffer) apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); } -#endif #ifdef FEAT_TITLE maketitle(); @@ -4544,12 +4478,11 @@ win_alloc(win_T *after UNUSED, int hidden UNUSED) init_var_dict(new_wp->w_vars, &new_wp->w_winvar, VAR_SCOPE); #endif -#ifdef FEAT_AUTOCMD /* Don't execute autocommands while the window is not properly * initialized yet. gui_create_scrollbar() may trigger a FocusGained * event. */ block_autocmds(); -#endif + /* * link the window in the window list */ @@ -4585,9 +4518,7 @@ win_alloc(win_T *after UNUSED, int hidden UNUSED) #ifdef FEAT_FOLDING foldInitWin(new_wp); #endif -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif #ifdef FEAT_SEARCH_EXTRA new_wp->w_match_head = NULL; new_wp->w_next_match_id = 4; @@ -4614,11 +4545,9 @@ win_free( /* 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. */ block_autocmds(); -#endif #ifdef FEAT_LUA lua_window_free(wp); @@ -4708,23 +4637,17 @@ win_free( vim_free(wp->w_p_cc_cols); #endif -#ifdef FEAT_AUTOCMD if (wp != aucmd_win) -#endif win_remove(wp, tp); -#ifdef FEAT_AUTOCMD if (autocmd_busy) { wp->w_next = au_pending_free_win; au_pending_free_win = wp; } else -#endif vim_free(wp); -#ifdef FEAT_AUTOCMD unblock_autocmds(); -#endif } /* @@ -6426,11 +6349,7 @@ only_one_window(void) # ifdef FEAT_QUICKFIX || wp->w_p_pvw # endif - ) || wp == curwin) -# ifdef FEAT_AUTOCMD - && wp != aucmd_win -# endif - ) + ) || wp == curwin) && wp != aucmd_win) ++count; return (count <= 1); } @@ -6613,9 +6532,7 @@ switch_win( tabpage_T *tp, int no_display) { -# ifdef FEAT_AUTOCMD block_autocmds(); -# endif *save_curwin = curwin; if (tp != NULL) { @@ -6667,9 +6584,7 @@ restore_win( curwin = save_curwin; curbuf = curwin->w_buffer; } -# ifdef FEAT_AUTOCMD unblock_autocmds(); -# endif } /* @@ -6679,9 +6594,7 @@ restore_win( void switch_buffer(bufref_T *save_curbuf, buf_T *buf) { -# ifdef FEAT_AUTOCMD block_autocmds(); -# endif set_bufref(save_curbuf, curbuf); --curbuf->b_nwindows; curbuf = buf; @@ -6695,9 +6608,7 @@ switch_buffer(bufref_T *save_curbuf, buf_T *buf) void restore_buffer(bufref_T *save_curbuf) { -# ifdef FEAT_AUTOCMD unblock_autocmds(); -# endif /* Check for valid buffer, just in case. */ if (bufref_valid(save_curbuf)) { |