summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-21 20:17:31 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-21 20:17:31 +0100
commit8e145b82464a21ee4fdf7948f04e2a1d505f8bfa (patch)
tree833d3862b868395323a8670c15af4b30f1d5564e /src
parent5a01caa90428a5f87600528d68529383c0b2f78c (diff)
patch 8.2.4993: smart/C/lisp indenting is optionalv8.2.4993
Problem: smart/C/lisp indenting is optional, which makes the code more complex, while it only reduces the executable size a bit. Solution: Graduate FEAT_CINDENT, FEAT_SMARTINDENT and FEAT_LISP.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c10
-rw-r--r--src/change.c67
-rw-r--r--src/charset.c2
-rw-r--r--src/cindent.c13
-rw-r--r--src/edit.c66
-rw-r--r--src/evalfunc.c24
-rw-r--r--src/feature.h22
-rw-r--r--src/globals.h2
-rw-r--r--src/indent.c33
-rw-r--r--src/insexpand.c13
-rw-r--r--src/main.c4
-rw-r--r--src/mouse.c4
-rw-r--r--src/ops.c20
-rw-r--r--src/option.c44
-rw-r--r--src/option.h22
-rw-r--r--src/optiondefs.h72
-rw-r--r--src/optionstr.c14
-rw-r--r--src/register.c2
-rw-r--r--src/search.c60
-rw-r--r--src/structs.h14
-rw-r--r--src/testdir/test_edit.vim16
-rw-r--r--src/textformat.c13
-rw-r--r--src/version.c14
23 files changed, 73 insertions, 478 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 3234138aeb..88528e9f33 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -290,9 +290,7 @@ open_buffer(
if (curbuf->b_flags & BF_NEVERLOADED)
{
(void)buf_init_chartab(curbuf, FALSE);
-#ifdef FEAT_CINDENT
parse_cino(curbuf);
-#endif
}
// Set/reset the Changed flag first, autocmds may change the buffer.
@@ -2274,7 +2272,7 @@ free_buf_options(
clear_string_option(&buf->b_p_inex);
# endif
#endif
-#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
clear_string_option(&buf->b_p_inde);
clear_string_option(&buf->b_p_indk);
#endif
@@ -2335,14 +2333,10 @@ free_buf_options(
clear_string_option(&buf->b_p_sua);
#endif
clear_string_option(&buf->b_p_ft);
-#ifdef FEAT_CINDENT
clear_string_option(&buf->b_p_cink);
clear_string_option(&buf->b_p_cino);
clear_string_option(&buf->b_p_cinsd);
-#endif
-#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
clear_string_option(&buf->b_p_cinw);
-#endif
clear_string_option(&buf->b_p_cpt);
#ifdef FEAT_COMPL_FUNC
clear_string_option(&buf->b_p_cfu);
@@ -2372,9 +2366,7 @@ free_buf_options(
#endif
buf->b_p_ar = -1;
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
-#ifdef FEAT_LISP
clear_string_option(&buf->b_p_lw);
-#endif
clear_string_option(&buf->b_p_bkc);
clear_string_option(&buf->b_p_menc);
}
diff --git a/src/change.c b/src/change.c
index 2d01f92586..25a96f85c2 100644
--- a/src/change.c
+++ b/src/change.c
@@ -1397,17 +1397,11 @@ open_line(
char_u *p;
int saved_char = NUL; // init for GCC
pos_T *pos;
-#ifdef FEAT_CINDENT
int do_cindent;
-#endif
-#ifdef FEAT_SMARTINDENT
int do_si = may_do_si();
int no_si = FALSE; // reset did_si afterwards
int first_char = NUL; // init for GCC
-#endif
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
int vreplace_mode;
-#endif
int did_append; // appended a new line
int saved_pi = curbuf->b_p_pi; // copy of preserveindent setting
@@ -1453,22 +1447,18 @@ open_line(
if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0)
{
p_extra = saved_line + curwin->w_cursor.col;
-#ifdef FEAT_SMARTINDENT
if (do_si) // need first char after new line break
{
p = skipwhite(p_extra);
first_char = *p;
}
-#endif
extra_len = (int)STRLEN(p_extra);
saved_char = *p_extra;
*p_extra = NUL;
}
u_clearline(); // cannot do "U" command when adding lines
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
-#endif
ai_col = 0;
// If we just did an auto-indent, then we didn't type anything on
@@ -1479,11 +1469,7 @@ open_line(
// If 'autoindent' and/or 'smartindent' is set, try to figure out what
// indent to use for the new line.
- if (curbuf->b_p_ai
-#ifdef FEAT_SMARTINDENT
- || do_si
-#endif
- )
+ if (curbuf->b_p_ai || do_si)
{
// count white space on current line
#ifdef FEAT_VARTABS
@@ -1495,7 +1481,6 @@ open_line(
if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
newindent = second_line_indent; // for ^^D command in insert mode
-#ifdef FEAT_SMARTINDENT
// Do smart indenting.
// In insert/replace mode (only when dir == FORWARD)
// we may move some text to the next line. If it starts with '{'
@@ -1636,22 +1621,19 @@ open_line(
}
if (do_si)
can_si = TRUE;
-#endif // FEAT_SMARTINDENT
did_ai = TRUE;
}
-#ifdef FEAT_CINDENT
// May do indenting after opening a new line.
do_cindent = !p_paste && (curbuf->b_p_cin
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
|| *curbuf->b_p_inde != NUL
-# endif
+#endif
)
&& in_cinkeys(dir == FORWARD
? KEY_OPEN_FORW
: KEY_OPEN_BACK, ' ', linewhite(curwin->w_cursor.lnum));
-#endif
// Find out if the current line starts with a comment leader.
// This may then be inserted in front of the new line.
@@ -1660,7 +1642,6 @@ open_line(
{
lead_len = get_leader_len(saved_line, &lead_flags,
dir == BACKWARD, TRUE);
-#ifdef FEAT_CINDENT
if (lead_len == 0 && curbuf->b_p_cin && do_cindent && dir == FORWARD
&& !has_format_option(FO_NO_OPEN_COMS))
{
@@ -1678,7 +1659,6 @@ open_line(
}
}
}
-#endif
}
else
lead_len = 0;
@@ -1984,11 +1964,7 @@ open_line(
}
// Recompute the indent, it may have changed.
- if (curbuf->b_p_ai
-#ifdef FEAT_SMARTINDENT
- || do_si
-#endif
- )
+ if (curbuf->b_p_ai || do_si)
#ifdef FEAT_VARTABS
newindent = get_indent_str_vtab(leader, curbuf->b_p_ts,
curbuf->b_p_vts_array, FALSE);
@@ -2035,11 +2011,7 @@ open_line(
// if a new indent will be set below, remove the indent that
// is in the comment leader
- if (newindent
-#ifdef FEAT_SMARTINDENT
- || did_si
-#endif
- )
+ if (newindent || did_si)
{
while (lead_len && VIM_ISWHITE(*leader))
{
@@ -2050,9 +2022,7 @@ open_line(
}
}
-#ifdef FEAT_SMARTINDENT
did_si = can_si = FALSE;
-#endif
}
else if (comment_end != NULL)
{
@@ -2061,11 +2031,7 @@ open_line(
// indent to align with the line containing the start of the
// comment.
if (comment_end[0] == '*' && comment_end[1] == '/' &&
- (curbuf->b_p_ai
-#ifdef FEAT_SMARTINDENT
- || do_si
-#endif
- ))
+ (curbuf->b_p_ai || do_si))
{
old_cursor = curwin->w_cursor;
curwin->w_cursor.col = (colnr_T)(comment_end - saved_line);
@@ -2182,14 +2148,9 @@ open_line(
did_append = FALSE;
}
- if (newindent
-#ifdef FEAT_SMARTINDENT
- || did_si
-#endif
- )
+ if (newindent || did_si)
{
++curwin->w_cursor.lnum;
-#ifdef FEAT_SMARTINDENT
if (did_si)
{
int sw = (int)get_sw_value(curbuf);
@@ -2198,7 +2159,6 @@ open_line(
newindent -= newindent % sw;
newindent += sw;
}
-#endif
// Copy the indent
if (curbuf->b_p_ci)
{
@@ -2221,10 +2181,8 @@ open_line(
for (n = 0; n < (int)curwin->w_cursor.col; ++n)
replace_push(NUL);
newcol += curwin->w_cursor.col;
-#ifdef FEAT_SMARTINDENT
if (no_si)
did_si = FALSE;
-#endif
}
// In MODE_REPLACE state, for each character in the extra leader, there
@@ -2278,7 +2236,6 @@ open_line(
curwin->w_cursor.col = newcol;
curwin->w_cursor.coladd = 0;
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
// In MODE_VREPLACE state, we are handling the replace stack ourselves, so
// stop fixthisline() from doing it (via change_indent()) by telling it
// we're in normal MODE_INSERT state.
@@ -2289,8 +2246,7 @@ open_line(
}
else
vreplace_mode = 0;
-#endif
-#ifdef FEAT_LISP
+
// May do lisp indenting.
if (!p_paste
&& leader == NULL
@@ -2300,19 +2256,16 @@ open_line(
fixthisline(get_lisp_indent);
ai_col = (colnr_T)getwhitecols_curline();
}
-#endif
-#ifdef FEAT_CINDENT
+
// May do indenting after opening a new line.
if (do_cindent)
{
do_c_expr_indent();
ai_col = (colnr_T)getwhitecols_curline();
}
-#endif
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
+
if (vreplace_mode != 0)
State = vreplace_mode;
-#endif
// Finally, MODE_VREPLACE gets the stuff on the new line, then puts back
// the original line, and inserts the new stuff char by char, pushing old
diff --git a/src/charset.c b/src/charset.c
index 6fd8b6b54f..34751e1862 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -129,13 +129,11 @@ buf_init_chartab(
SET_CHARTAB(buf, c);
}
-#ifdef FEAT_LISP
/*
* In lisp mode the '-' character is included in keywords.
*/
if (buf->b_p_lisp)
SET_CHARTAB(buf, '-');
-#endif
// Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint'
// options Each option is a list of characters, character numbers or
diff --git a/src/cindent.c b/src/cindent.c
index 2d47e641be..27e8a7b276 100644
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -32,7 +32,6 @@
#define LOOKFOR_JS_KEY 11
#define LOOKFOR_COMMA 12
-#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
/*
* Return TRUE if the string "line" starts with a word from 'cinwords'.
*/
@@ -64,7 +63,6 @@ cin_is_cinword(char_u *line)
}
return retval;
}
-#endif
/*
* Skip to the end of a "string" and a 'c' character.
@@ -148,8 +146,6 @@ is_pos_in_string(char_u *line, colnr_T col)
return !((colnr_T)(p - line) <= col);
}
-#if defined(FEAT_CINDENT) || defined(FEAT_SYN_HL)
-
/*
* Find the start of a comment, not knowing if we are in a comment right now.
* Search starts at w_cursor.lnum and goes backwards.
@@ -254,9 +250,7 @@ ind_find_start_CORS(linenr_T *is_raw) // XXX
}
return comment_pos;
}
-#endif // FEAT_CINDENT || FEAT_SYN_HL
-#if defined(FEAT_CINDENT) || defined(PROTO)
/*
* Return TRUE if C-indenting is on.
@@ -265,9 +259,9 @@ ind_find_start_CORS(linenr_T *is_raw) // XXX
cindent_on(void)
{
return (!p_paste && (curbuf->b_p_cin
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
|| *curbuf->b_p_inde != NUL
-# endif
+#endif
));
}
@@ -4151,7 +4145,6 @@ do_c_expr_indent(void)
# endif
fixthisline(get_c_indent);
}
-#endif
#if defined(FEAT_EVAL) || defined(PROTO)
/*
@@ -4160,7 +4153,6 @@ do_c_expr_indent(void)
void
f_cindent(typval_T *argvars UNUSED, typval_T *rettv)
{
-# ifdef FEAT_CINDENT
pos_T pos;
linenr_T lnum;
@@ -4176,7 +4168,6 @@ f_cindent(typval_T *argvars UNUSED, typval_T *rettv)
curwin->w_cursor = pos;
}
else
-# endif
rettv->vval.v_number = -1;
}
#endif
diff --git a/src/edit.c b/src/edit.c
index 6e76971c35..939aeb9d66 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -84,9 +84,7 @@ static int last_insert_skip; // nr of chars in front of previous insert
static int new_insert_skip; // nr of chars in front of current insert
static int did_restart_edit; // "restart_edit" when calling edit()
-#ifdef FEAT_CINDENT
static int can_cindent; // may do cindenting on this line
-#endif
#ifdef FEAT_RIGHTLEFT
static int revins_on; // reverse insert mode on
@@ -134,9 +132,7 @@ edit(
static linenr_T o_lnum = 0;
int i;
int did_backspace = TRUE; // previous char was backspace
-#ifdef FEAT_CINDENT
int line_is_white = FALSE; // line is empty before insert
-#endif
linenr_T old_topline = 0; // topline before insertion
#ifdef FEAT_DIFF
int old_topfill = -1;
@@ -387,9 +383,7 @@ edit(
ins_need_undo = TRUE;
where_paste_started.lnum = 0;
-#ifdef FEAT_CINDENT
can_cindent = TRUE;
-#endif
#ifdef FEAT_FOLDING
// The cursor line is not in a closed fold, unless 'insertmode' is set or
// restarting.
@@ -742,7 +736,6 @@ edit(
continue;
}
-#ifdef FEAT_CINDENT
if (cindent_on() && ctrl_x_mode_none())
{
// A key name preceded by a bang means this key is not to be
@@ -756,7 +749,6 @@ edit(
&& stop_arrow() == OK)
do_c_expr_indent();
}
-#endif
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl)
@@ -1294,9 +1286,7 @@ docomplete:
disable_fold_update--;
#endif
compl_busy = FALSE;
-#ifdef FEAT_SMARTINDENT
can_si = may_do_si(); // allow smartindenting
-#endif
break;
case Ctrl_Y: // copy from previous line or scroll down
@@ -1346,18 +1336,14 @@ normalchar:
break;
}
#endif
-#ifdef FEAT_SMARTINDENT
// Try to perform smart-indenting.
ins_try_si(c);
-#endif
if (c == ' ')
{
inserted_space = TRUE;
-#ifdef FEAT_CINDENT
if (inindent(0))
can_cindent = FALSE;
-#endif
if (Insstart_blank_vcol == MAXCOL
&& curwin->w_cursor.lnum == Insstart.lnum)
Insstart_blank_vcol = get_nolist_virtcol();
@@ -1402,7 +1388,6 @@ normalchar:
if (arrow_used)
inserted_space = FALSE;
-#ifdef FEAT_CINDENT
if (can_cindent && cindent_on() && ctrl_x_mode_normal())
{
force_cindent:
@@ -1416,7 +1401,6 @@ force_cindent:
do_c_expr_indent();
}
}
-#endif // FEAT_CINDENT
} // for (;;)
// NOTREACHED
@@ -2194,11 +2178,9 @@ insertchar(
end_comment_pending = NUL;
did_ai = FALSE;
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
can_si = FALSE;
can_si_back = FALSE;
-#endif
/*
* If there's any pending input, grab up to INPUT_BUFLEN at once.
@@ -2220,9 +2202,7 @@ insertchar(
&& !has_insertcharpre()
&& vpeekc() != NUL
&& !(State & REPLACE_FLAG)
-#ifdef FEAT_CINDENT
&& !cindent_on()
-#endif
#ifdef FEAT_RIGHTLEFT
&& !p_ri
#endif
@@ -2546,11 +2526,9 @@ stop_insert(
}
}
did_ai = FALSE;
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
can_si = FALSE;
can_si_back = FALSE;
-#endif
// Set '[ and '] to the inserted text. When end_insert_pos is NULL we are
// now in a different buffer.
@@ -3898,14 +3876,10 @@ ins_shift(int c, int lastc)
if (did_ai && *skipwhite(ml_get_curline()) != NUL)
did_ai = FALSE;
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
can_si = FALSE;
can_si_back = FALSE;
-#endif
-#ifdef FEAT_CINDENT
can_cindent = FALSE; // no cindenting after ^D or ^T
-#endif
}
static void
@@ -3935,11 +3909,9 @@ ins_del(void)
else if (del_char(FALSE) == FAIL) // delete char under cursor
vim_beep(BO_BS);
did_ai = FALSE;
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
can_si = FALSE;
can_si_back = FALSE;
-#endif
AppendCharToRedobuff(K_DEL);
}
@@ -3982,9 +3954,7 @@ ins_bs(
int in_indent;
int oldState;
int cpc[MAX_MCO]; // composing characters
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
int call_fix_indent = FALSE;
-#endif
/*
* can't delete anything in an empty file
@@ -4016,10 +3986,8 @@ ins_bs(
if (stop_arrow() == FAIL)
return FALSE;
in_indent = inindent(0);
-#ifdef FEAT_CINDENT
if (in_indent)
can_cindent = FALSE;
-#endif
end_comment_pending = NUL; // After BS, don't auto-end comment
#ifdef FEAT_RIGHTLEFT
if (revins_on) // put cursor after last inserted char
@@ -4153,11 +4121,7 @@ ins_bs(
mincol = 0;
// keep indent
if (mode == BACKSPACE_LINE
- && (curbuf->b_p_ai
-#ifdef FEAT_CINDENT
- || cindent_on()
-#endif
- )
+ && (curbuf->b_p_ai || cindent_on())
#ifdef FEAT_RIGHTLEFT
&& !revins_on
#endif
@@ -4168,10 +4132,8 @@ ins_bs(
if (curwin->w_cursor.col < save_col)
{
mincol = curwin->w_cursor.col;
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
// should now fix the indent to match with the previous line
call_fix_indent = TRUE;
-#endif
}
curwin->w_cursor.col = save_col;
}
@@ -4337,18 +4299,14 @@ ins_bs(
}
did_backspace = TRUE;
}
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
can_si = FALSE;
can_si_back = FALSE;
-#endif
if (curwin->w_cursor.col <= 1)
did_ai = FALSE;
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
if (call_fix_indent)
fix_indent();
-#endif
/*
* It's a little strange to put backspaces into the redo
@@ -4497,9 +4455,7 @@ ins_tabline(int c)
{
undisplay_dollar();
start_arrow(&curwin->w_cursor);
-# ifdef FEAT_CINDENT
can_cindent = TRUE;
-# endif
}
if (c == K_TABLINE)
@@ -4523,9 +4479,7 @@ ins_scroll(void)
if (gui_do_scroll())
{
start_arrow(&tpos);
-# ifdef FEAT_CINDENT
can_cindent = TRUE;
-# endif
}
}
@@ -4539,9 +4493,7 @@ ins_horscroll(void)
if (gui_do_horiz_scroll(scrollbar_value, FALSE))
{
start_arrow(&tpos);
-# ifdef FEAT_CINDENT
can_cindent = TRUE;
-# endif
}
}
#endif
@@ -4748,9 +4700,7 @@ ins_up(
)
redraw_later(VALID);
start_arrow(&tpos);
-#ifdef FEAT_CINDENT
can_cindent = TRUE;
-#endif
}
else
vim_beep(BO_CRSR);
@@ -4778,9 +4728,7 @@ ins_pageup(void)
if (onepage(BACKWARD, 1L) == OK)
{
start_arrow(&tpos);
-#ifdef FEAT_CINDENT
can_cindent = TRUE;
-#endif
}
else
vim_beep(BO_CRSR);
@@ -4809,9 +4757,7 @@ ins_down(
)
redraw_later(VALID);
start_arrow(&tpos);
-#ifdef FEAT_CINDENT
can_cindent = TRUE;
-#endif
}
else
vim_beep(BO_CRSR);
@@ -4839,9 +4785,7 @@ ins_pagedown(void)
if (onepage(FORWARD, 1L) == OK)
{
start_arrow(&tpos);
-#ifdef FEAT_CINDENT
can_cindent = TRUE;
-#endif
}
else
vim_beep(BO_CRSR);
@@ -4872,10 +4816,8 @@ ins_tab(void)
return FALSE;
ind = inindent(0);
-#ifdef FEAT_CINDENT
if (ind)
can_cindent = FALSE;
-#endif
/*
* When nothing special, insert TAB like a normal character.
@@ -4901,11 +4843,9 @@ ins_tab(void)
return TRUE;
did_ai = FALSE;
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
can_si = FALSE;
can_si_back = FALSE;
-#endif
AppendToRedobuff((char_u *)"\t");
#ifdef FEAT_VARTABS
@@ -5173,9 +5113,7 @@ ins_eol(int c)
has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent,
NULL);
old_indent = 0;
-#ifdef FEAT_CINDENT
can_cindent = TRUE;
-#endif
#ifdef FEAT_FOLDING
// When inserting a line the cursor line must never be in a closed fold.
foldOpenCursor();
@@ -5427,7 +5365,6 @@ do_insert_char_pre(int c)
}
#endif
-#if defined(FEAT_CINDENT) || defined(PROTO)
int
get_can_cindent(void)
{
@@ -5439,7 +5376,6 @@ set_can_cindent(int val)
{
can_cindent = val;
}
-#endif
/*
* Trigger "event" and take care of fixing undo.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 35b8984c3c..6abd53a73e 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5476,13 +5476,7 @@ f_has(typval_T *argvars, typval_T *rettv)
0
#endif
},
- {"cindent",
-#ifdef FEAT_CINDENT
- 1
-#else
- 0
-#endif
- },
+ {"cindent", 1},
{"clientserver",
#ifdef FEAT_CLIENTSERVER
1
@@ -5796,13 +5790,7 @@ f_has(typval_T *argvars, typval_T *rettv)
0
#endif
},
- {"lispindent",
-#ifdef FEAT_LISP
- 1
-#else
- 0
-#endif
- },
+ {"lispindent", 1},
{"listcmds", 1},
{"localmap", 1},
{"lua",
@@ -6091,13 +6079,7 @@ f_has(typval_T *argvars, typval_T *rettv)
0
#endif
},
- {"smartindent",
-#ifdef FEAT_SMARTINDENT
- 1
-#else
- 0
-#endif
- },
+ {"smartindent", 1},
{"startuptime",
#ifdef STARTUPTIME
1
diff --git a/src/feature.h b/src/feature.h
index 1a24879816..b02bb9c554 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -111,6 +111,9 @@
* +comments 'comments' option.
* +title 'title' and 'icon' options
* +jumplist Jumplist, CTRL-O and CTRL-I commands.
+ * +lispindent lisp indenting (From Eric Fischer).
+ * +cindent C code indenting (From Eric Fischer).
+ * +smartindent smart C code indenting when the 'si' option is set.
*
* Obsolete:
* +tag_old_static Old style static tags: "file:tag file ..".
@@ -432,25 +435,6 @@
#endif
/*
- * +lispindent lisp indenting (From Eric Fischer).
- * +cindent C code indenting (From Eric Fischer).
- * +smartindent smart C code indenting when the 'si' option is set.
- *
- * These two need to be defined when making prototypes.
- */
-#if defined(FEAT_NORMAL) || defined(PROTO)
-# define FEAT_LISP
-#endif
-
-#if defined(FEAT_NORMAL) || defined(PROTO)
-# define FEAT_CINDENT
-#endif
-
-#ifdef FEAT_NORMAL
-# define FEAT_SMARTINDENT
-#endif
-
-/*
* +cryptv Encryption (by Mohsin Ahmed <mosh@sasi.com>).
*/
#if defined(FEAT_NORMAL) && !defined(FEAT_CRYPT) || defined(PROTO)
diff --git a/src/globals.h b/src/globals.h
index 52b4c053f0..bf098fdedb 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -937,7 +937,6 @@ EXTERN int end_comment_pending INIT(= NUL);
*/
EXTERN int did_syncbind INIT(= FALSE);
-#ifdef FEAT_SMARTINDENT
/*
* This flag is set when a smart indent has been performed. When the next typed
* character is a '{' the inserted tab will be deleted again.
@@ -955,7 +954,6 @@ EXTERN int can_si INIT(= FALSE);
* one indent will be removed.
*/
EXTERN int can_si_back INIT(= FALSE);
-#endif
EXTERN int old_indent INIT(= 0); // for ^^D command in insert mode
diff --git a/src/indent.c b/src/indent.c
index 486259ef2a..ccf4aa8687 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1055,7 +1055,6 @@ inindent(int extra)
return FALSE;
}
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(PROTO)
/*
* op_reindent - handle reindenting a block of lines.
*/
@@ -1092,10 +1091,8 @@ op_reindent(oparg_T *oap, int (*how)(void))
// Be vi-compatible: For lisp indenting the first line is not
// indented, unless there is only one line.
-# ifdef FEAT_LISP
if (i != oap->line_count - 1 || oap->line_count == 1
|| how != get_lisp_indent)
-# endif
{
l = skipwhite(ml_get_curline());
if (*l == NUL) // empty or blank line
@@ -1142,9 +1139,7 @@ op_reindent(oparg_T *oap, int (*how)(void))
curbuf->b_op_end = oap->end;
}
}
-#endif // defined(FEAT_LISP) || defined(FEAT_CINDENT)
-#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) || defined(PROTO)
/*
* Return TRUE if lines starting with '#' should be left aligned.
*/
@@ -1152,22 +1147,12 @@ op_reindent(oparg_T *oap, int (*how)(void))
preprocs_left(void)
{
return
-# ifdef FEAT_SMARTINDENT
-# ifdef FEAT_CINDENT
(curbuf->b_p_si && !curbuf->b_p_cin) ||
-# else
- curbuf->b_p_si
-# endif
-# endif
-# ifdef FEAT_CINDENT
(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE)
&& curbuf->b_ind_hash_comment == 0)
-# endif
;
}
-#endif
-#ifdef FEAT_SMARTINDENT
/*
* Return TRUE if the conditions are OK for smart indenting.
*/
@@ -1175,9 +1160,7 @@ preprocs_left(void)
may_do_si()
{
return curbuf->b_p_si
-# ifdef FEAT_CINDENT
&& !curbuf->b_p_cin
-# endif
# ifdef FEAT_EVAL
&& *curbuf->b_p_inde == NUL
# endif
@@ -1263,7 +1246,6 @@ ins_try_si(int c)
if (ai_col > curwin->w_cursor.col)
ai_col = curwin->w_cursor.col;
}
-#endif
/*
* Insert an indent (for <Tab> or CTRL-T) or delete an indent (for CTRL-D).
@@ -1865,7 +1847,7 @@ ex_retab(exarg_T *eap)
u_clearline();
}
-#if (defined(FEAT_CINDENT) && defined(FEAT_EVAL)) || defined(PROTO)
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Get indent level from 'indentexpr'.
*/
@@ -1933,8 +1915,6 @@ get_expr_indent(void)
}
#endif
-#if defined(FEAT_LISP) || defined(PROTO)
-
static int
lisp_match(char_u *p)
{
@@ -2150,9 +2130,7 @@ get_lisp_indent(void)
return amount;
}
-#endif // FEAT_LISP
-#if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(PROTO)
/*
* Re-indent the current line, based on the current contents of it and the
* surrounding lines. Fixing the cursor position seems really easy -- I'm very
@@ -2181,19 +2159,12 @@ fix_indent(void)
{
if (p_paste)
return;
-# ifdef FEAT_LISP
if (curbuf->b_p_lisp && curbuf->b_p_ai)
fixthisline(get_lisp_indent);
-# endif
-# if defined(FEAT_LISP) && defined(FEAT_CINDENT)
else
-# endif
-# ifdef FEAT_CINDENT
if (cindent_on())
do_c_expr_indent();
-# endif
}
-#endif
#if defined(FEAT_EVAL) || defined(PROTO)
/*
@@ -2224,7 +2195,6 @@ f_indent(typval_T *argvars, typval_T *rettv)
void
f_lispindent(typval_T *argvars UNUSED, typval_T *rettv)
{
-# ifdef FEAT_LISP
pos_T pos;
linenr_T lnum;
@@ -2242,7 +2212,6 @@ f_lispindent(typval_T *argvars UNUSED, typval_T *rettv)
else if (in_vim9script())
semsg(_(e_invalid_line_number_nr), lnum);
else
-# endif
rettv->vval.v_number = -1;
}
#endif
diff --git a/src/insexpand.c b/src/insexpand.c
index 6e38098642..fd1218fd75 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -263,9 +263,7 @@ ins_ctrl_x(void)
/*
* Functions to check the current CTRL-X mode.
*/
-#ifdef FEAT_CINDENT
int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; }
-#endif
int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; }
int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; }
int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; }
@@ -2151,9 +2149,7 @@ set_ctrl_x_mode(int c)
ins_compl_stop(int c, int prev_mode, int retval)
{
char_u *ptr;
-#ifdef FEAT_CINDENT
int want_cindent;
-#endif
// Get here when we have finished typing a sequence of ^N and
// ^P or other completion characters in CTRL-X mode. Free up
@@ -2173,21 +2169,18 @@ ins_compl_stop(int c, int prev_mode, int retval)
ins_compl_fixRedoBufForLeader(ptr);
}
-#ifdef FEAT_CINDENT
want_cindent = (get_can_cindent() && cindent_on());
-#endif
+
// When completing whole lines: fix indent for 'cindent'.
// Otherwise, break line if it's too long.
if (compl_cont_mode == CTRL_X_WHOLE_LINE)
{
-#ifdef FEAT_CINDENT
// re-indent the current line
if (want_cindent)
{
do_c_expr_indent();
want_cindent = FALSE; // don't do it again
}
-#endif
}
else
{
@@ -2251,11 +2244,9 @@ ins_compl_stop(int c, int prev_mode, int retval)
// command line window.
update_screen(0);
#endif
-#ifdef FEAT_CINDENT
// Indent now if a key was typed that is in 'cinkeys'.
if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0)))
do_c_expr_indent();
-#endif
// Trigger the CompleteDone event to give scripts a chance to act
// upon the end of completion.
ins_apply_autocmds(EVENT_COMPLETEDONE);
@@ -4738,11 +4729,9 @@ ins_compl_start(void)
// First time we hit ^N or ^P (in a row, I mean)
did_ai = FALSE;
-#ifdef FEAT_SMARTINDENT
did_si = FALSE;
can_si = FALSE;
can_si_back = FALSE;
-#endif
if (stop_arrow() == FAIL)
return FAIL;
diff --git a/src/mai