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/main.c | |
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/main.c')
-rw-r--r-- | src/main.c | 69 |
1 files changed, 14 insertions, 55 deletions
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 */ |