Mercurial > vim
changeset 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 | f17de8647585 |
children | 17ca7f6f60ab |
files | runtime/doc/builtin.txt runtime/doc/indent.txt runtime/doc/options.txt runtime/doc/various.txt src/buffer.c src/change.c src/charset.c src/cindent.c src/edit.c src/evalfunc.c src/feature.h src/globals.h src/indent.c src/insexpand.c src/main.c src/mouse.c src/ops.c src/option.c src/option.h src/optiondefs.h src/optionstr.c src/register.c src/search.c src/structs.h src/testdir/test_edit.vim src/textformat.c src/version.c |
diffstat | 27 files changed, 82 insertions(+), 510 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1500,8 +1500,7 @@ cindent({lnum}) *cindent()* indenting rules, as with 'cindent'. The indent is counted in spaces, the value of 'tabstop' is relevant. {lnum} is used just like in |getline()|. - When {lnum} is invalid or Vim was not compiled the |+cindent| - feature, -1 is returned. + When {lnum} is invalid -1 is returned. See |C-indenting|. Can also be used as a |method|: > @@ -5173,8 +5172,7 @@ lispindent({lnum}) *lispindent()* indenting rules, as with 'lisp'. The indent is counted in spaces, the value of 'tabstop' is relevant. {lnum} is used just like in |getline()|. - When {lnum} is invalid or Vim was not compiled the - |+lispindent| feature, -1 is returned. In |Vim9| script an + When {lnum} is invalid -1 is returned. In |Vim9| script an error is given. Can also be used as a |method|: >
--- a/runtime/doc/indent.txt +++ b/runtime/doc/indent.txt @@ -22,9 +22,6 @@ indent and do not perform other formatti affect other kinds of formatting as well as indenting, see |format-comments|, |fo-table|, |gq| and |formatting| for the main ones. -Note that this will not work when the |+smartindent| or |+cindent| features -have been disabled at compile time. - There are in fact four main methods available for indentation, each one overrides the previous if it is enabled, or non-empty for 'indentexpr': 'autoindent' uses the indent from the previous line.
--- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1621,8 +1621,6 @@ A jump table for the options with a shor *'cindent'* *'cin'* *'nocindent'* *'nocin'* 'cindent' 'cin' boolean (default off) local to buffer - {not available when compiled without the |+cindent| - feature} Enables automatic C program indenting. See 'cinkeys' to set the keys that trigger reindenting in insert mode and 'cinoptions' to set your preferred indent style. @@ -1639,8 +1637,6 @@ A jump table for the options with a shor *'cinkeys'* *'cink'* 'cinkeys' 'cink' string (default "0{,0},0),0],:,0#,!^F,o,O,e") local to buffer - {not available when compiled without the |+cindent| - feature} A list of keys that, when typed in Insert mode, cause reindenting of the current line. Only used if 'cindent' is on and 'indentexpr' is empty. @@ -1650,8 +1646,6 @@ A jump table for the options with a shor *'cinoptions'* *'cino'* 'cinoptions' 'cino' string (default "") local to buffer - {not available when compiled without the |+cindent| - feature} The 'cinoptions' affect the way 'cindent' reindents lines in a C program. See |cinoptions-values| for the values of this option, and |C-indenting| for info on C indenting in general. @@ -1660,8 +1654,6 @@ A jump table for the options with a shor *'cinwords'* *'cinw'* 'cinwords' 'cinw' string (default "if,else,while,do,for,switch") local to buffer - {not available when compiled without both the - |+cindent| and the |+smartindent| features} These keywords start an extra indent in the next line when 'smartindent' or 'cindent' is set. For 'cindent' this is only done at an appropriate place (inside {}). @@ -1672,8 +1664,6 @@ A jump table for the options with a shor *'cinscopedecls'* *'cinsd'* 'cinscopedecls' 'cinsd' string (default "public,protected,private") local to buffer - {not available when compiled without the |+cindent| - feature} Keywords that are interpreted as a C++ scope declaration by |cino-g|. Useful e.g. for working with the Qt framework that defines additional scope declarations "signals", "public slots" and "private slots": > @@ -4578,8 +4568,8 @@ A jump table for the options with a shor *'indentexpr'* *'inde'* 'indentexpr' 'inde' string (default "") local to buffer - {not available when compiled without the |+cindent| - or |+eval| features} + {not available when compiled without the |+eval| + feature} Expression which is evaluated to obtain the proper indent for a line. It is used when a new line is created, for the |=| operator and in Insert mode as specified with the 'indentkeys' option. @@ -4624,8 +4614,6 @@ A jump table for the options with a shor *'indentkeys'* *'indk'* 'indentkeys' 'indk' string (default "0{,0},0),0],:,0#,!^F,o,O,e") local to buffer - {not available when compiled without the |+cindent| - feature} A list of keys that, when typed in Insert mode, cause reindenting of the current line. Only happens if 'indentexpr' isn't empty. The format is identical to 'cinkeys', see |indentkeys-format|. @@ -5013,8 +5001,6 @@ A jump table for the options with a shor *'lisp'* *'nolisp'* 'lisp' boolean (default off) local to buffer - {not available when compiled without the |+lispindent| - feature} Lisp mode: When <Enter> is typed in insert mode set the indent for the next line to Lisp standards (well, sort of). Also happens with "cc" or "S". 'autoindent' must also be on for this to work. The 'p' @@ -5028,8 +5014,6 @@ A jump table for the options with a shor *'lispwords'* *'lw'* 'lispwords' 'lw' string (default is very long) global or local to buffer |global-local| - {not available when compiled without the |+lispindent| - feature} Comma-separated list of words that influence the Lisp indenting. |'lisp'| @@ -7222,8 +7206,6 @@ A jump table for the options with a shor *'smartindent'* *'si'* *'nosmartindent'* *'nosi'* 'smartindent' 'si' boolean (default off) local to buffer - {not available when compiled without the - |+smartindent| feature} Do smart autoindenting when starting a new line. Works for C-like programs, but can also be used for other languages. 'cindent' does something like this, works better in most cases, but is more strict,
--- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -346,7 +346,7 @@ B *++builtin_terms* maximal terminals b N *+byte_offset* support for 'o' flag in 'statusline' option, "go" and ":goto" commands. m *+channel* inter process communication |channel| -N *+cindent* |'cindent'|, C indenting +6 *+cindent* |'cindent'|, C indenting N *+clientserver* Unix and Win32: Remote invocation |clientserver| *+clipboard* |clipboard| support compiled-in *+clipboard_working* |clipboard| support compiled-in and working @@ -398,7 +398,7 @@ N *+lambda* |lambda| and |closure| B *+langmap* |'langmap'| N *+libcall* |libcall()| N *+linebreak* |'linebreak'|, |'breakat'| and |'showbreak'| -N *+lispindent* |'lisp'| +t *+lispindent* |'lisp'| T *+listcmds* Vim commands for the list of buffers |buffer-hidden| and argument list |:argdelete| T *+localmap* Support for mappings local to a buffer |:map-local| @@ -450,7 +450,7 @@ m *+ruby* Ruby interface |ruby| m *+ruby/dyn* Ruby interface |ruby-dynamic| |/dyn| T *+scrollbind* |'scrollbind'| B *+signs* |:sign| -N *+smartindent* |'smartindent'| +t *+smartindent* |'smartindent'| B *+sodium* compiled with libsodium for better encryption support B *+sound* |sound_playevent()|, |sound_playfile()| functions, etc. N *+spell* spell checking support, see |spell|
--- 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); }
--- 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
--- 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
--- 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 c 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) } 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) 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, typv curwin->w_cursor = pos; } else -# endif rettv->vval.v_number = -1; } #endif
--- a/src/edit.c +++ b/src/edit.c @@ -84,9 +84,7 @@ static int last_insert_skip; // nr of ch 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.
--- 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
--- 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)
--- a/src/globals.h +++ b/src/globals.h @@ -937,7 +937,6 @@ EXTERN int end_comment_pending INIT( */ 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
--- 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)(voi // 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)(voi 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)(voi 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 *re 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, t else if (in_vim9script()) semsg(_(e_invalid_line_number_nr), lnum); else -# endif rettv->vval.v_number = -1; } #endif
--- 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 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 // 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;
--- a/src/main.c +++ b/src/main.c @@ -2180,10 +2180,8 @@ command_line_scan(mparm_T *parmp) break; case 'l': // "-l" lisp mode, 'lisp' and 'showmatch' on -#ifdef FEAT_LISP set_option_value_give_err((char_u *)"lisp", 1L, NULL, 0); p_sm = TRUE; -#endif break; case 'M': // "-M" no changes or writing of files @@ -3494,9 +3492,7 @@ usage(void) main_msg(_("-m\t\t\tModifications (writing files) not allowed")); main_msg(_("-M\t\t\tModifications in text not allowed")); main_msg(_("-b\t\t\tBinary mode")); -#ifdef FEAT_LISP main_msg(_("-l\t\t\tLisp mode")); -#endif main_msg(_("-C\t\t\tCompatible with Vi: 'compatible'")); main_msg(_("-N\t\t\tNot fully Vi compatible: 'nocompatible'")); main_msg(_("-V[N][fname]\t\tBe verbose [level N] [log messages to fname]"));
--- a/src/mouse.c +++ b/src/mouse.c @@ -1083,9 +1083,7 @@ ins_mouse(int c) curwin = new_curwin; curbuf = curwin->w_buffer; } -# ifdef FEAT_CINDENT set_can_cindent(TRUE); -# endif } // redraw status lines (in case another window became active) @@ -1173,9 +1171,7 @@ ins_mousescroll(int dir) if (!EQUAL_POS(curwin->w_cursor, tpos)) { start_arrow(&tpos); -# ifdef FEAT_CINDENT set_can_cindent(TRUE); -# endif } }
--- a/src/ops.c +++ b/src/ops.c @@ -159,10 +159,8 @@ op_shift(oparg_T *oap, int curs_top, int else // Move the line right if it doesn't start with '#', 'smartindent' // isn't set or 'cindent' isn't set or '#' isn't in 'cino'. -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) if (first_char != '#' || !preprocs_left()) -#endif - shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE); + shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE); ++curwin->w_cursor.lnum; } @@ -1717,9 +1715,7 @@ op_change(oparg_T *oap) if (oap->motion_type == MLINE) { l = 0; -#ifdef FEAT_SMARTINDENT can_si = may_do_si(); // Like opening a new line, do smart indent -#endif } // First delete the text in the region. In an empty buffer only need to @@ -1750,10 +1746,8 @@ op_change(oparg_T *oap) bd.textcol = curwin->w_cursor.col; } -#if defined(FEAT_LISP) || defined(FEAT_CINDENT) if (oap->motion_type == MLINE) fix_indent(); -#endif retval = edit(NUL, FALSE, (linenr_T)1); @@ -3292,11 +3286,9 @@ op_colon(oparg_T *oap) stuffReadbuff((char_u *)"!"); if (oap->op_type == OP_INDENT) { -#ifndef FEAT_CINDENT if (*get_equalprg() == NUL) stuffReadbuff((char_u *)"indent"); else -#endif stuffReadbuff(get_equalprg()); stuffReadbuff((char_u *)"\n"); } @@ -4057,27 +4049,21 @@ do_pending_operator(cmdarg_T *cap, int o case OP_INDENT: case OP_COLON: -#if defined(FEAT_LISP) || defined(FEAT_CINDENT) // If 'equalprg' is empty, do the indenting internally. if (oap->op_type == OP_INDENT && *get_equalprg() == NUL) { -# ifdef FEAT_LISP if (curbuf->b_p_lisp) { op_reindent(oap, get_lisp_indent); break; } -# endif -# ifdef FEAT_CINDENT op_reindent(oap, -# ifdef FEAT_EVAL +#ifdef FEAT_EVAL *curbuf->b_p_inde != NUL ? get_expr_indent : -# endif +#endif get_c_indent); break; -# endif } -#endif op_colon(oap); break;
--- a/src/option.c +++ b/src/option.c @@ -658,9 +658,7 @@ set_options_default( // The 'scroll' option must be computed for all windows. FOR_ALL_TAB_WINDOWS(tp, wp) win_comp_scroll(wp); -#ifdef FEAT_CINDENT parse_cino(curbuf); -#endif } /* @@ -2538,9 +2536,7 @@ insecure_flag(int opt_idx, int opt_flags # ifdef FEAT_BEVAL case PV_BEXPR: return &curbuf->b_p_bexpr_flags; # endif -# if defined(FEAT_CINDENT) case PV_INDE: return &curbuf->b_p_inde_flags; -# endif case PV_FEX: return &curbuf->b_p_fex_flags; # ifdef FEAT_FIND_ID case PV_INEX: return &curbuf->b_p_inex_flags; @@ -2991,12 +2987,10 @@ set_bool_option( * When 'lisp' option changes include/exclude '-' in * keyword characters. */ -#ifdef FEAT_LISP else if (varp == (char_u *)&(curbuf->b_p_lisp)) { (void)buf_init_chartab(curbuf, FALSE); // ignore errors } -#endif // when 'title' changed, may need to change the title; same for 'icon' else if ((int *)varp == &p_title || (int *)varp == &p_icon) @@ -3490,22 +3484,18 @@ set_num_option( } #endif // FEAT_FOLDING -#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) // 'shiftwidth' or 'tabstop' else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) { -# ifdef FEAT_FOLDING +#ifdef FEAT_FOLDING if (foldmethodIsIndent(curwin)) foldUpdateAll(curwin); -# endif -# ifdef FEAT_CINDENT +#endif // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: // parse 'cinoptions'. if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) parse_cino(curbuf); -# endif - } -#endif + } // 'maxcombine' else if (pp == &p_mco) @@ -5206,11 +5196,9 @@ unset_global_local_option(char_u *name, case PV_UL: buf->b_p_ul = NO_LOCAL_UNDOLEVEL; break; -#ifdef FEAT_LISP case PV_LW: clear_string_option(&buf->b_p_lw); break; -#endif case PV_MENC: clear_string_option(&buf->b_p_menc); break; @@ -5280,9 +5268,7 @@ get_varp_scope(struct vimoption *p, int case PV_STL: return (char_u *)&(curwin->w_p_stl); #endif case PV_UL: return (char_u *)&(curbuf->b_p_ul); -#ifdef FEAT_LISP case PV_LW: return (char_u *)&(curbuf->b_p_lw); -#endif case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); case PV_MENC: return (char_u *)&(curbuf->b_p_menc); case PV_LCS: return (char_u *)&(curwin->w_p_lcs); @@ -5379,10 +5365,8 @@ get_varp(struct vimoption *p) #endif case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL ? (char_u *)&(curbuf->b_p_ul) : p->var; -#ifdef FEAT_LISP case PV_LW: return *curbuf->b_p_lw != NUL ? (char_u *)&(curbuf->b_p_lw) : p->var; -#endif case PV_MENC: return *curbuf->b_p_menc != NUL ? (char_u *)&(curbuf->b_p_menc) : p->var; #ifdef FEAT_ARABIC @@ -5460,15 +5444,11 @@ get_varp(struct vimoption *p) case PV_BT: return (char_u *)&(curbuf->b_p_bt); case PV_BL: return (char_u *)&(curbuf->b_p_bl); case PV_CI: return (char_u *)&(curbuf->b_p_ci); -#ifdef FEAT_CINDENT case PV_CIN: return (char_u *)&(curbuf->b_p_cin); case PV_CINK: return (char_u *)&(curbuf->b_p_cink); case PV_CINO: return (char_u *)&(curbuf->b_p_cino); case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd); -#endif -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); -#endif case PV_COM: return (char_u *)&(curbuf->b_p_com); #ifdef FEAT_FOLDING case PV_CMS: return (char_u *)&(curbuf->b_p_cms); @@ -5501,7 +5481,7 @@ get_varp(struct vimoption *p) case PV_INEX: return (char_u *)&(curbuf->b_p_inex); # endif #endif -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) case PV_INDE: return (char_u *)&(curbuf->b_p_inde); case PV_INDK: return (char_u *)&(curbuf->b_p_indk); #endif @@ -5511,9 +5491,7 @@ get_varp(struct vimoption *p) #ifdef FEAT_CRYPT case PV_KEY: return (char_u *)&(curbuf->b_p_key); #endif -#ifdef FEAT_LISP case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); -#endif case PV_ML: return (char_u *)&(curbuf->b_p_ml); case PV_MPS: return (char_u *)&(curbuf->b_p_mps); case PV_MA: return (char_u *)&(curbuf->b_p_ma); @@ -5524,9 +5502,7 @@ get_varp(struct vimoption *p) case PV_QE: return (char_u *)&(curbuf->b_p_qe); #endif case PV_RO: return (char_u *)&(curbuf->b_p_ro); -#ifdef FEAT_SMARTINDENT case PV_SI: return (char_u *)&(curbuf->b_p_si); -#endif case PV_SN: return (char_u *)&(curbuf->b_p_sn); case PV_STS: return (char_u *)&(curbuf->b_p_sts); #ifdef FEAT_SEARCHPATH @@ -6023,13 +5999,11 @@ buf_copy_options(buf_T *buf, int flags) COPY_OPT_SCTX(buf, BV_NF); buf->b_p_mps = vim_strsave(p_mps); COPY_OPT_SCTX(buf, BV_MPS); -#ifdef FEAT_SMARTINDENT buf->b_p_si = p_si; COPY_OPT_SCTX(buf, BV_SI); -#endif buf->b_p_ci = p_ci; COPY_OPT_SCTX(buf, BV_CI); -#ifdef FEAT_CINDENT + buf->b_p_cin = p_cin; COPY_OPT_SCTX(buf, BV_CIN); buf->b_p_cink = vim_strsave(p_cink); @@ -6038,19 +6012,15 @@ buf_copy_options(buf_T *buf, int flags) COPY_OPT_SCTX(buf, BV_CINO); buf->b_p_cinsd = vim_strsave(p_cinsd); COPY_OPT_SCTX(buf, BV_CINSD); -#endif + // Don't copy 'filetype', it must be detected buf->b_p_ft = empty_option; buf->b_p_pi = p_pi; COPY_OPT_SCTX(buf, BV_PI); -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) buf->b_p_cinw = vim_strsave(p_cinw); COPY_OPT_SCTX(buf, BV_CINW); -#endif -#ifdef FEAT_LISP buf->b_p_lisp = p_lisp; COPY_OPT_SCTX(buf, BV_LISP); -#endif #ifdef FEAT_SYN_HL // Don't copy 'syntax', it must be set buf->b_p_syn = empty_option; @@ -6069,7 +6039,7 @@ buf_copy_options(buf_T *buf, int flags) buf->b_s.b_p_spo = vim_strsave(p_spo); COPY_OPT_SCTX(buf, BV_SPO); #endif -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) buf->b_p_inde = vim_strsave(p_inde); COPY_OPT_SCTX(buf, BV_INDE); buf->b_p_indk = vim_strsave(p_indk); @@ -6148,9 +6118,7 @@ buf_copy_options(buf_T *buf, int flags) buf->b_p_udf = p_udf; COPY_OPT_SCTX(buf, BV_UDF); #endif -#ifdef FEAT_LISP buf->b_p_lw = empty_option; -#endif buf->b_p_menc = empty_option; /*
--- a/src/option.h +++ b/src/option.h @@ -398,14 +398,10 @@ EXTERN int p_ai; // 'autoindent' EXTERN int p_bin; // 'binary' EXTERN int p_bomb; // 'bomb' EXTERN int p_bl; // 'buflisted' -#ifdef FEAT_CINDENT EXTERN int p_cin; // 'cindent' EXTERN char_u *p_cink; // 'cinkeys' EXTERN char_u *p_cinsd; // 'cinscopedecls' -#endif -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) EXTERN char_u *p_cinw; // 'cinwords' -#endif #ifdef FEAT_COMPL_FUNC EXTERN char_u *p_cfu; // 'completefunc' EXTERN char_u *p_ofu; // 'omnifunc' @@ -491,9 +487,7 @@ EXTERN int p_deco; // 'delcombine' EXTERN char_u *p_ccv; // 'charconvert' #endif EXTERN int p_cdh; // 'cdhome' -#ifdef FEAT_CINDENT EXTERN char_u *p_cino; // 'cinoptions' -#endif #ifdef FEAT_CMDWIN EXTERN char_u *p_cedit; // 'cedit' EXTERN long p_cwh; // 'cmdwinheight' @@ -688,7 +682,7 @@ EXTERN int p_inf; // 'infercase' EXTERN char_u *p_inex; // 'includeexpr' #endif EXTERN int p_is; // 'incsearch' -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) EXTERN char_u *p_inde; // 'indentexpr' EXTERN char_u *p_indk; // 'indentkeys' #endif @@ -717,10 +711,8 @@ EXTERN char_u *p_lm; // 'langmenu' #ifdef FEAT_GUI EXTERN long p_linespace; // 'linespace' #endif -#ifdef FEAT_LISP EXTERN int p_lisp; // 'lisp' EXTERN char_u *p_lispwords; // 'lispwords' -#endif EXTERN long p_ls; // 'laststatus' EXTERN long p_stal; // 'showtabline' EXTERN char_u *p_lcs; // 'listchars' @@ -914,9 +906,7 @@ EXTERN int p_smd; // 'showmode' EXTERN long p_ss; // 'sidescroll' EXTERN long p_siso; // 'sidescrolloff' EXTERN int p_scs; // 'smartcase' -#ifdef FEAT_SMARTINDENT EXTERN int p_si; // 'smartindent' -#endif EXTERN int p_sta; // 'smarttab' EXTERN long p_sts; // 'softtabstop' EXTERN int p_sb; // 'splitbelow' @@ -1125,15 +1115,11 @@ enum , BV_BL , BV_BOMB , BV_CI -#ifdef FEAT_CINDENT , BV_CIN , BV_CINK , BV_CINO , BV_CINSD -#endif -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) , BV_CINW -#endif , BV_CM #ifdef FEAT_FOLDING , BV_CMS @@ -1168,7 +1154,7 @@ enum , BV_FT , BV_IMI , BV_IMS -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) , BV_INDE , BV_INDK #endif @@ -1184,10 +1170,8 @@ enum , BV_KMAP #endif , BV_KP -#ifdef FEAT_LISP , BV_LISP , BV_LW -#endif , BV_MENC , BV_MA , BV_ML @@ -1203,9 +1187,7 @@ enum , BV_QE #endif , BV_RO -#ifdef FEAT_SMARTINDENT , BV_SI -#endif , BV_SN #ifdef FEAT_SYN_HL , BV_SMC
--- a/src/optiondefs.h +++ b/src/optiondefs.h @@ -40,15 +40,11 @@ #define PV_BL OPT_BUF(BV_BL) #define PV_BOMB OPT_BUF(BV_BOMB) #define PV_CI OPT_BUF(BV_CI) -#ifdef FEAT_CINDENT -# define PV_CIN OPT_BUF(BV_CIN) -# define PV_CINK OPT_BUF(BV_CINK) -# define PV_CINO OPT_BUF(BV_CINO) -# define PV_CINSD OPT_BUF(BV_CINSD) -#endif -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) -# define PV_CINW OPT_BUF(BV_CINW) -#endif +#define PV_CIN OPT_BUF(BV_CIN) +#define PV_CINK OPT_BUF(BV_CINK) +#define PV_CINO OPT_BUF(BV_CINO) +#define PV_CINSD OPT_BUF(BV_CINSD) +#define PV_CINW OPT_BUF(BV_CINW) #define PV_CM OPT_BOTH(OPT_BUF(BV_CM)) #ifdef FEAT_FOLDING # define PV_CMS OPT_BUF(BV_CMS) @@ -83,7 +79,7 @@ #define PV_FT OPT_BUF(BV_FT) #define PV_IMI OPT_BUF(BV_IMI) #define PV_IMS OPT_BUF(BV_IMS) -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) # define PV_INDE OPT_BUF(BV_INDE) # define PV_INDK OPT_BUF(BV_INDK) #endif @@ -99,10 +95,8 @@ # define PV_KMAP OPT_BUF(BV_KMAP) #endif #define PV_KP OPT_BOTH(OPT_BUF(BV_KP)) -#ifdef FEAT_LISP -# define PV_LISP OPT_BUF(BV_LISP) -# define PV_LW OPT_BOTH(OPT_BUF(BV_LW)) -#endif +#define PV_LISP OPT_BUF(BV_LISP) +#define PV_LW OPT_BOTH(OPT_BUF(BV_LW)) #define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC)) #define PV_MA OPT_BUF(BV_MA) #define PV_ML OPT_BUF(BV_ML) @@ -118,9 +112,7 @@ # define PV_QE OPT_BUF(BV_QE) #endif #define PV_RO OPT_BUF(BV_RO) -#ifdef FEAT_SMARTINDENT -# define PV_SI OPT_BUF(BV_SI) -#endif +#define PV_SI OPT_BUF(BV_SI) #define PV_SN OPT_BUF(BV_SN) #ifdef FEAT_SYN_HL # define PV_SMC OPT_BUF(BV_SMC) @@ -582,46 +574,22 @@ static struct vimoption options[] = #endif SCTX_INIT}, {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM, -#ifdef FEAT_CINDENT (char_u *)&p_cin, PV_CIN, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, -#ifdef FEAT_CINDENT (char_u *)&p_cink, PV_CINK, - {INDENTKEYS_DEFAULT, (char_u *)0L} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)0L, (char_u *)0L} -#endif - SCTX_INIT}, + {INDENTKEYS_DEFAULT, (char_u *)0L} SCTX_INIT}, {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, -#ifdef FEAT_CINDENT (char_u *)&p_cino, PV_CINO, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"cinscopedecls", "cinsd", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, -#ifdef FEAT_CINDENT (char_u *)&p_cinsd, PV_CINSD, {(char_u *)"public,protected,private", (char_u *)0L} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)0L, (char_u *)0L} -#endif SCTX_INIT}, {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) (char_u *)&p_cinw, PV_CINW, {(char_u *)"if,else,while,do,for,switch", (char_u *)0L} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)0L, (char_u *)0L} -#endif SCTX_INIT}, {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, #ifdef FEAT_CLIPBOARD @@ -1406,7 +1374,7 @@ static struct vimoption options[] = (char_u *)&p_is, PV_NONE, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE, -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) (char_u *)&p_inde, PV_INDE, {(char_u *)"", (char_u *)0L} #else @@ -1415,7 +1383,7 @@ static struct vimoption options[] = #endif SCTX_INIT}, {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) (char_u *)&p_indk, PV_INDK, {INDENTKEYS_DEFAULT, (char_u *)0L} #else @@ -1576,21 +1544,11 @@ static struct vimoption options[] = #endif SCTX_INIT}, {"lisp", NULL, P_BOOL|P_VI_DEF, -#ifdef FEAT_LISP (char_u *)&p_lisp, PV_LISP, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, -#ifdef FEAT_LISP (char_u *)&p_lispwords, PV_LW, - {(char_u *)LISPWORD_VALUE, (char_u *)0L} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)"", (char_u *)0L} -#endif - SCTX_INIT}, + {(char_u *)LISPWORD_VALUE, (char_u *)0L} SCTX_INIT}, {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN, (char_u *)VAR_WIN, PV_LIST, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, @@ -2342,11 +2300,7 @@ static struct vimoption options[] = (char_u *)&p_scs, PV_NONE, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM, -#ifdef FEAT_SMARTINDENT (char_u *)&p_si, PV_SI, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM, (char_u *)&p_sta, PV_NONE,
--- a/src/optionstr.c +++ b/src/optionstr.c @@ -215,7 +215,7 @@ check_buf_options(buf_T *buf) check_string_option(&buf->b_p_inex); # endif #endif -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) check_string_option(&buf->b_p_inde); check_string_option(&buf->b_p_indk); #endif @@ -258,16 +258,12 @@ check_buf_options(buf_T *buf) #ifdef FEAT_SEARCHPATH check_string_option(&buf->b_p_sua); #endif -#ifdef FEAT_CINDENT check_string_option(&buf->b_p_cink); check_string_option(&buf->b_p_cino); check_string_option(&buf->b_p_cinsd); parse_cino(buf); -#endif check_string_option(&buf->b_p_ft); -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) check_string_option(&buf->b_p_cinw); -#endif check_string_option(&buf->b_p_cpt); #ifdef FEAT_COMPL_FUNC check_string_option(&buf->b_p_cfu); @@ -291,9 +287,7 @@ check_buf_options(buf_T *buf) check_string_option(&buf->b_p_tc); check_string_option(&buf->b_p_dict); check_string_option(&buf->b_p_tsr); -#ifdef FEAT_LISP check_string_option(&buf->b_p_lw); -#endif check_string_option(&buf->b_p_bkc); check_string_option(&buf->b_p_menc); #ifdef FEAT_VARTABS @@ -2116,14 +2110,12 @@ ambw_end: } #endif -#ifdef FEAT_CINDENT // 'cinoptions' else if (gvarp == &p_cino) { // TODO: recognize errors parse_cino(curbuf); } -#endif #if defined(FEAT_RENDER_OPTIONS) // 'renderoptions' @@ -2315,9 +2307,7 @@ ambw_end: # ifdef FEAT_FIND_ID gvarp == &p_inex || # endif -# ifdef FEAT_CINDENT gvarp == &p_inde || -# endif # ifdef FEAT_DIFF varp == &p_pex || # endif @@ -2351,10 +2341,8 @@ ambw_end: if (gvarp == &p_inex) // 'includeexpr' p_opt = &curbuf->b_p_inex; # endif -# ifdef FEAT_CINDENT if (gvarp == &p_inde) // 'indentexpr' p_opt = &curbuf->b_p_inde; -# endif # ifdef FEAT_DIFF if (varp == &p_pex) // 'patchexpr' p_opt = &p_pex;
--- a/src/register.c +++ b/src/register.c @@ -2154,11 +2154,9 @@ do_put( ptr = ml_get(lnum); if (cnt == count && i == y_size - 1) lendiff = (int)STRLEN(ptr); -#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) if (*ptr == '#' && preprocs_left()) indent = 0; // Leave # lines at start else -#endif if (*ptr == NUL) indent = 0; // Ignore empty lines else if (first_indent)
--- a/src/search.c +++ b/src/search.c @@ -2116,10 +2116,8 @@ findmatchlimit( int match_escaped = 0; // search for escaped match int dir; // Direction to search int comment_col = MAXCOL; // start of / / comment -#ifdef FEAT_LISP int lispcomm = FALSE; // inside of Lisp-style comment int lisp = curbuf->b_p_lisp; // engage Lisp-specific hacks ;) -#endif pos = curwin->w_cursor; pos.coladd = 0; @@ -2348,16 +2346,11 @@ findmatchlimit( CLEAR_POS(&match_pos); // backward search: Check if this line contains a single-line comment - if ((backwards && comment_dir) -#ifdef FEAT_LISP - || lisp -#endif - ) + if ((backwards && comment_dir) || lisp) comment_col = check_linecomment(linep); -#ifdef FEAT_LISP if (lisp && comment_col != MAXCOL && pos.col > (colnr_T)comment_col) lispcomm = TRUE; // find match inside this comment -#endif + while (!got_int) { /* @@ -2366,11 +2359,9 @@ findmatchlimit( */ if (backwards) { -#ifdef FEAT_LISP // char to match is inside of comment, don't search outside if (lispcomm && pos.col < (colnr_T)comment_col) break; -#endif if (pos.col == 0) // at start of line, go to prev. one { if (pos.lnum == 1) // start of file @@ -2386,17 +2377,11 @@ findmatchlimit( line_breakcheck(); // Check if this line contains a single-line comment - if (comment_dir -#ifdef FEAT_LISP - || lisp -#endif - ) + if (comment_dir || lisp) comment_col = check_linecomment(linep); -#ifdef FEAT_LISP // skip comment if (lisp && comment_col != MAXCOL) pos.col = comment_col; -#endif } else { @@ -2409,20 +2394,14 @@ findmatchlimit( { if (linep[pos.col] == NUL // at end of line, go to next one -#ifdef FEAT_LISP - // don't search for match in comment + // For lisp don't search for match in comment || (lisp && comment_col != MAXCOL - && pos.col == (colnr_T)comment_col) -#endif - ) + && pos.col == (colnr_T)comment_col)) { if (pos.lnum == curbuf->b_ml.ml_line_count // end of file -#ifdef FEAT_LISP // line is exhausted and comment with it, // don't search for match in code - || lispcomm -#endif - ) + || lispcomm) break; ++pos.lnum; @@ -2433,10 +2412,8 @@ findmatchlimit( pos.col = 0; do_quotes = -1; line_breakcheck(); -#ifdef FEAT_LISP if (lisp) // find comment pos in new line comment_col = check_linecomment(linep); -#endif } else { @@ -2679,7 +2656,6 @@ findmatchlimit( // FALLTHROUGH default: -#ifdef FEAT_LISP /* * For Lisp skip over backslashed (), {} and []. * (actually, we skip #\( et al) @@ -2690,7 +2666,6 @@ findmatchlimit( && check_prevcol(linep, pos.col, '\\', NULL) && check_prevcol(linep, pos.col - 1, '#', NULL)) break; -#endif // Check for match outside of quotes, and inside of // quotes when the start is also inside of quotes. @@ -2739,7 +2714,6 @@ check_linecomment(char_u *line) char_u *p; p = line; -#ifdef FEAT_LISP // skip Lispish one-line comments if (curbuf->b_p_lisp) { @@ -2773,17 +2747,16 @@ check_linecomment(char_u *line) p = NULL; } else -#endif - while ((p = vim_strchr(p, '/')) != NULL) - { - // Accept a double /, unless it's preceded with * and followed by *, - // because * / / * is an end and start of a C comment. - // Only accept the position if it is not inside a string. - if (p[1] == '/' && (p == line || p[-1] != '*' || p[2] != '*') + while ((p = vim_strchr(p, '/')) != NULL) + { + // Accept a double /, unless it's preceded with * and followed by + // *, because * / / * is an end and start of a C comment. Only + // accept the position if it is not inside a string. + if (p[1] == '/' && (p == line || p[-1] != '*' || p[2] != '*') && !is_pos_in_string(line, (colnr_T)(p - line))) - break; - ++p; - } + break; + ++p; + } if (p == NULL) return MAXCOL; @@ -3117,8 +3090,6 @@ current_search( return OK; } -#if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(FEAT_TEXTOBJ) \ - || defined(PROTO) /* * return TRUE if line 'lnum' is empty or has white chars only. */ @@ -3130,7 +3101,6 @@ linewhite(linenr_T lnum) p = skipwhite(ml_get(lnum)); return (*p == NUL); } -#endif /* * Add the search count "[3/19]" to "msgbuf".
--- a/src/structs.h +++ b/src/structs.h @@ -2879,15 +2879,11 @@ struct file_buffer int b_has_qf_entry; #endif int b_p_bl; // 'buflisted' -#ifdef FEAT_CINDENT int b_p_cin; // 'cindent' char_u *b_p_cino; // 'cinoptions' char_u *b_p_cink; // 'cinkeys' char_u *b_p_cinsd; // 'cinscopedecls' -#endif -#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT) char_u *b_p_cinw; // 'cinwords' -#endif char_u *b_p_com; // 'comments' #ifdef FEAT_FOLDING char_u *b_p_cms; // 'commentstring' @@ -2926,7 +2922,7 @@ struct file_buffer long_u b_p_inex_flags; // flags for 'includeexpr' # endif #endif -#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +#if defined(FEAT_EVAL) char_u *b_p_inde; // 'indentexpr' long_u b_p_inde_flags; // flags for 'indentexpr' char_u *b_p_indk; // 'indentkeys' @@ -2940,9 +2936,7 @@ struct file_buffer char_u *b_p_key; // 'key' #endif char_u *b_p_kp; // 'keywordprg' -#ifdef FEAT_LISP int b_p_lisp; // 'lisp' -#endif char_u *b_p_menc; // 'makeencoding' char_u *b_p_mps; // 'matchpairs' int b_p_ml; // 'modeline' @@ -2956,9 +2950,7 @@ struct file_buffer int b_p_ro; // 'readonly' long b_p_sw; // 'shiftwidth' int b_p_sn; // 'shortname' -#ifdef FEAT_SMARTINDENT int b_p_si; // 'smartindent' -#endif long b_p_sts; // 'softtabstop' long b_p_sts_nopaste; // b_p_sts saved for paste mode #ifdef FEAT_SEARCHPATH @@ -3012,9 +3004,7 @@ struct file_buffer #ifdef FEAT_PERSISTENT_UNDO int b_p_udf; // 'undofile' #endif -#ifdef FEAT_LISP char_u *b_p_lw; // 'lispwords' local value -#endif #ifdef FEAT_TERMINAL long b_p_twsl; // 'termwinscroll' #endif @@ -3023,7 +3013,6 @@ struct file_buffer * end of buffer options */ -#ifdef FEAT_CINDENT // values set from b_p_cino int b_ind_level; int b_ind_open_imag; @@ -3062,7 +3051,6 @@ struct file_buffer int b_ind_if_for_while; int b_ind_cpp_extern_c; int b_ind_pragma; -#endif linenr_T b_no_eol_lnum; // non-zero lnum when last line of next binary // write should not have an end-of-line
--- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -391,15 +391,13 @@ endfunc func Test_edit_13() " Test smartindenting - if exists("+smartindent") - new - set smartindent autoindent - call setline(1, ["\tabc"]) - call feedkeys("A {\<cr>more\<cr>}\<esc>", 'tnix') - call assert_equal(["\tabc {", "\t\tmore", "\t}"], getline(1, '$')) - set smartindent& autoindent& - bwipe! - endif + new + set smartindent autoindent + call setline(1, ["\tabc"]) + call feedkeys("A {\<cr>more\<cr>}\<esc>", 'tnix') + call assert_equal(["\tabc {", "\t\tmore", "\t}"], getline(1, '$')) + set smartindent& autoindent& + bwipe! " Test autoindent removing indent of blank line. new
--- a/src/textformat.c +++ b/src/textformat.c @@ -108,7 +108,6 @@ internal_format( char_u *line = ml_get_curline(); leader_len = get_leader_len(line, NULL, FALSE, TRUE); -#ifdef FEAT_CINDENT if (leader_len == 0 && curbuf->b_p_cin) { int comment_start; @@ -123,7 +122,6 @@ internal_format( leader_len += comment_start; } } -#endif } else leader_len = 0; @@ -444,16 +442,12 @@ internal_format( } haveto_redraw = TRUE; -#ifdef FEAT_CINDENT set_can_cindent(TRUE); -#endif // moved the cursor, don't autoindent or cindent now did_ai = FALSE; -#ifdef FEAT_SMARTINDENT did_si = FALSE; can_si = FALSE; can_si_back = FALSE; -#endif line_breakcheck(); } @@ -1119,14 +1113,10 @@ format_lines( // indent. if (curwin->w_cursor.lnum == first_line) indent = get_indent(); - else -# ifdef FEAT_LISP - if (curbuf->b_p_lisp) + else if (curbuf->b_p_lisp) indent = get_lisp_indent(); else -# endif { -#ifdef FEAT_CINDENT if (cindent_on()) { indent = @@ -1136,7 +1126,6 @@ format_lines( get_c_indent(); } else -#endif indent = get_indent(); } (void)set_indent(indent, SIN_CHANGED);
--- a/src/version.c +++ b/src/version.c @@ -152,11 +152,7 @@ static char *(features[]) = #else "-channel", #endif -#ifdef FEAT_CINDENT "+cindent", -#else - "-cindent", -#endif #ifdef FEAT_CLIENTSERVER "+clientserver", #else @@ -334,11 +330,7 @@ static char *(features[]) = #else "-linebreak", #endif -#ifdef FEAT_LISP "+lispindent", -#else - "-lispindent", -#endif "+listcmds", "+localmap", #ifdef FEAT_LUA @@ -546,11 +538,7 @@ static char *(features[]) = #else "-signs", #endif -#ifdef FEAT_SMARTINDENT "+smartindent", -#else - "-smartindent", -#endif #ifdef FEAT_SODIUM # ifdef DYNAMIC_SODIUM "+sodium/dyn", @@ -747,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4993, +/**/ 4992, /**/ 4991,