comparison src/ops.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 6a4edacbd178
children fba9e366ced4
comparison
equal deleted inserted replaced
28941:f17de8647585 28942:6cdf55afaae9
157 else if (oap->block_mode) 157 else if (oap->block_mode)
158 shift_block(oap, amount); 158 shift_block(oap, amount);
159 else 159 else
160 // Move the line right if it doesn't start with '#', 'smartindent' 160 // Move the line right if it doesn't start with '#', 'smartindent'
161 // isn't set or 'cindent' isn't set or '#' isn't in 'cino'. 161 // isn't set or 'cindent' isn't set or '#' isn't in 'cino'.
162 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
163 if (first_char != '#' || !preprocs_left()) 162 if (first_char != '#' || !preprocs_left())
164 #endif 163 shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE);
165 shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE);
166 ++curwin->w_cursor.lnum; 164 ++curwin->w_cursor.lnum;
167 } 165 }
168 166
169 changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L); 167 changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
170 if (oap->block_mode) 168 if (oap->block_mode)
1715 1713
1716 l = oap->start.col; 1714 l = oap->start.col;
1717 if (oap->motion_type == MLINE) 1715 if (oap->motion_type == MLINE)
1718 { 1716 {
1719 l = 0; 1717 l = 0;
1720 #ifdef FEAT_SMARTINDENT
1721 can_si = may_do_si(); // Like opening a new line, do smart indent 1718 can_si = may_do_si(); // Like opening a new line, do smart indent
1722 #endif
1723 } 1719 }
1724 1720
1725 // First delete the text in the region. In an empty buffer only need to 1721 // First delete the text in the region. In an empty buffer only need to
1726 // save for undo 1722 // save for undo
1727 if (curbuf->b_ml.ml_flags & ML_EMPTY) 1723 if (curbuf->b_ml.ml_flags & ML_EMPTY)
1748 pre_textlen = (long)STRLEN(firstline); 1744 pre_textlen = (long)STRLEN(firstline);
1749 pre_indent = (long)getwhitecols(firstline); 1745 pre_indent = (long)getwhitecols(firstline);
1750 bd.textcol = curwin->w_cursor.col; 1746 bd.textcol = curwin->w_cursor.col;
1751 } 1747 }
1752 1748
1753 #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
1754 if (oap->motion_type == MLINE) 1749 if (oap->motion_type == MLINE)
1755 fix_indent(); 1750 fix_indent();
1756 #endif
1757 1751
1758 retval = edit(NUL, FALSE, (linenr_T)1); 1752 retval = edit(NUL, FALSE, (linenr_T)1);
1759 1753
1760 /* 1754 /*
1761 * In Visual block mode, handle copying the new text to all lines of the 1755 * In Visual block mode, handle copying the new text to all lines of the
3290 } 3284 }
3291 if (oap->op_type != OP_COLON) 3285 if (oap->op_type != OP_COLON)
3292 stuffReadbuff((char_u *)"!"); 3286 stuffReadbuff((char_u *)"!");
3293 if (oap->op_type == OP_INDENT) 3287 if (oap->op_type == OP_INDENT)
3294 { 3288 {
3295 #ifndef FEAT_CINDENT
3296 if (*get_equalprg() == NUL) 3289 if (*get_equalprg() == NUL)
3297 stuffReadbuff((char_u *)"indent"); 3290 stuffReadbuff((char_u *)"indent");
3298 else 3291 else
3299 #endif
3300 stuffReadbuff(get_equalprg()); 3292 stuffReadbuff(get_equalprg());
3301 stuffReadbuff((char_u *)"\n"); 3293 stuffReadbuff((char_u *)"\n");
3302 } 3294 }
3303 else if (oap->op_type == OP_FORMAT) 3295 else if (oap->op_type == OP_FORMAT)
3304 { 3296 {
4055 // FALLTHROUGH 4047 // FALLTHROUGH
4056 4048
4057 case OP_INDENT: 4049 case OP_INDENT:
4058 case OP_COLON: 4050 case OP_COLON:
4059 4051
4060 #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
4061 // If 'equalprg' is empty, do the indenting internally. 4052 // If 'equalprg' is empty, do the indenting internally.
4062 if (oap->op_type == OP_INDENT && *get_equalprg() == NUL) 4053 if (oap->op_type == OP_INDENT && *get_equalprg() == NUL)
4063 { 4054 {
4064 # ifdef FEAT_LISP
4065 if (curbuf->b_p_lisp) 4055 if (curbuf->b_p_lisp)
4066 { 4056 {
4067 op_reindent(oap, get_lisp_indent); 4057 op_reindent(oap, get_lisp_indent);
4068 break; 4058 break;
4069 } 4059 }
4070 # endif
4071 # ifdef FEAT_CINDENT
4072 op_reindent(oap, 4060 op_reindent(oap,
4073 # ifdef FEAT_EVAL 4061 #ifdef FEAT_EVAL
4074 *curbuf->b_p_inde != NUL ? get_expr_indent : 4062 *curbuf->b_p_inde != NUL ? get_expr_indent :
4075 # endif 4063 #endif
4076 get_c_indent); 4064 get_c_indent);
4077 break; 4065 break;
4078 # endif 4066 }
4079 }
4080 #endif
4081 4067
4082 op_colon(oap); 4068 op_colon(oap);
4083 break; 4069 break;
4084 4070
4085 case OP_TILDE: 4071 case OP_TILDE: