diff src/ex_getln.c @ 13380:69517d67421f v8.0.1564

patch 8.0.1564: too many #ifdefs commit https://github.com/vim/vim/commit/f2bd8ef2b4507d02c6043affff8f7e85e3414d5f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 4 18:08:14 2018 +0100 patch 8.0.1564: too many #ifdefs Problem: Too many #ifdefs. Solution: Graduate the +autocmd feature. Takes away 450 #ifdefs and increases code size of tiny Vim by only 40 Kbyte.
author Christian Brabandt <cb@256bit.org>
date Sun, 04 Mar 2018 18:15:08 +0100
parents 69e86e6e5703
children 1fd0f8392946
line wrap: on
line diff
--- 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 ev
     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);