]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blame - vim/patches/vim-7.3.492.patch0
vim: Update configuration file.
[people/arne_f/ipfire-3.x.git] / vim / patches / vim-7.3.492.patch0
CommitLineData
c6060300
MT
1To: vim_dev@googlegroups.com
2Subject: Patch 7.3.492
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.3.492
11Problem: Can't indent conditions separately from function arguments.
12Solution: Add the 'k' flag in 'cino. (Lech Lorens)
13Files: runtime/doc/indent.txt, src/misc1.c, src/testdir/test3.in,
14 src/testdir/test3.ok
15
16
17*** ../vim-7.3.491/runtime/doc/indent.txt 2011-06-26 03:16:58.000000000 +0200
18--- runtime/doc/indent.txt 2012-04-05 17:12:14.000000000 +0200
19***************
20*** 459,464 ****
21--- 460,481 ----
22 a_short_line(argument, a_short_line(argument,
23 argument); argument);
24 <
25+ *cino-k*
26+ kN When in unclosed parentheses which follow "if", "for" or
27+ "while" and N is non-zero, overrides the behaviour defined by
28+ "(N": causes the indent to be N characters relative to the outer
29+ context (i.e. the line where "if", "for" or "while" is). Has
30+ no effect on deeper levels of nesting. Affects flags like "wN"
31+ only for the "if", "for" and "while" conditions. If 0, defaults
32+ to behaviour defined by the "(N" flag. (default: 0).
33+
34+ cino=(0 cino=(0,ks >
35+ if (condition1 if (condition1
36+ && condition2) && condition2)
37+ action(); action();
38+ function(argument1 function(argument1
39+ && argument2); && argument2);
40+ <
41 *cino-m*
42 mN When N is non-zero, line up a line starting with a closing
43 parentheses with the first character of the line with the
44***************
45*** 527,540 ****
46
47 *cino-#*
48 #N When N is non-zero recognize shell/Perl comments, starting with
49! '#'. Default N is zero: don't recognizes '#' comments. Note
50 that lines starting with # will still be seen as preprocessor
51 lines.
52
53
54 The defaults, spelled out in full, are:
55 cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s,
56! c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0
57
58 Vim puts a line in column 1 if:
59 - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
60--- 546,559 ----
61
62 *cino-#*
63 #N When N is non-zero recognize shell/Perl comments, starting with
64! '#'. Default N is zero: don't recognize '#' comments. Note
65 that lines starting with # will still be seen as preprocessor
66 lines.
67
68
69 The defaults, spelled out in full, are:
70 cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s,
71! c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0
72
73 Vim puts a line in column 1 if:
74 - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
75*** ../vim-7.3.491/src/misc1.c 2012-02-29 13:49:03.000000000 +0100
76--- src/misc1.c 2012-04-05 17:12:14.000000000 +0200
77***************
78*** 5771,5776 ****
79--- 5771,5822 ----
80 }
81
82 /*
83+ * Check whether in "p" there is an "if", "for" or "while" before offset.
84+ * Return 0 if there is none.
85+ * Otherwise return !0 and update "*poffset" to point to the place where the
86+ * string was found.
87+ */
88+ static int
89+ cin_is_if_for_while_before_offset(line, offset, poffset)
90+ char_u *line;
91+ size_t offset;
92+ int *poffset;
93+ {
94+
95+ if (offset-- < 2)
96+ return 0;
97+ while (offset > 2 && vim_iswhite(line[offset]))
98+ --offset;
99+
100+ offset -= 1;
101+ if (!STRNCMP(line + offset, "if", 2))
102+ goto probablyFound;
103+
104+ if (offset >= 1)
105+ {
106+ offset -= 1;
107+ if (!STRNCMP(line + offset, "for", 3))
108+ goto probablyFound;
109+
110+ if (offset >= 2)
111+ {
112+ offset -= 2;
113+ if (!STRNCMP(line + offset, "while", 5))
114+ goto probablyFound;
115+ }
116+ }
117+
118+ return 0;
119+ probablyFound:
120+ if (!offset || !vim_isIDc(line[offset - 1]))
121+ {
122+ *poffset = offset;
123+ return 1;
124+ }
125+ return 0;
126+ }
127+
128+ /*
129 * Return TRUE if we are at the end of a do-while.
130 * do
131 * nothing;
132***************
133*** 6124,6130 ****
134
135 /*
136 * Find the matching '(', failing if it is in a comment.
137! * Return NULL of no match found.
138 */
139 static pos_T *
140 find_match_paren(ind_maxparen, ind_maxcomment) /* XXX */
141--- 6170,6176 ----
142
143 /*
144 * Find the matching '(', failing if it is in a comment.
145! * Return NULL if no match found.
146 */
147 static pos_T *
148 find_match_paren(ind_maxparen, ind_maxcomment) /* XXX */
149***************
150*** 6393,6398 ****
151--- 6439,6450 ----
152 */
153 int ind_cpp_namespace = 0;
154
155+ /*
156+ * handle continuation lines containing conditions of if(), for() and
157+ * while()
158+ */
159+ int ind_if_for_while = 0;
160+
161 pos_T cur_curpos;
162 int amount;
163 int scope_amount;
164***************
165*** 6437,6442 ****
166--- 6489,6495 ----
167 int cont_amount = 0; /* amount for continuation line */
168 int original_line_islabel;
169 int added_to_amount = 0;
170+ int is_if_for_while = 0;
171
172 for (options = curbuf->b_p_cino; *options; )
173 {
174***************
175*** 6509,6514 ****
176--- 6562,6568 ----
177 case 'l': ind_keep_case_label = n; break;
178 case '#': ind_hash_comment = n; break;
179 case 'N': ind_cpp_namespace = n; break;
180+ case 'k': ind_if_for_while = n; break;
181 }
182 if (*options == ',')
183 ++options;
184***************
185*** 6812,6817 ****
186--- 6866,6900 ----
187 if (amount == -1)
188 {
189 int ignore_paren_col = 0;
190+ int is_if_for_while = 0;
191+
192+ if (ind_if_for_while)
193+ {
194+ /* Look for the outermost opening parenthesis on this line
195+ * and check whether it belongs to an "if", "for" or "while". */
196+
197+ pos_T cursor_save = curwin->w_cursor;
198+ pos_T outermost;
199+ char_u *line;
200+ int look_col;
201+
202+ trypos = &our_paren_pos;
203+ do {
204+ outermost = *trypos;
205+ curwin->w_cursor.lnum = outermost.lnum;
206+ curwin->w_cursor.col = outermost.col;
207+
208+ trypos = find_match_paren(ind_maxparen, ind_maxcomment);
209+ } while (trypos && trypos->lnum == outermost.lnum);
210+
211+ curwin->w_cursor = cursor_save;
212+
213+ line = ml_get(outermost.lnum);
214+
215+ is_if_for_while =
216+ cin_is_if_for_while_before_offset(line, outermost.col,
217+ &outermost.col);
218+ }
219
220 amount = skip_label(our_paren_pos.lnum, &look, ind_maxcomment);
221 look = skipwhite(look);
222***************
223*** 6836,6842 ****
224 curwin->w_cursor.lnum = save_lnum;
225 look = ml_get(our_paren_pos.lnum) + look_col;
226 }
227! if (theline[0] == ')' || ind_unclosed == 0
228 || (!ind_unclosed_noignore && *look == '('
229 && ignore_paren_col == 0))
230 {
231--- 6919,6925 ----
232 curwin->w_cursor.lnum = save_lnum;
233 look = ml_get(our_paren_pos.lnum) + look_col;
234 }
235! if (theline[0] == ')' || (ind_unclosed == 0 && is_if_for_while == 0)
236 || (!ind_unclosed_noignore && *look == '('
237 && ignore_paren_col == 0))
238 {
239***************
240*** 6907,6913 ****
241 {
242 /* Line up with the start of the matching paren line. */
243 }
244! else if (ind_unclosed == 0 || (!ind_unclosed_noignore
245 && *look == '(' && ignore_paren_col == 0))
246 {
247 if (cur_amount != MAXCOL)
248--- 6990,6997 ----
249 {
250 /* Line up with the start of the matching paren line. */
251 }
252! else if ((ind_unclosed == 0 && is_if_for_while == 0)
253! || (!ind_unclosed_noignore
254 && *look == '(' && ignore_paren_col == 0))
255 {
256 if (cur_amount != MAXCOL)
257***************
258*** 6943,6949 ****
259 if (find_match_paren(ind_maxparen, ind_maxcomment) != NULL)
260 amount += ind_unclosed2;
261 else
262! amount += ind_unclosed;
263 }
264 /*
265 * For a line starting with ')' use the minimum of the two
266--- 7027,7038 ----
267 if (find_match_paren(ind_maxparen, ind_maxcomment) != NULL)
268 amount += ind_unclosed2;
269 else
270! {
271! if (is_if_for_while)
272! amount += ind_if_for_while;
273! else
274! amount += ind_unclosed;
275! }
276 }
277 /*
278 * For a line starting with ')' use the minimum of the two
279*** ../vim-7.3.491/src/testdir/test3.in 2011-12-14 20:21:29.000000000 +0100
280--- src/testdir/test3.in 2012-04-05 17:12:14.000000000 +0200
281***************
282*** 1574,1579 ****
283--- 1574,1793 ----
284 }
285
286 STARTTEST
287+ :set cino=k2s,(0
288+ 2kdd3j=][
289+ ENDTEST
290+
291+ void func(void)
292+ {
293+ if (condition1
294+ && condition2)
295+ action();
296+ function(argument1
297+ && argument2);
298+
299+ if (c1 && (c2 ||
300+ c3))
301+ foo;
302+ if (c1 &&
303+ (c2 || c3))
304+ {
305+ }
306+
307+ if ( c1
308+ && ( c2
309+ || c3))
310+ foo;
311+ func( c1
312+ && ( c2
313+ || c3))
314+ foo;
315+ }
316+
317+ STARTTEST
318+ :set cino=k2s,(s
319+ 2kdd3j=][
320+ ENDTEST
321+
322+ void func(void)
323+ {
324+ if (condition1
325+ && condition2)
326+ action();
327+ function(argument1
328+ && argument2);
329+
330+ if (c1 && (c2 ||
331+ c3))
332+ foo;
333+ if (c1 &&
334+ (c2 || c3))
335+ {
336+ }
337+
338+ if ( c1
339+ && ( c2
340+ || c3))
341+ foo;
342+ func( c1
343+ && ( c2
344+ || c3))
345+ foo;
346+ }
347+
348+ STARTTEST
349+ :set cino=k2s,(s,U1
350+ 2kdd3j=][
351+ ENDTEST
352+
353+ void func(void)
354+ {
355+ if (condition1
356+ && condition2)
357+ action();
358+ function(argument1
359+ && argument2);
360+
361+ if (c1 && (c2 ||
362+ c3))
363+ foo;
364+ if (c1 &&
365+ (c2 || c3))
366+ {
367+ }
368+ if (c123456789
369+ && (c22345
370+ || c3))
371+ printf("foo\n");
372+
373+ c = c1 &&
374+ (
375+ c2 ||
376+ c3
377+ ) && c4;
378+ }
379+
380+ STARTTEST
381+ :set cino=k2s,(0,W4
382+ 2kdd3j=][
383+ ENDTEST
384+
385+ void func(void)
386+ {
387+ if (condition1
388+ && condition2)
389+ action();
390+ function(argument1
391+ && argument2);
392+
393+ if (c1 && (c2 ||
394+ c3))
395+ foo;
396+ if (c1 &&
397+ (c2 || c3))
398+ {
399+ }
400+ if (c123456789
401+ && (c22345
402+ || c3))
403+ printf("foo\n");
404+
405+ if ( c1
406+ && ( c2
407+ || c3))
408+ foo;
409+
410+ a_long_line(
411+ argument,
412+ argument);
413+ a_short_line(argument,
414+ argument);
415+ }
416+
417+ STARTTEST
418+ :set cino=k2s,u2
419+ 2kdd3j=][
420+ ENDTEST
421+
422+ void func(void)
423+ {
424+ if (condition1
425+ && condition2)
426+ action();
427+ function(argument1
428+ && argument2);
429+
430+ if (c1 && (c2 ||
431+ c3))
432+ foo;
433+ if (c1 &&
434+ (c2 || c3))
435+ {
436+ }
437+ if (c123456789
438+ && (c22345
439+ || c3))
440+ printf("foo\n");
441+ }
442+
443+ STARTTEST
444+ :set cino=k2s,(0,w1
445+ 2kdd3j=][
446+ ENDTEST
447+
448+ void func(void)
449+ {
450+ if (condition1
451+ && condition2)
452+ action();
453+ function(argument1
454+ && argument2);
455+
456+ if (c1 && (c2 ||
457+ c3))
458+ foo;
459+ if (c1 &&
460+ (c2 || c3))
461+ {
462+ }
463+ if (c123456789
464+ && (c22345
465+ || c3))
466+ printf("foo\n");
467+
468+ if ( c1
469+ && ( c2
470+ || c3))
471+ foo;
472+ func( c1
473+ && ( c2
474+ || c3))
475+ foo;
476+ }
477+
478+ STARTTEST
479+ :set cino=k2,(s
480+ 2kdd3j=][
481+ ENDTEST
482+
483+ void func(void)
484+ {
485+ if (condition1
486+ && condition2)
487+ action();
488+ function(argument1
489+ && argument2);
490+
491+ if (c1 && (c2 ||
492+ c3))
493+ foo;
494+ if (c1 &&
495+ (c2 || c3))
496+ {
497+ }
498+ }
499+
500+ STARTTEST
501 :set cino=N-s
502 /^NAMESPACESTART
503 =/^NAMESPACEEND
504*** ../vim-7.3.491/src/testdir/test3.ok 2011-12-14 20:21:29.000000000 +0100
505--- src/testdir/test3.ok 2012-04-05 17:12:14.000000000 +0200
506***************
507*** 1411,1416 ****
508--- 1411,1602 ----
509 }
510
511
512+ void func(void)
513+ {
514+ if (condition1
515+ && condition2)
516+ action();
517+ function(argument1
518+ && argument2);
519+
520+ if (c1 && (c2 ||
521+ c3))
522+ foo;
523+ if (c1 &&
524+ (c2 || c3))
525+ {
526+ }
527+
528+ if ( c1
529+ && ( c2
530+ || c3))
531+ foo;
532+ func( c1
533+ && ( c2
534+ || c3))
535+ foo;
536+ }
537+
538+
539+ void func(void)
540+ {
541+ if (condition1
542+ && condition2)
543+ action();
544+ function(argument1
545+ && argument2);
546+
547+ if (c1 && (c2 ||
548+ c3))
549+ foo;
550+ if (c1 &&
551+ (c2 || c3))
552+ {
553+ }
554+
555+ if ( c1
556+ && ( c2
557+ || c3))
558+ foo;
559+ func( c1
560+ && ( c2
561+ || c3))
562+ foo;
563+ }
564+
565+
566+ void func(void)
567+ {
568+ if (condition1
569+ && condition2)
570+ action();
571+ function(argument1
572+ && argument2);
573+
574+ if (c1 && (c2 ||
575+ c3))
576+ foo;
577+ if (c1 &&
578+ (c2 || c3))
579+ {
580+ }
581+ if (c123456789
582+ && (c22345
583+ || c3))
584+ printf("foo\n");
585+
586+ c = c1 &&
587+ (
588+ c2 ||
589+ c3
590+ ) && c4;
591+ }
592+
593+
594+ void func(void)
595+ {
596+ if (condition1
597+ && condition2)
598+ action();
599+ function(argument1
600+ && argument2);
601+
602+ if (c1 && (c2 ||
603+ c3))
604+ foo;
605+ if (c1 &&
606+ (c2 || c3))
607+ {
608+ }
609+ if (c123456789
610+ && (c22345
611+ || c3))
612+ printf("foo\n");
613+
614+ if ( c1
615+ && ( c2
616+ || c3))
617+ foo;
618+
619+ a_long_line(
620+ argument,
621+ argument);
622+ a_short_line(argument,
623+ argument);
624+ }
625+
626+
627+ void func(void)
628+ {
629+ if (condition1
630+ && condition2)
631+ action();
632+ function(argument1
633+ && argument2);
634+
635+ if (c1 && (c2 ||
636+ c3))
637+ foo;
638+ if (c1 &&
639+ (c2 || c3))
640+ {
641+ }
642+ if (c123456789
643+ && (c22345
644+ || c3))
645+ printf("foo\n");
646+ }
647+
648+
649+ void func(void)
650+ {
651+ if (condition1
652+ && condition2)
653+ action();
654+ function(argument1
655+ && argument2);
656+
657+ if (c1 && (c2 ||
658+ c3))
659+ foo;
660+ if (c1 &&
661+ (c2 || c3))
662+ {
663+ }
664+ if (c123456789
665+ && (c22345
666+ || c3))
667+ printf("foo\n");
668+
669+ if ( c1
670+ && ( c2
671+ || c3))
672+ foo;
673+ func( c1
674+ && ( c2
675+ || c3))
676+ foo;
677+ }
678+
679+
680+ void func(void)
681+ {
682+ if (condition1
683+ && condition2)
684+ action();
685+ function(argument1
686+ && argument2);
687+
688+ if (c1 && (c2 ||
689+ c3))
690+ foo;
691+ if (c1 &&
692+ (c2 || c3))
693+ {
694+ }
695+ }
696+
697+
698 NAMESPACESTART
699 /* valid namespaces with normal indent */
700 namespace
701*** ../vim-7.3.491/src/version.c 2012-04-05 16:56:38.000000000 +0200
702--- src/version.c 2012-04-05 17:14:18.000000000 +0200
703***************
704*** 716,717 ****
705--- 716,719 ----
706 { /* Add new patch number below this line */
707+ /**/
708+ 492,
709 /**/
710
711--
712You were lucky to have a LAKE! There were a hundred and sixty of
713us living in a small shoebox in the middle of the road.
714
715 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
716/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
717\\\ an exciting new programming language -- http://www.Zimbu.org ///
718 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///