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.
diff --git a/src/ex_getln.c b/src/ex_getln.c
index f92f1df..6119ad2 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -146,7 +146,6 @@
#endif
-#ifdef FEAT_AUTOCMD
static void
trigger_cmd_autocmd(int typechar, int evt)
{
@@ -156,7 +155,6 @@
typestr[1] = NUL;
apply_autocmds(evt, typestr, typestr, FALSE, curbuf);
}
-#endif
/*
* Abandon the command line.
@@ -266,9 +264,7 @@
* 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 @@
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 @@
* 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 @@
{
/* ":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 @@
*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 @@
#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 @@
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 @@
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 @@
}
return FALSE;
}
-#endif
static int
cmdline_charsize(int idx)
@@ -4983,10 +4971,8 @@
{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 @@
/* 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 @@
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 @@
# 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 @@
}
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 @@
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 @@
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 @@
}
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 @@
}
}
-# 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 @@
/* Restore window sizes. */
win_size_restore(&winsizes);
-# ifdef FEAT_AUTOCMD
unblock_autocmds();
-# endif
}
ga_clear(&winsizes);