mirror of
https://github.com/vim/vim.git
synced 2025-09-05 21:43:39 -04:00
updated for version 7.4.069
Problem: Cannot right shift lines starting with #. Solution: Allow the right shift when 'cino' contains #N with N > 0. (Christian Brabandt) Refactor parsing 'cino', store the values in the buffer.
This commit is contained in:
parent
0958e0fbe7
commit
6bcbcc59be
@ -545,10 +545,12 @@ The examples below assume a 'shiftwidth' of 4.
|
||||
(default 70 lines).
|
||||
|
||||
*cino-#*
|
||||
#N When N is non-zero recognize shell/Perl comments, starting with
|
||||
'#'. Default N is zero: don't recognize '#' comments. Note
|
||||
that lines starting with # will still be seen as preprocessor
|
||||
lines.
|
||||
#N When N is non-zero recognize shell/Perl comments starting with
|
||||
'#', do not recognize preprocessor lines; allow right-shifting
|
||||
lines that start with "#".
|
||||
When N is zero (default): don't recognize '#' comments, do
|
||||
recognize preprocessor lines; right-shifting lines that start
|
||||
with "#" does not work.
|
||||
|
||||
|
||||
The defaults, spelled out in full, are:
|
||||
@ -556,7 +558,7 @@ The defaults, spelled out in full, are:
|
||||
c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0
|
||||
|
||||
Vim puts a line in column 1 if:
|
||||
- It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
|
||||
- It starts with '#' (preprocessor directives), if 'cinkeys' contains '#0'.
|
||||
- It starts with a label (a keyword followed by ':', other than "case" and
|
||||
"default") and 'cinoptions' does not contain an 'L' entry with a positive
|
||||
value.
|
||||
|
@ -211,7 +211,10 @@ open_buffer(read_stdin, eap, flags)
|
||||
|
||||
/* if first time loading this buffer, init b_chartab[] */
|
||||
if (curbuf->b_flags & BF_NEVERLOADED)
|
||||
{
|
||||
(void)buf_init_chartab(curbuf, FALSE);
|
||||
parse_cino(curbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set/reset the Changed flag first, autocmds may change the buffer.
|
||||
|
@ -8958,7 +8958,7 @@ ins_bs(c, mode, inserted_space_p)
|
||||
|
||||
*inserted_space_p = FALSE;
|
||||
if (p_sta && in_indent)
|
||||
ts = (int)get_sw_value();
|
||||
ts = (int)get_sw_value(curbuf);
|
||||
else
|
||||
ts = (int)get_sts_value();
|
||||
/* Compute the virtual column where we want to be. Since
|
||||
@ -9647,7 +9647,7 @@ ins_tab()
|
||||
* When nothing special, insert TAB like a normal character
|
||||
*/
|
||||
if (!curbuf->b_p_et
|
||||
&& !(p_sta && ind && curbuf->b_p_ts != get_sw_value())
|
||||
&& !(p_sta && ind && curbuf->b_p_ts != get_sw_value(curbuf))
|
||||
&& get_sts_value() == 0)
|
||||
return TRUE;
|
||||
|
||||
@ -9663,7 +9663,7 @@ ins_tab()
|
||||
AppendToRedobuff((char_u *)"\t");
|
||||
|
||||
if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */
|
||||
temp = (int)get_sw_value();
|
||||
temp = (int)get_sw_value(curbuf);
|
||||
else if (curbuf->b_p_sts != 0) /* use 'softtabstop' when set */
|
||||
temp = (int)get_sts_value();
|
||||
else /* otherwise use 'tabstop' */
|
||||
|
@ -16934,7 +16934,7 @@ f_shiftwidth(argvars, rettv)
|
||||
typval_T *argvars UNUSED;
|
||||
typval_T *rettv;
|
||||
{
|
||||
rettv->vval.v_number = get_sw_value();
|
||||
rettv->vval.v_number = get_sw_value(curbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2280,7 +2280,7 @@ getexmodeline(promptc, cookie, indent)
|
||||
|
||||
if (c1 == Ctrl_T)
|
||||
{
|
||||
long sw = get_sw_value();
|
||||
long sw = get_sw_value(curbuf);
|
||||
|
||||
p = (char_u *)line_ga.ga_data;
|
||||
p[line_ga.ga_len] = NUL;
|
||||
@ -2337,7 +2337,7 @@ redraw:
|
||||
p[line_ga.ga_len] = NUL;
|
||||
indent = get_indent_str(p, 8);
|
||||
--indent;
|
||||
indent -= indent % get_sw_value();
|
||||
indent -= indent % get_sw_value(curbuf);
|
||||
}
|
||||
while (get_indent_str(p, 8) > indent)
|
||||
{
|
||||
@ -4178,7 +4178,7 @@ expand_showtail(xp)
|
||||
/*
|
||||
* Prepare a string for expansion.
|
||||
* When expanding file names: The string will be used with expand_wildcards().
|
||||
* Copy the file name into allocated memory and add a '*' at the end.
|
||||
* Copy "fname[len]" into allocated memory and add a '*' at the end.
|
||||
* When expanding other names: The string will be used with regcomp(). Copy
|
||||
* the name into allocated memory and prepend "^".
|
||||
*/
|
||||
|
@ -3052,7 +3052,7 @@ foldlevelIndent(flp)
|
||||
flp->lvl = -1;
|
||||
}
|
||||
else
|
||||
flp->lvl = get_indent_buf(buf, lnum) / get_sw_value();
|
||||
flp->lvl = get_indent_buf(buf, lnum) / get_sw_value(curbuf);
|
||||
if (flp->lvl > flp->wp->w_p_fdn)
|
||||
{
|
||||
flp->lvl = flp->wp->w_p_fdn;
|
||||
|
798
src/misc1.c
798
src/misc1.c
File diff suppressed because it is too large
Load Diff
@ -336,7 +336,7 @@ shift_line(left, round, amount, call_changed_bytes)
|
||||
{
|
||||
int count;
|
||||
int i, j;
|
||||
int p_sw = (int)get_sw_value();
|
||||
int p_sw = (int)get_sw_value(curbuf);
|
||||
|
||||
count = get_indent(); /* get current indent */
|
||||
|
||||
@ -392,7 +392,7 @@ shift_block(oap, amount)
|
||||
int total;
|
||||
char_u *newp, *oldp;
|
||||
int oldcol = curwin->w_cursor.col;
|
||||
int p_sw = (int)get_sw_value();
|
||||
int p_sw = (int)get_sw_value(curbuf);
|
||||
int p_ts = (int)curbuf->b_p_ts;
|
||||
struct block_def bd;
|
||||
int incr;
|
||||
@ -4046,7 +4046,8 @@ preprocs_left()
|
||||
# endif
|
||||
# endif
|
||||
# ifdef FEAT_CINDENT
|
||||
(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE))
|
||||
(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE)
|
||||
&& curbuf->b_ind_hash_comment == 0)
|
||||
# endif
|
||||
;
|
||||
}
|
||||
|
29
src/option.c
29
src/option.c
@ -5372,6 +5372,7 @@ check_buf_options(buf)
|
||||
#ifdef FEAT_CINDENT
|
||||
check_string_option(&buf->b_p_cink);
|
||||
check_string_option(&buf->b_p_cino);
|
||||
parse_cino(buf);
|
||||
#endif
|
||||
#ifdef FEAT_AUTOCMD
|
||||
check_string_option(&buf->b_p_ft);
|
||||
@ -6990,6 +6991,15 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_CINDENT
|
||||
/* 'cinoptions' */
|
||||
else if (gvarp == &p_cino)
|
||||
{
|
||||
/* TODO: recognize errors */
|
||||
parse_cino(curbuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Options that are a list of flags. */
|
||||
else
|
||||
{
|
||||
@ -8338,14 +8348,24 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
|
||||
curwin->w_p_fdc = 12;
|
||||
}
|
||||
}
|
||||
#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
|
||||
if (foldmethodIsIndent(curwin))
|
||||
foldUpdateAll(curwin);
|
||||
# endif
|
||||
# ifdef FEAT_CINDENT
|
||||
/* 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 /* FEAT_FOLDING */
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 'maxcombine' */
|
||||
@ -11729,9 +11749,10 @@ check_ff_value(p)
|
||||
* 'tabstop' value when 'shiftwidth' is zero.
|
||||
*/
|
||||
long
|
||||
get_sw_value()
|
||||
get_sw_value(buf)
|
||||
buf_T *buf;
|
||||
{
|
||||
return curbuf->b_p_sw ? curbuf->b_p_sw : curbuf->b_p_ts;
|
||||
return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -11741,7 +11762,7 @@ get_sw_value()
|
||||
long
|
||||
get_sts_value()
|
||||
{
|
||||
return curbuf->b_p_sts < 0 ? get_sw_value() : curbuf->b_p_sts;
|
||||
return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -84,6 +84,7 @@ void do_c_expr_indent __ARGS((void));
|
||||
int cin_islabel __ARGS((int ind_maxcomment));
|
||||
int cin_iscase __ARGS((char_u *s, int strict));
|
||||
int cin_isscopedecl __ARGS((char_u *s));
|
||||
void parse_cino __ARGS((buf_T *buf));
|
||||
int get_c_indent __ARGS((void));
|
||||
int get_expr_indent __ARGS((void));
|
||||
int get_lisp_indent __ARGS((void));
|
||||
|
@ -59,7 +59,7 @@ int can_bs __ARGS((int what));
|
||||
void save_file_ff __ARGS((buf_T *buf));
|
||||
int file_ff_differs __ARGS((buf_T *buf, int ignore_empty));
|
||||
int check_ff_value __ARGS((char_u *p));
|
||||
long get_sw_value __ARGS((void));
|
||||
long get_sw_value __ARGS((buf_T *buf));
|
||||
long get_sts_value __ARGS((void));
|
||||
void find_mps_values __ARGS((int *initc, int *findc, int *backwards, int switchit));
|
||||
/* vim: set ft=c : */
|
||||
|
@ -1633,6 +1633,45 @@ 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;
|
||||
int b_ind_no_brace;
|
||||
int b_ind_first_open;
|
||||
int b_ind_open_extra;
|
||||
int b_ind_close_extra;
|
||||
int b_ind_open_left_imag;
|
||||
int b_ind_jump_label;
|
||||
int b_ind_case;
|
||||
int b_ind_case_code;
|
||||
int b_ind_case_break;
|
||||
int b_ind_param;
|
||||
int b_ind_func_type;
|
||||
int b_ind_comment;
|
||||
int b_ind_in_comment;
|
||||
int b_ind_in_comment2;
|
||||
int b_ind_cpp_baseclass;
|
||||
int b_ind_continuation;
|
||||
int b_ind_unclosed;
|
||||
int b_ind_unclosed2;
|
||||
int b_ind_unclosed_noignore;
|
||||
int b_ind_unclosed_wrapped;
|
||||
int b_ind_unclosed_whiteok;
|
||||
int b_ind_matching_paren;
|
||||
int b_ind_paren_prev;
|
||||
int b_ind_maxparen;
|
||||
int b_ind_maxcomment;
|
||||
int b_ind_scopedecl;
|
||||
int b_ind_scopedecl_code;
|
||||
int b_ind_java;
|
||||
int b_ind_js;
|
||||
int b_ind_keep_case_label;
|
||||
int b_ind_hash_comment;
|
||||
int b_ind_cpp_namespace;
|
||||
int b_ind_if_for_while;
|
||||
#endif
|
||||
|
||||
linenr_T b_no_eol_lnum; /* non-zero lnum when last line of next binary
|
||||
* write should not have an end-of-line */
|
||||
|
||||
|
@ -738,6 +738,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
69,
|
||||
/**/
|
||||
68,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user