Mercurial > vim
comparison src/edit.c @ 28942:6cdf55afaae9 v8.2.4993
patch 8.2.4993: smart/C/lisp indenting is optional
Commit: https://github.com/vim/vim/commit/8e145b82464a21ee4fdf7948f04e2a1d505f8bfa
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 21 20:17:31 2022 +0100
patch 8.2.4993: smart/C/lisp indenting is optional
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 21 May 2022 21:30:04 +0200 |
parents | aa44d5842d6c |
children | 45c182c4f7e9 |
comparison
equal
deleted
inserted
replaced
28941:f17de8647585 | 28942:6cdf55afaae9 |
---|---|
82 // K_SPECIAL and CSI are escaped | 82 // K_SPECIAL and CSI are escaped |
83 static int last_insert_skip; // nr of chars in front of previous insert | 83 static int last_insert_skip; // nr of chars in front of previous insert |
84 static int new_insert_skip; // nr of chars in front of current insert | 84 static int new_insert_skip; // nr of chars in front of current insert |
85 static int did_restart_edit; // "restart_edit" when calling edit() | 85 static int did_restart_edit; // "restart_edit" when calling edit() |
86 | 86 |
87 #ifdef FEAT_CINDENT | |
88 static int can_cindent; // may do cindenting on this line | 87 static int can_cindent; // may do cindenting on this line |
89 #endif | |
90 | 88 |
91 #ifdef FEAT_RIGHTLEFT | 89 #ifdef FEAT_RIGHTLEFT |
92 static int revins_on; // reverse insert mode on | 90 static int revins_on; // reverse insert mode on |
93 static int revins_chars; // how much to skip after edit | 91 static int revins_chars; // how much to skip after edit |
94 static int revins_legal; // was the last char 'legal'? | 92 static int revins_legal; // was the last char 'legal'? |
132 int lastc = 0; | 130 int lastc = 0; |
133 int mincol; | 131 int mincol; |
134 static linenr_T o_lnum = 0; | 132 static linenr_T o_lnum = 0; |
135 int i; | 133 int i; |
136 int did_backspace = TRUE; // previous char was backspace | 134 int did_backspace = TRUE; // previous char was backspace |
137 #ifdef FEAT_CINDENT | |
138 int line_is_white = FALSE; // line is empty before insert | 135 int line_is_white = FALSE; // line is empty before insert |
139 #endif | |
140 linenr_T old_topline = 0; // topline before insertion | 136 linenr_T old_topline = 0; // topline before insertion |
141 #ifdef FEAT_DIFF | 137 #ifdef FEAT_DIFF |
142 int old_topfill = -1; | 138 int old_topfill = -1; |
143 #endif | 139 #endif |
144 int inserted_space = FALSE; // just inserted a space | 140 int inserted_space = FALSE; // just inserted a space |
385 | 381 |
386 // Need to save the line for undo before inserting the first char. | 382 // Need to save the line for undo before inserting the first char. |
387 ins_need_undo = TRUE; | 383 ins_need_undo = TRUE; |
388 | 384 |
389 where_paste_started.lnum = 0; | 385 where_paste_started.lnum = 0; |
390 #ifdef FEAT_CINDENT | |
391 can_cindent = TRUE; | 386 can_cindent = TRUE; |
392 #endif | |
393 #ifdef FEAT_FOLDING | 387 #ifdef FEAT_FOLDING |
394 // The cursor line is not in a closed fold, unless 'insertmode' is set or | 388 // The cursor line is not in a closed fold, unless 'insertmode' is set or |
395 // restarting. | 389 // restarting. |
396 if (!p_im && did_restart_edit == 0) | 390 if (!p_im && did_restart_edit == 0) |
397 foldOpenCursor(); | 391 foldOpenCursor(); |
740 ins_ctrl_v(); | 734 ins_ctrl_v(); |
741 c = Ctrl_V; // pretend CTRL-V is last typed character | 735 c = Ctrl_V; // pretend CTRL-V is last typed character |
742 continue; | 736 continue; |
743 } | 737 } |
744 | 738 |
745 #ifdef FEAT_CINDENT | |
746 if (cindent_on() && ctrl_x_mode_none()) | 739 if (cindent_on() && ctrl_x_mode_none()) |
747 { | 740 { |
748 // A key name preceded by a bang means this key is not to be | 741 // A key name preceded by a bang means this key is not to be |
749 // inserted. Skip ahead to the re-indenting below. | 742 // inserted. Skip ahead to the re-indenting below. |
750 // A key name preceded by a star means that indenting has to be | 743 // A key name preceded by a star means that indenting has to be |
754 goto force_cindent; | 747 goto force_cindent; |
755 if (can_cindent && in_cinkeys(c, '*', line_is_white) | 748 if (can_cindent && in_cinkeys(c, '*', line_is_white) |
756 && stop_arrow() == OK) | 749 && stop_arrow() == OK) |
757 do_c_expr_indent(); | 750 do_c_expr_indent(); |
758 } | 751 } |
759 #endif | |
760 | 752 |
761 #ifdef FEAT_RIGHTLEFT | 753 #ifdef FEAT_RIGHTLEFT |
762 if (curwin->w_p_rl) | 754 if (curwin->w_p_rl) |
763 switch (c) | 755 switch (c) |
764 { | 756 { |
1292 compl_status_clear(); | 1284 compl_status_clear(); |
1293 #ifdef FEAT_FOLDING | 1285 #ifdef FEAT_FOLDING |
1294 disable_fold_update--; | 1286 disable_fold_update--; |
1295 #endif | 1287 #endif |
1296 compl_busy = FALSE; | 1288 compl_busy = FALSE; |
1297 #ifdef FEAT_SMARTINDENT | |
1298 can_si = may_do_si(); // allow smartindenting | 1289 can_si = may_do_si(); // allow smartindenting |
1299 #endif | |
1300 break; | 1290 break; |
1301 | 1291 |
1302 case Ctrl_Y: // copy from previous line or scroll down | 1292 case Ctrl_Y: // copy from previous line or scroll down |
1303 case Ctrl_E: // copy from next line or scroll up | 1293 case Ctrl_E: // copy from next line or scroll up |
1304 c = ins_ctrl_ey(c); | 1294 c = ins_ctrl_ey(c); |
1344 // then don't insert any character. | 1334 // then don't insert any character. |
1345 if (c == NUL) | 1335 if (c == NUL) |
1346 break; | 1336 break; |
1347 } | 1337 } |
1348 #endif | 1338 #endif |
1349 #ifdef FEAT_SMARTINDENT | |
1350 // Try to perform smart-indenting. | 1339 // Try to perform smart-indenting. |
1351 ins_try_si(c); | 1340 ins_try_si(c); |
1352 #endif | |
1353 | 1341 |
1354 if (c == ' ') | 1342 if (c == ' ') |
1355 { | 1343 { |
1356 inserted_space = TRUE; | 1344 inserted_space = TRUE; |
1357 #ifdef FEAT_CINDENT | |
1358 if (inindent(0)) | 1345 if (inindent(0)) |
1359 can_cindent = FALSE; | 1346 can_cindent = FALSE; |
1360 #endif | |
1361 if (Insstart_blank_vcol == MAXCOL | 1347 if (Insstart_blank_vcol == MAXCOL |
1362 && curwin->w_cursor.lnum == Insstart.lnum) | 1348 && curwin->w_cursor.lnum == Insstart.lnum) |
1363 Insstart_blank_vcol = get_nolist_virtcol(); | 1349 Insstart_blank_vcol = get_nolist_virtcol(); |
1364 } | 1350 } |
1365 | 1351 |
1400 | 1386 |
1401 // If the cursor was moved we didn't just insert a space | 1387 // If the cursor was moved we didn't just insert a space |
1402 if (arrow_used) | 1388 if (arrow_used) |
1403 inserted_space = FALSE; | 1389 inserted_space = FALSE; |
1404 | 1390 |
1405 #ifdef FEAT_CINDENT | |
1406 if (can_cindent && cindent_on() && ctrl_x_mode_normal()) | 1391 if (can_cindent && cindent_on() && ctrl_x_mode_normal()) |
1407 { | 1392 { |
1408 force_cindent: | 1393 force_cindent: |
1409 /* | 1394 /* |
1410 * Indent now if a key was typed that is in 'cinkeys'. | 1395 * Indent now if a key was typed that is in 'cinkeys'. |
1414 if (stop_arrow() == OK) | 1399 if (stop_arrow() == OK) |
1415 // re-indent the current line | 1400 // re-indent the current line |
1416 do_c_expr_indent(); | 1401 do_c_expr_indent(); |
1417 } | 1402 } |
1418 } | 1403 } |
1419 #endif // FEAT_CINDENT | |
1420 | 1404 |
1421 } // for (;;) | 1405 } // for (;;) |
1422 // NOTREACHED | 1406 // NOTREACHED |
1423 } | 1407 } |
1424 | 1408 |
2192 } | 2176 } |
2193 } | 2177 } |
2194 end_comment_pending = NUL; | 2178 end_comment_pending = NUL; |
2195 | 2179 |
2196 did_ai = FALSE; | 2180 did_ai = FALSE; |
2197 #ifdef FEAT_SMARTINDENT | |
2198 did_si = FALSE; | 2181 did_si = FALSE; |
2199 can_si = FALSE; | 2182 can_si = FALSE; |
2200 can_si_back = FALSE; | 2183 can_si_back = FALSE; |
2201 #endif | |
2202 | 2184 |
2203 /* | 2185 /* |
2204 * If there's any pending input, grab up to INPUT_BUFLEN at once. | 2186 * If there's any pending input, grab up to INPUT_BUFLEN at once. |
2205 * This speeds up normal text input considerably. | 2187 * This speeds up normal text input considerably. |
2206 * Don't do this when 'cindent' or 'indentexpr' is set, because we might | 2188 * Don't do this when 'cindent' or 'indentexpr' is set, because we might |
2218 if ( !ISSPECIAL(c) | 2200 if ( !ISSPECIAL(c) |
2219 && (!has_mbyte || (*mb_char2len)(c) == 1) | 2201 && (!has_mbyte || (*mb_char2len)(c) == 1) |
2220 && !has_insertcharpre() | 2202 && !has_insertcharpre() |
2221 && vpeekc() != NUL | 2203 && vpeekc() != NUL |
2222 && !(State & REPLACE_FLAG) | 2204 && !(State & REPLACE_FLAG) |
2223 #ifdef FEAT_CINDENT | |
2224 && !cindent_on() | 2205 && !cindent_on() |
2225 #endif | |
2226 #ifdef FEAT_RIGHTLEFT | 2206 #ifdef FEAT_RIGHTLEFT |
2227 && !p_ri | 2207 && !p_ri |
2228 #endif | 2208 #endif |
2229 ) | 2209 ) |
2230 { | 2210 { |
2544 if (VIsual_active) | 2524 if (VIsual_active) |
2545 check_visual_pos(); | 2525 check_visual_pos(); |
2546 } | 2526 } |
2547 } | 2527 } |
2548 did_ai = FALSE; | 2528 did_ai = FALSE; |
2549 #ifdef FEAT_SMARTINDENT | |
2550 did_si = FALSE; | 2529 did_si = FALSE; |
2551 can_si = FALSE; | 2530 can_si = FALSE; |
2552 can_si_back = FALSE; | 2531 can_si_back = FALSE; |
2553 #endif | |
2554 | 2532 |
2555 // Set '[ and '] to the inserted text. When end_insert_pos is NULL we are | 2533 // Set '[ and '] to the inserted text. When end_insert_pos is NULL we are |
2556 // now in a different buffer. | 2534 // now in a different buffer. |
2557 if (end_insert_pos != NULL) | 2535 if (end_insert_pos != NULL) |
2558 { | 2536 { |
3896 else | 3874 else |
3897 change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE); | 3875 change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE); |
3898 | 3876 |
3899 if (did_ai && *skipwhite(ml_get_curline()) != NUL) | 3877 if (did_ai && *skipwhite(ml_get_curline()) != NUL) |
3900 did_ai = FALSE; | 3878 did_ai = FALSE; |
3901 #ifdef FEAT_SMARTINDENT | |
3902 did_si = FALSE; | 3879 did_si = FALSE; |
3903 can_si = FALSE; | 3880 can_si = FALSE; |
3904 can_si_back = FALSE; | 3881 can_si_back = FALSE; |
3905 #endif | |
3906 #ifdef FEAT_CINDENT | |
3907 can_cindent = FALSE; // no cindenting after ^D or ^T | 3882 can_cindent = FALSE; // no cindenting after ^D or ^T |
3908 #endif | |
3909 } | 3883 } |
3910 | 3884 |
3911 static void | 3885 static void |
3912 ins_del(void) | 3886 ins_del(void) |
3913 { | 3887 { |
3933 } | 3907 } |
3934 } | 3908 } |
3935 else if (del_char(FALSE) == FAIL) // delete char under cursor | 3909 else if (del_char(FALSE) == FAIL) // delete char under cursor |
3936 vim_beep(BO_BS); | 3910 vim_beep(BO_BS); |
3937 did_ai = FALSE; | 3911 did_ai = FALSE; |
3938 #ifdef FEAT_SMARTINDENT | |
3939 did_si = FALSE; | 3912 did_si = FALSE; |
3940 can_si = FALSE; | 3913 can_si = FALSE; |
3941 can_si_back = FALSE; | 3914 can_si_back = FALSE; |
3942 #endif | |
3943 AppendCharToRedobuff(K_DEL); | 3915 AppendCharToRedobuff(K_DEL); |
3944 } | 3916 } |
3945 | 3917 |
3946 /* | 3918 /* |
3947 * Delete one character for ins_bs(). | 3919 * Delete one character for ins_bs(). |
3980 colnr_T mincol; | 3952 colnr_T mincol; |
3981 int did_backspace = FALSE; | 3953 int did_backspace = FALSE; |
3982 int in_indent; | 3954 int in_indent; |
3983 int oldState; | 3955 int oldState; |
3984 int cpc[MAX_MCO]; // composing characters | 3956 int cpc[MAX_MCO]; // composing characters |
3985 #if defined(FEAT_LISP) || defined(FEAT_CINDENT) | |
3986 int call_fix_indent = FALSE; | 3957 int call_fix_indent = FALSE; |
3987 #endif | |
3988 | 3958 |
3989 /* | 3959 /* |
3990 * can't delete anything in an empty file | 3960 * can't delete anything in an empty file |
3991 * can't backup past first character in buffer | 3961 * can't backup past first character in buffer |
3992 * can't backup past starting point unless 'backspace' > 1 | 3962 * can't backup past starting point unless 'backspace' > 1 |
4014 } | 3984 } |
4015 | 3985 |
4016 if (stop_arrow() == FAIL) | 3986 if (stop_arrow() == FAIL) |
4017 return FALSE; | 3987 return FALSE; |
4018 in_indent = inindent(0); | 3988 in_indent = inindent(0); |
4019 #ifdef FEAT_CINDENT | |
4020 if (in_indent) | 3989 if (in_indent) |
4021 can_cindent = FALSE; | 3990 can_cindent = FALSE; |
4022 #endif | |
4023 end_comment_pending = NUL; // After BS, don't auto-end comment | 3991 end_comment_pending = NUL; // After BS, don't auto-end comment |
4024 #ifdef FEAT_RIGHTLEFT | 3992 #ifdef FEAT_RIGHTLEFT |
4025 if (revins_on) // put cursor after last inserted char | 3993 if (revins_on) // put cursor after last inserted char |
4026 inc_cursor(); | 3994 inc_cursor(); |
4027 #endif | 3995 #endif |
4151 dec_cursor(); | 4119 dec_cursor(); |
4152 #endif | 4120 #endif |
4153 mincol = 0; | 4121 mincol = 0; |
4154 // keep indent | 4122 // keep indent |
4155 if (mode == BACKSPACE_LINE | 4123 if (mode == BACKSPACE_LINE |
4156 && (curbuf->b_p_ai | 4124 && (curbuf->b_p_ai || cindent_on()) |
4157 #ifdef FEAT_CINDENT | |
4158 || cindent_on() | |
4159 #endif | |
4160 ) | |
4161 #ifdef FEAT_RIGHTLEFT | 4125 #ifdef FEAT_RIGHTLEFT |
4162 && !revins_on | 4126 && !revins_on |
4163 #endif | 4127 #endif |
4164 ) | 4128 ) |
4165 { | 4129 { |
4166 save_col = curwin->w_cursor.col; | 4130 save_col = curwin->w_cursor.col; |
4167 beginline(BL_WHITE); | 4131 beginline(BL_WHITE); |
4168 if (curwin->w_cursor.col < save_col) | 4132 if (curwin->w_cursor.col < save_col) |
4169 { | 4133 { |
4170 mincol = curwin->w_cursor.col; | 4134 mincol = curwin->w_cursor.col; |
4171 #if defined(FEAT_LISP) || defined(FEAT_CINDENT) | |
4172 // should now fix the indent to match with the previous line | 4135 // should now fix the indent to match with the previous line |
4173 call_fix_indent = TRUE; | 4136 call_fix_indent = TRUE; |
4174 #endif | |
4175 } | 4137 } |
4176 curwin->w_cursor.col = save_col; | 4138 curwin->w_cursor.col = save_col; |
4177 } | 4139 } |
4178 | 4140 |
4179 /* | 4141 /* |
4335 || curwin->w_cursor.col != Insstart_orig.col) | 4297 || curwin->w_cursor.col != Insstart_orig.col) |
4336 ))); | 4298 ))); |
4337 } | 4299 } |
4338 did_backspace = TRUE; | 4300 did_backspace = TRUE; |
4339 } | 4301 } |
4340 #ifdef FEAT_SMARTINDENT | |
4341 did_si = FALSE; | 4302 did_si = FALSE; |
4342 can_si = FALSE; | 4303 can_si = FALSE; |
4343 can_si_back = FALSE; | 4304 can_si_back = FALSE; |
4344 #endif | |
4345 if (curwin->w_cursor.col <= 1) | 4305 if (curwin->w_cursor.col <= 1) |
4346 did_ai = FALSE; | 4306 did_ai = FALSE; |
4347 | 4307 |
4348 #if defined(FEAT_LISP) || defined(FEAT_CINDENT) | |
4349 if (call_fix_indent) | 4308 if (call_fix_indent) |
4350 fix_indent(); | 4309 fix_indent(); |
4351 #endif | |
4352 | 4310 |
4353 /* | 4311 /* |
4354 * It's a little strange to put backspaces into the redo | 4312 * It's a little strange to put backspaces into the redo |
4355 * buffer, but it makes auto-indent a lot easier to deal | 4313 * buffer, but it makes auto-indent a lot easier to deal |
4356 * with. | 4314 * with. |
4495 if (c != K_TABMENU || current_tabmenu != TABLINE_MENU_CLOSE | 4453 if (c != K_TABMENU || current_tabmenu != TABLINE_MENU_CLOSE |
4496 || (current_tab != 0 && current_tab != tabpage_index(curtab))) | 4454 || (current_tab != 0 && current_tab != tabpage_index(curtab))) |
4497 { | 4455 { |
4498 undisplay_dollar(); | 4456 undisplay_dollar(); |
4499 start_arrow(&curwin->w_cursor); | 4457 start_arrow(&curwin->w_cursor); |
4500 # ifdef FEAT_CINDENT | |
4501 can_cindent = TRUE; | 4458 can_cindent = TRUE; |
4502 # endif | |
4503 } | 4459 } |
4504 | 4460 |
4505 if (c == K_TABLINE) | 4461 if (c == K_TABLINE) |
4506 goto_tabpage(current_tab); | 4462 goto_tabpage(current_tab); |
4507 else | 4463 else |
4521 undisplay_dollar(); | 4477 undisplay_dollar(); |
4522 tpos = curwin->w_cursor; | 4478 tpos = curwin->w_cursor; |
4523 if (gui_do_scroll()) | 4479 if (gui_do_scroll()) |
4524 { | 4480 { |
4525 start_arrow(&tpos); | 4481 start_arrow(&tpos); |
4526 # ifdef FEAT_CINDENT | |
4527 can_cindent = TRUE; | 4482 can_cindent = TRUE; |
4528 # endif | |
4529 } | 4483 } |
4530 } | 4484 } |
4531 | 4485 |
4532 void | 4486 void |
4533 ins_horscroll(void) | 4487 ins_horscroll(void) |
4537 undisplay_dollar(); | 4491 undisplay_dollar(); |
4538 tpos = curwin->w_cursor; | 4492 tpos = curwin->w_cursor; |
4539 if (gui_do_horiz_scroll(scrollbar_value, FALSE)) | 4493 if (gui_do_horiz_scroll(scrollbar_value, FALSE)) |
4540 { | 4494 { |
4541 start_arrow(&tpos); | 4495 start_arrow(&tpos); |
4542 # ifdef FEAT_CINDENT | |
4543 can_cindent = TRUE; | 4496 can_cindent = TRUE; |
4544 # endif | |
4545 } | 4497 } |
4546 } | 4498 } |
4547 #endif | 4499 #endif |
4548 | 4500 |
4549 static void | 4501 static void |
4746 || old_topfill != curwin->w_topfill | 4698 || old_topfill != curwin->w_topfill |
4747 #endif | 4699 #endif |
4748 ) | 4700 ) |
4749 redraw_later(VALID); | 4701 redraw_later(VALID); |
4750 start_arrow(&tpos); | 4702 start_arrow(&tpos); |
4751 #ifdef FEAT_CINDENT | |
4752 can_cindent = TRUE; | 4703 can_cindent = TRUE; |
4753 #endif | |
4754 } | 4704 } |
4755 else | 4705 else |
4756 vim_beep(BO_CRSR); | 4706 vim_beep(BO_CRSR); |
4757 } | 4707 } |
4758 | 4708 |
4776 | 4726 |
4777 tpos = curwin->w_cursor; | 4727 tpos = curwin->w_cursor; |
4778 if (onepage(BACKWARD, 1L) == OK) | 4728 if (onepage(BACKWARD, 1L) == OK) |
4779 { | 4729 { |
4780 start_arrow(&tpos); | 4730 start_arrow(&tpos); |
4781 #ifdef FEAT_CINDENT | |
4782 can_cindent = TRUE; | 4731 can_cindent = TRUE; |
4783 #endif | |
4784 } | 4732 } |
4785 else | 4733 else |
4786 vim_beep(BO_CRSR); | 4734 vim_beep(BO_CRSR); |
4787 } | 4735 } |
4788 | 4736 |
4807 || old_topfill != curwin->w_topfill | 4755 || old_topfill != curwin->w_topfill |
4808 #endif | 4756 #endif |
4809 ) | 4757 ) |
4810 redraw_later(VALID); | 4758 redraw_later(VALID); |
4811 start_arrow(&tpos); | 4759 start_arrow(&tpos); |
4812 #ifdef FEAT_CINDENT | |
4813 can_cindent = TRUE; | 4760 can_cindent = TRUE; |
4814 #endif | |
4815 } | 4761 } |
4816 else | 4762 else |
4817 vim_beep(BO_CRSR); | 4763 vim_beep(BO_CRSR); |
4818 } | 4764 } |
4819 | 4765 |
4837 | 4783 |
4838 tpos = curwin->w_cursor; | 4784 tpos = curwin->w_cursor; |
4839 if (onepage(FORWARD, 1L) == OK) | 4785 if (onepage(FORWARD, 1L) == OK) |
4840 { | 4786 { |
4841 start_arrow(&tpos); | 4787 start_arrow(&tpos); |
4842 #ifdef FEAT_CINDENT | |
4843 can_cindent = TRUE; | 4788 can_cindent = TRUE; |
4844 #endif | |
4845 } | 4789 } |
4846 else | 4790 else |
4847 vim_beep(BO_CRSR); | 4791 vim_beep(BO_CRSR); |
4848 } | 4792 } |
4849 | 4793 |
4870 Insstart_blank_vcol = get_nolist_virtcol(); | 4814 Insstart_blank_vcol = get_nolist_virtcol(); |
4871 if (echeck_abbr(TAB + ABBR_OFF)) | 4815 if (echeck_abbr(TAB + ABBR_OFF)) |
4872 return FALSE; | 4816 return FALSE; |
4873 | 4817 |
4874 ind = inindent(0); | 4818 ind = inindent(0); |
4875 #ifdef FEAT_CINDENT | |
4876 if (ind) | 4819 if (ind) |
4877 can_cindent = FALSE; | 4820 can_cindent = FALSE; |
4878 #endif | |
4879 | 4821 |
4880 /* | 4822 /* |
4881 * When nothing special, insert TAB like a normal character. | 4823 * When nothing special, insert TAB like a normal character. |
4882 */ | 4824 */ |
4883 if (!curbuf->b_p_et | 4825 if (!curbuf->b_p_et |
4899 | 4841 |
4900 if (stop_arrow() == FAIL) | 4842 if (stop_arrow() == FAIL) |
4901 return TRUE; | 4843 return TRUE; |
4902 | 4844 |
4903 did_ai = FALSE; | 4845 did_ai = FALSE; |
4904 #ifdef FEAT_SMARTINDENT | |
4905 did_si = FALSE; | 4846 did_si = FALSE; |
4906 can_si = FALSE; | 4847 can_si = FALSE; |
4907 can_si_back = FALSE; | 4848 can_si_back = FALSE; |
4908 #endif | |
4909 AppendToRedobuff((char_u *)"\t"); | 4849 AppendToRedobuff((char_u *)"\t"); |
4910 | 4850 |
4911 #ifdef FEAT_VARTABS | 4851 #ifdef FEAT_VARTABS |
4912 if (p_sta && ind) // insert tab in indent, use 'shiftwidth' | 4852 if (p_sta && ind) // insert tab in indent, use 'shiftwidth' |
4913 { | 4853 { |
5171 AppendToRedobuff(NL_STR); | 5111 AppendToRedobuff(NL_STR); |
5172 i = open_line(FORWARD, | 5112 i = open_line(FORWARD, |
5173 has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent, | 5113 has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent, |
5174 NULL); | 5114 NULL); |
5175 old_indent = 0; | 5115 old_indent = 0; |
5176 #ifdef FEAT_CINDENT | |
5177 can_cindent = TRUE; | 5116 can_cindent = TRUE; |
5178 #endif | |
5179 #ifdef FEAT_FOLDING | 5117 #ifdef FEAT_FOLDING |
5180 // When inserting a line the cursor line must never be in a closed fold. | 5118 // When inserting a line the cursor line must never be in a closed fold. |
5181 foldOpenCursor(); | 5119 foldOpenCursor(); |
5182 #endif | 5120 #endif |
5183 | 5121 |
5425 | 5363 |
5426 return res; | 5364 return res; |
5427 } | 5365 } |
5428 #endif | 5366 #endif |
5429 | 5367 |
5430 #if defined(FEAT_CINDENT) || defined(PROTO) | |
5431 int | 5368 int |
5432 get_can_cindent(void) | 5369 get_can_cindent(void) |
5433 { | 5370 { |
5434 return can_cindent; | 5371 return can_cindent; |
5435 } | 5372 } |
5437 void | 5374 void |
5438 set_can_cindent(int val) | 5375 set_can_cindent(int val) |
5439 { | 5376 { |
5440 can_cindent = val; | 5377 can_cindent = val; |
5441 } | 5378 } |
5442 #endif | |
5443 | 5379 |
5444 /* | 5380 /* |
5445 * Trigger "event" and take care of fixing undo. | 5381 * Trigger "event" and take care of fixing undo. |
5446 */ | 5382 */ |
5447 int | 5383 int |