comparison src/insexpand.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 7d28903e80df
comparison
equal deleted inserted replaced
28941:f17de8647585 28942:6cdf55afaae9
261 } 261 }
262 262
263 /* 263 /*
264 * Functions to check the current CTRL-X mode. 264 * Functions to check the current CTRL-X mode.
265 */ 265 */
266 #ifdef FEAT_CINDENT
267 int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; } 266 int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; }
268 #endif
269 int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; } 267 int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; }
270 int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; } 268 int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; }
271 int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; } 269 int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; }
272 int ctrl_x_mode_files(void) { return ctrl_x_mode == CTRL_X_FILES; } 270 int ctrl_x_mode_files(void) { return ctrl_x_mode == CTRL_X_FILES; }
273 int ctrl_x_mode_tags(void) { return ctrl_x_mode == CTRL_X_TAGS; } 271 int ctrl_x_mode_tags(void) { return ctrl_x_mode == CTRL_X_TAGS; }
2149 */ 2147 */
2150 static int 2148 static int
2151 ins_compl_stop(int c, int prev_mode, int retval) 2149 ins_compl_stop(int c, int prev_mode, int retval)
2152 { 2150 {
2153 char_u *ptr; 2151 char_u *ptr;
2154 #ifdef FEAT_CINDENT
2155 int want_cindent; 2152 int want_cindent;
2156 #endif
2157 2153
2158 // Get here when we have finished typing a sequence of ^N and 2154 // Get here when we have finished typing a sequence of ^N and
2159 // ^P or other completion characters in CTRL-X mode. Free up 2155 // ^P or other completion characters in CTRL-X mode. Free up
2160 // memory that was used, and make sure we can redo the insert. 2156 // memory that was used, and make sure we can redo the insert.
2161 if (compl_curr_match != NULL || compl_leader != NULL || c == Ctrl_E) 2157 if (compl_curr_match != NULL || compl_leader != NULL || c == Ctrl_E)
2171 else 2167 else
2172 ptr = NULL; 2168 ptr = NULL;
2173 ins_compl_fixRedoBufForLeader(ptr); 2169 ins_compl_fixRedoBufForLeader(ptr);
2174 } 2170 }
2175 2171
2176 #ifdef FEAT_CINDENT
2177 want_cindent = (get_can_cindent() && cindent_on()); 2172 want_cindent = (get_can_cindent() && cindent_on());
2178 #endif 2173
2179 // When completing whole lines: fix indent for 'cindent'. 2174 // When completing whole lines: fix indent for 'cindent'.
2180 // Otherwise, break line if it's too long. 2175 // Otherwise, break line if it's too long.
2181 if (compl_cont_mode == CTRL_X_WHOLE_LINE) 2176 if (compl_cont_mode == CTRL_X_WHOLE_LINE)
2182 { 2177 {
2183 #ifdef FEAT_CINDENT
2184 // re-indent the current line 2178 // re-indent the current line
2185 if (want_cindent) 2179 if (want_cindent)
2186 { 2180 {
2187 do_c_expr_indent(); 2181 do_c_expr_indent();
2188 want_cindent = FALSE; // don't do it again 2182 want_cindent = FALSE; // don't do it again
2189 } 2183 }
2190 #endif
2191 } 2184 }
2192 else 2185 else
2193 { 2186 {
2194 int prev_col = curwin->w_cursor.col; 2187 int prev_col = curwin->w_cursor.col;
2195 2188
2249 if (c == Ctrl_C && cmdwin_type != 0) 2242 if (c == Ctrl_C && cmdwin_type != 0)
2250 // Avoid the popup menu remains displayed when leaving the 2243 // Avoid the popup menu remains displayed when leaving the
2251 // command line window. 2244 // command line window.
2252 update_screen(0); 2245 update_screen(0);
2253 #endif 2246 #endif
2254 #ifdef FEAT_CINDENT
2255 // Indent now if a key was typed that is in 'cinkeys'. 2247 // Indent now if a key was typed that is in 'cinkeys'.
2256 if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0))) 2248 if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0)))
2257 do_c_expr_indent(); 2249 do_c_expr_indent();
2258 #endif
2259 // Trigger the CompleteDone event to give scripts a chance to act 2250 // Trigger the CompleteDone event to give scripts a chance to act
2260 // upon the end of completion. 2251 // upon the end of completion.
2261 ins_apply_autocmds(EVENT_COMPLETEDONE); 2252 ins_apply_autocmds(EVENT_COMPLETEDONE);
2262 2253
2263 return retval; 2254 return retval;
4736 int flags = CP_ORIGINAL_TEXT; 4727 int flags = CP_ORIGINAL_TEXT;
4737 4728
4738 // First time we hit ^N or ^P (in a row, I mean) 4729 // First time we hit ^N or ^P (in a row, I mean)
4739 4730
4740 did_ai = FALSE; 4731 did_ai = FALSE;
4741 #ifdef FEAT_SMARTINDENT
4742 did_si = FALSE; 4732 did_si = FALSE;
4743 can_si = FALSE; 4733 can_si = FALSE;
4744 can_si_back = FALSE; 4734 can_si_back = FALSE;
4745 #endif
4746 if (stop_arrow() == FAIL) 4735 if (stop_arrow() == FAIL)
4747 return FAIL; 4736 return FAIL;
4748 4737
4749 line = ml_get(curwin->w_cursor.lnum); 4738 line = ml_get(curwin->w_cursor.lnum);
4750 curs_col = curwin->w_cursor.col; 4739 curs_col = curwin->w_cursor.col;