comparison src/textformat.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 d0241e74bfdb
children 864fa5276e78
comparison
equal deleted inserted replaced
28941:f17de8647585 28942:6cdf55afaae9
106 if (do_comments) 106 if (do_comments)
107 { 107 {
108 char_u *line = ml_get_curline(); 108 char_u *line = ml_get_curline();
109 109
110 leader_len = get_leader_len(line, NULL, FALSE, TRUE); 110 leader_len = get_leader_len(line, NULL, FALSE, TRUE);
111 #ifdef FEAT_CINDENT
112 if (leader_len == 0 && curbuf->b_p_cin) 111 if (leader_len == 0 && curbuf->b_p_cin)
113 { 112 {
114 int comment_start; 113 int comment_start;
115 114
116 // Check for a line comment after code. 115 // Check for a line comment after code.
121 line + comment_start, NULL, FALSE, TRUE); 120 line + comment_start, NULL, FALSE, TRUE);
122 if (leader_len != 0) 121 if (leader_len != 0)
123 leader_len += comment_start; 122 leader_len += comment_start;
124 } 123 }
125 } 124 }
126 #endif
127 } 125 }
128 else 126 else
129 leader_len = 0; 127 leader_len = 0;
130 128
131 // If the line doesn't start with a comment leader, then don't 129 // If the line doesn't start with a comment leader, then don't
442 if (curwin->w_cursor.col > len) 440 if (curwin->w_cursor.col > len)
443 curwin->w_cursor.col = len; 441 curwin->w_cursor.col = len;
444 } 442 }
445 443
446 haveto_redraw = TRUE; 444 haveto_redraw = TRUE;
447 #ifdef FEAT_CINDENT
448 set_can_cindent(TRUE); 445 set_can_cindent(TRUE);
449 #endif
450 // moved the cursor, don't autoindent or cindent now 446 // moved the cursor, don't autoindent or cindent now
451 did_ai = FALSE; 447 did_ai = FALSE;
452 #ifdef FEAT_SMARTINDENT
453 did_si = FALSE; 448 did_si = FALSE;
454 can_si = FALSE; 449 can_si = FALSE;
455 can_si_back = FALSE; 450 can_si_back = FALSE;
456 #endif
457 line_breakcheck(); 451 line_breakcheck();
458 } 452 }
459 453
460 if (save_char != NUL) // put back space after cursor 454 if (save_char != NUL) // put back space after cursor
461 pchar_cursor(save_char); 455 pchar_cursor(save_char);
1117 // number of tabs and spaces, according to current options. 1111 // number of tabs and spaces, according to current options.
1118 // For the very first formatted line keep the current 1112 // For the very first formatted line keep the current
1119 // indent. 1113 // indent.
1120 if (curwin->w_cursor.lnum == first_line) 1114 if (curwin->w_cursor.lnum == first_line)
1121 indent = get_indent(); 1115 indent = get_indent();
1122 else 1116 else if (curbuf->b_p_lisp)
1123 # ifdef FEAT_LISP
1124 if (curbuf->b_p_lisp)
1125 indent = get_lisp_indent(); 1117 indent = get_lisp_indent();
1126 else 1118 else
1127 # endif
1128 { 1119 {
1129 #ifdef FEAT_CINDENT
1130 if (cindent_on()) 1120 if (cindent_on())
1131 { 1121 {
1132 indent = 1122 indent =
1133 # ifdef FEAT_EVAL 1123 # ifdef FEAT_EVAL
1134 *curbuf->b_p_inde != NUL ? get_expr_indent() : 1124 *curbuf->b_p_inde != NUL ? get_expr_indent() :
1135 # endif 1125 # endif
1136 get_c_indent(); 1126 get_c_indent();
1137 } 1127 }
1138 else 1128 else
1139 #endif
1140 indent = get_indent(); 1129 indent = get_indent();
1141 } 1130 }
1142 (void)set_indent(indent, SIN_CHANGED); 1131 (void)set_indent(indent, SIN_CHANGED);
1143 } 1132 }
1144 1133