]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blame - vim/patches/vim-7.3.202.patch0
vim: Update configuration file.
[people/arne_f/ipfire-3.x.git] / vim / patches / vim-7.3.202.patch0
CommitLineData
c6060300
MT
1To: vim_dev@googlegroups.com
2Subject: Patch 7.3.202
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.202
11Problem: Cannot influence the indent inside a namespace.
12Solution: Add the "N" 'cino' parameter. (Konstantin Lepa)
13Files: runtime/doc/indent.txt, src/misc1.c, src/testdir/test3.in,
14 src/testdir/test3.ok
15
16
17*** ../mercurial/vim73/runtime/doc/indent.txt 2011-04-28 19:01:26.000000000 +0200
18--- runtime/doc/indent.txt 2011-05-25 14:35:37.000000000 +0200
19***************
20*** 128,140 ****
21 used CTRL-T or CTRL-D.
22
23 *cinoptions-values*
24! The 'cinoptions' option sets how Vim performs indentation. In the list below,
25 "N" represents a number of your choice (the number can be negative). When
26 there is an 's' after the number, Vim multiplies the number by 'shiftwidth':
27 "1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a
28! decimal point, too: "-0.5s" is minus half a 'shiftwidth'. The examples below
29! assume a 'shiftwidth' of 4.
30!
31 >N Amount added for "normal" indent. Used after a line that should
32 increase the indent (lines starting with "if", an opening brace,
33 etc.). (default 'shiftwidth').
34--- 128,147 ----
35 used CTRL-T or CTRL-D.
36
37 *cinoptions-values*
38! The 'cinoptions' option sets how Vim performs indentation. The value after
39! the option character can be one of these (N is any number):
40! N indent N spaces
41! -N indent N spaces to the left
42! Ns N times 'shiftwidth spaces
43! -Ns N times 'shiftwidth spaces to the left
44!
45! In the list below,
46 "N" represents a number of your choice (the number can be negative). When
47 there is an 's' after the number, Vim multiplies the number by 'shiftwidth':
48 "1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a
49! decimal point, too: "-0.5s" is minus half a 'shiftwidth'.
50! The examples below assume a 'shiftwidth' of 4.
51! *cino->*
52 >N Amount added for "normal" indent. Used after a line that should
53 increase the indent (lines starting with "if", an opening brace,
54 etc.). (default 'shiftwidth').
55***************
56*** 145,150 ****
57--- 152,158 ----
58 foo; foo; foo;
59 } } }
60 <
61+ *cino-e*
62 eN Add N to the prevailing indent inside a set of braces if the
63 opening brace at the End of the line (more precise: is not the
64 first character in a line). This is useful if you want a
65***************
66*** 160,165 ****
67--- 168,174 ----
68 bar; bar; bar;
69 } } }
70 <
71+ *cino-n*
72 nN Add N to the prevailing indent for a statement after an "if",
73 "while", etc., if it is NOT inside a set of braces. This is
74 useful if you want a different indent when there is no '{'
75***************
76*** 174,179 ****
77--- 183,189 ----
78 bar; bar; bar;
79 } } }
80 <
81+ *cino-f*
82 fN Place the first opening brace of a function or other block in
83 column N. This applies only for an opening brace that is not
84 inside other braces and is at the start of the line. What comes
85***************
86*** 184,189 ****
87--- 194,200 ----
88 { { {
89 int foo; int foo; int foo;
90 <
91+ *cino-{*
92 {N Place opening braces N characters from the prevailing indent.
93 This applies only for opening braces that are inside other
94 braces. (default 0).
95***************
96*** 193,198 ****
97--- 204,210 ----
98 { { {
99 foo; foo; foo;
100 <
101+ *cino-}*
102 }N Place closing braces N characters from the matching opening
103 brace. (default 0).
104
105***************
106*** 202,207 ****
107--- 214,220 ----
108 foo; foo; foo;
109 } } }
110 <
111+ *cino-^*
112 ^N Add N to the prevailing indent inside a set of braces if the
113 opening brace is in column 0. This can specify a different
114 indent for whole of a function (some may like to set it to a
115***************
116*** 216,221 ****
117--- 229,235 ----
118 } } }
119 } } }
120 <
121+ *cino-L*
122 LN Controls placement of jump labels. If N is negative, the label
123 will be placed at column 1. If N is non-negative, the indent of
124 the label will be the prevailing indent minus N. (default -1).
125***************
126*** 229,234 ****
127--- 243,249 ----
128 } } }
129 } } }
130 <
131+ *cino-:*
132 :N Place case labels N characters from the indent of the switch().
133 (default 'shiftwidth').
134
135***************
136*** 240,245 ****
137--- 255,261 ----
138 default: default:
139 } }
140 <
141+ *cino-=*
142 =N Place statements occurring after a case label N characters from
143 the indent of the label. (default 'shiftwidth').
144
145***************
146*** 247,252 ****
147--- 263,269 ----
148 case 11: case 11: a = a + 1;
149 a = a + 1; b = b + 1;
150 <
151+ *cino-l*
152 lN If N != 0 Vim will align with a case label instead of the
153 statement after it in the same line.
154
155***************
156*** 256,261 ****
157--- 273,279 ----
158 break; break;
159 } }
160 <
161+ *cino-b*
162 bN If N != 0 Vim will align a final "break" with the case label,
163 so that case..break looks like a sort of block. (default: 0).
164 When using 1, consider adding "0=break" to 'cinkeys'.
165***************
166*** 272,277 ****
167--- 290,296 ----
168 break; break;
169 } }
170 <
171+ *cino-g*
172 gN Place C++ scope declarations N characters from the indent of the
173 block they are in. (default 'shiftwidth'). A scope declaration
174 can be "public:", "protected:" or "private:".
175***************
176*** 283,288 ****
177--- 302,308 ----
178 private: private:
179 } }
180 <
181+ *cino-h*
182 hN Place statements occurring after a C++ scope declaration N
183 characters from the indent of the label. (default
184 'shiftwidth').
185***************
186*** 291,296 ****
187--- 311,331 ----
188 public: public: a = a + 1;
189 a = a + 1; b = b + 1;
190 <
191+ *cino-N*
192+ NN Indent inside C++ namespace N characters extra compared to a
193+ normal block. (default 0).
194+
195+ cino= cino=N-s >
196+ namespace { namespace {
197+ void function(); void function();
198+ } }
199+
200+ namespace my namespace my
201+ { {
202+ void function(); void function();
203+ } }
204+ <
205+ *cino-p*
206 pN Parameter declarations for K&R-style function declarations will
207 be indented N characters from the margin. (default
208 'shiftwidth').
209***************
210*** 300,305 ****
211--- 335,341 ----
212 int a; int a; int a;
213 char b; char b; char b;
214 <
215+ *cino-t*
216 tN Indent a function return type declaration N characters from the
217 margin. (default 'shiftwidth').
218
219***************
220*** 307,312 ****
221--- 343,349 ----
222 int int int
223 func() func() func()
224 <
225+ *cino-i*
226 iN Indent C++ base class declarations and constructor
227 initializations, if they start in a new line (otherwise they
228 are aligned at the right side of the ':').
229***************
230*** 330,335 ****
231--- 368,374 ----
232 a = b + 9 * a = b + 9 *
233 c; c;
234 <
235+ *cino-c*
236 cN Indent comment lines after the comment opener, when there is no
237 other text with which to align, N characters from the comment
238 opener. (default 3). See also |format-comments|.
239***************
240*** 339,344 ****
241--- 378,384 ----
242 text. text.
243 */ */
244 <
245+ *cino-C*
246 CN When N is non-zero, indent comment lines by the amount specified
247 with the c flag above even if there is other text behind the
248 comment opener. (default 0).
249***************
250*** 349,360 ****
251--- 389,402 ----
252 ********/ ********/
253 < (Example uses ":set comments& comments-=s1:/* comments^=s0:/*")
254
255+ *cino-/*
256 /N Indent comment lines N characters extra. (default 0).
257 cino= cino=/4 >
258 a = b; a = b;
259 /* comment */ /* comment */
260 c = d; c = d;
261 <
262+ *cino-(*
263 (N When in unclosed parentheses, indent N characters from the line
264 with the unclosed parentheses. Add a 'shiftwidth' for every
265 unclosed parentheses. When N is 0 or the unclosed parentheses
266***************
267*** 370,375 ****
268--- 412,418 ----
269 (c2 || c3)) (c2 || c3))
270 { {
271 <
272+ *cino-u*
273 uN Same as (N, but for one level deeper. (default 'shiftwidth').
274
275 cino= cino=u2 >
276***************
277*** 377,382 ****
278--- 420,426 ----
279 && (c22345 && (c22345
280 || c3)) || c3))
281 <
282+ *cino-U*
283 UN When N is non-zero, do not ignore the indenting specified by
284 ( or u in case that the unclosed parentheses is the first
285 non-white character in its line. (default 0).
286***************
287*** 388,393 ****
288--- 432,438 ----
289 c3 c3
290 ) && c4; ) && c4;
291 <
292+ *cino-2*
293 wN When in unclosed parentheses and N is non-zero and either
294 using "(0" or "u0", respectively, or using "U0" and the unclosed
295 parentheses is the first non-white character in its line, line
296***************
297*** 400,405 ****
298--- 445,451 ----
299 || c3)) || c3))
300 foo; foo;
301 <
302+ *cino-W*
303 WN When in unclosed parentheses and N is non-zero and either
304 using "(0" or "u0", respectively and the unclosed parentheses is
305 the last non-white character in its line and it is not the
306***************
307*** 414,419 ****
308--- 460,466 ----
309 a_short_line(argument, a_short_line(argument,
310 argument); argument);
311 <
312+ *cino-m*
313 mN When N is non-zero, line up a line starting with a closing
314 parentheses with the first character of the line with the
315 matching opening parentheses. (default 0).
316***************
317*** 428,433 ****
318--- 475,481 ----
319 ) )
320 foo; foo;
321 <
322+ *cino-M*
323 MN When N is non-zero, line up a line starting with a closing
324 parentheses with the first character of the previous line.
325 (default 0).
326***************
327*** 437,443 ****
328 cond2 cond2
329 ) )
330 <
331! *java-cinoptions* *java-indenting*
332 jN Indent java anonymous classes correctly. The value 'N' is
333 currently unused but must be non-zero (e.g. 'j1'). 'j1' will
334 indent for example the following code snippet correctly: >
335--- 485,491 ----
336 cond2 cond2
337 ) )
338 <
339! *java-cinoptions* *java-indenting* *cino-j*
340 jN Indent java anonymous classes correctly. The value 'N' is
341 currently unused but must be non-zero (e.g. 'j1'). 'j1' will
342 indent for example the following code snippet correctly: >
343***************
344*** 448,454 ****
345 }
346 });
347 <
348! *javascript-cinoptions* *javascript-indenting*
349 JN Indent JavaScript object declarations correctly by not confusing
350 them with labels. The value 'N' is currently unused but must be
351 non-zero (e.g. 'J1'). >
352--- 496,502 ----
353 }
354 });
355 <
356! *javascript-cinoptions* *javascript-indenting* *cino-J*
357 JN Indent JavaScript object declarations correctly by not confusing
358 them with labels. The value 'N' is currently unused but must be
359 non-zero (e.g. 'J1'). >
360***************
361*** 483,489 ****
362
363
364 The defaults, spelled out in full, are:
365! cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,
366 c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0
367
368 Vim puts a line in column 1 if:
369--- 534,540 ----
370
371
372 The defaults, spelled out in full, are:
373! cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s,
374 c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0
375
376 Vim puts a line in column 1 if:
377*** ../mercurial/vim73/src/misc1.c 2011-05-25 13:33:59.000000000 +0200
378--- src/misc1.c 2011-05-25 14:57:31.000000000 +0200
379***************
380*** 4959,4964 ****
381--- 4959,4965 ----
382 static int corr_ind_maxparen __ARGS((int ind_maxparen, pos_T *startpos));
383 static int find_last_paren __ARGS((char_u *l, int start, int end));
384 static int find_match __ARGS((int lookfor, linenr_T ourscope, int ind_maxparen, int ind_maxcomment));
385+ static int cin_is_cpp_namespace __ARGS((char_u *));
386
387 static int ind_hash_comment = 0; /* # starts a comment */
388
389***************
390*** 5221,5226 ****
391--- 5222,5271 ----
392 return (*(s = cin_skipcomment(s + i)) == ':' && s[1] != ':');
393 }
394
395+ /* Maximum number of lines to search back for a "namespace" line. */
396+ #define FIND_NAMESPACE_LIM 20
397+
398+ /*
399+ * Recognize a "namespace" scope declaration.
400+ */
401+ static int
402+ cin_is_cpp_namespace(s)
403+ char_u *s;
404+ {
405+ char_u *p;
406+ int has_name = FALSE;
407+
408+ s = cin_skipcomment(s);
409+ if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9])))
410+ {
411+ p = cin_skipcomment(skipwhite(s + 9));
412+ while (*p != NUL)
413+ {
414+ if (vim_iswhite(*p))
415+ {
416+ has_name = TRUE; /* found end of a name */
417+ p = cin_skipcomment(skipwhite(p));
418+ }
419+ else if (*p == '{')
420+ {
421+ break;
422+ }
423+ else if (vim_iswordc(*p))
424+ {
425+ if (has_name)
426+ return FALSE; /* word character after skipping past name */
427+ ++p;
428+ }
429+ else
430+ {
431+ return FALSE;
432+ }
433+ }
434+ return TRUE;
435+ }
436+ return FALSE;
437+ }
438+
439 /*
440 * Return a pointer to the first non-empty non-comment character after a ':'.
441 * Return NULL if not found.
442***************
443*** 6296,6301 ****
444--- 6341,6351 ----
445 */
446 int ind_keep_case_label = 0;
447
448+ /*
449+ * handle C++ namespace
450+ */
451+ int ind_cpp_namespace = 0;
452+
453 pos_T cur_curpos;
454 int amount;
455 int scope_amount;
456***************
457*** 6336,6341 ****
458--- 6386,6392 ----
459 int n;
460 int iscase;
461 int lookfor_break;
462+ int lookfor_cpp_namespace = FALSE;
463 int cont_amount = 0; /* amount for continuation line */
464 int original_line_islabel;
465
466***************
467*** 6409,6414 ****
468--- 6460,6466 ----
469 case 'J': ind_js = n; break;
470 case 'l': ind_keep_case_label = n; break;
471 case '#': ind_hash_comment = n; break;
472+ case 'N': ind_cpp_namespace = n; break;
473 }
474 if (*options == ',')
475 ++options;
476***************
477*** 6976,6986 ****
478--- 7028,7051 ----
479 if (start_brace == BRACE_IN_COL0) /* '{' is in column 0 */
480 {
481 amount = ind_open_left_imag;
482+ lookfor_cpp_namespace = TRUE;
483+ }
484+ else if (start_brace == BRACE_AT_START &&
485+ lookfor_cpp_namespace) /* '{' is at start */
486+ {
487+
488+ lookfor_cpp_namespace = TRUE;
489 }
490 else
491 {
492 if (start_brace == BRACE_AT_END) /* '{' is at end of line */
493+ {
494 amount += ind_open_imag;
495+
496+ l = skipwhite(ml_get_curline());
497+ if (cin_is_cpp_namespace(l))
498+ amount += ind_cpp_namespace;
499+ }
500 else
501 {
502 /* Compensate for adding ind_open_extra later. */
503***************
504*** 7151,7156 ****
505--- 7216,7261 ----
506 else
507 amount += ind_continuation;
508 }
509+ else if (lookfor_cpp_namespace)
510+ {
511+ if (curwin->w_cursor.lnum == ourscope)
512+ continue;
513+
514+ if (curwin->w_cursor.lnum == 0
515+ || curwin->w_cursor.lnum
516+ < ourscope - FIND_NAMESPACE_LIM)
517+ break;
518+
519+ l = ml_get_curline();
520+
521+ /*
522+ * If we're in a comment now, skip to the start of the
523+ * comment.
524+ */
525+ trypos = find_start_comment(ind_maxcomment);
526+ if (trypos != NULL)
527+ {
528+ curwin->w_cursor.lnum = trypos->lnum + 1;
529+ curwin->w_cursor.col = 0;
530+ continue;
531+ }
532+
533+ /*
534+ * Skip preprocessor directives and blank lines.
535+ */
536+ if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
537+ continue;
538+
539+ if (cin_is_cpp_namespace(l))
540+ {
541+ amount += ind_cpp_namespace;
542+ break;
543+ }
544+
545+ if (cin_nocode(l))
546+ continue;
547+
548+ }
549 else if (lookfor != LOOKFOR_TERM
550 && lookfor != LOOKFOR_CPP_BASECLASS)
551 {
552*** ../mercurial/vim73/src/testdir/test3.in 2011-05-25 13:33:59.000000000 +0200
553--- src/testdir/test3.in 2011-05-25 14:47:31.000000000 +0200
554***************
555*** 799,804 ****
556--- 799,867 ----
557 df */
558 hello
559 }
560+
561+ /* valid namespaces with normal indent */
562+ namespace
563+ {
564+ {
565+ 111111111111;
566+ }
567+ }
568+ namespace /* test */
569+ {
570+ 11111111111111111;
571+ }
572+ namespace // test
573+ {
574+ 111111111111111111;
575+ }
576+ namespace
577+ {
578+ 111111111111111111;
579+ }
580+ namespace test
581+ {
582+ 111111111111111111;
583+ }
584+ namespace{
585+ 111111111111111111;
586+ }
587+ namespace test{
588+ 111111111111111111;
589+ }
590+ namespace {
591+ 111111111111111111;
592+ }
593+ namespace test {
594+ 111111111111111111;
595+ namespace test2 {
596+ 22222222222222222;
597+ }
598+ }
599+
600+ /* invalid namespaces use block indent */
601+ namespace test test2 {
602+ 111111111111111111111;
603+ }
604+ namespace11111111111 {
605+ 111111111111;
606+ }
607+ namespace() {
608+ 1111111111111;
609+ }
610+ namespace()
611+ {
612+ 111111111111111111;
613+ }
614+ namespace test test2
615+ {
616+ 1111111111111111111;
617+ }
618+ namespace111111111
619+ {
620+ 111111111111111111;
621+ }
622+
623 /* end of AUTO */
624
625 STARTTEST
626***************
627*** 1428,1433 ****
628--- 1491,1566 ----
629 }
630
631 STARTTEST
632+ :set cino=N-s
633+ /namespaces
634+ =/^NAMESPACEEND
635+ ENDTEST
636+
637+ /* valid namespaces with normal indent */
638+ namespace
639+ {
640+ {
641+ 111111111111;
642+ }
643+ }
644+ namespace /* test */
645+ {
646+ 11111111111111111;
647+ }
648+ namespace // test
649+ {
650+ 111111111111111111;
651+ }
652+ namespace
653+ {
654+ 111111111111111111;
655+ }
656+ namespace test
657+ {
658+ 111111111111111111;
659+ }
660+ namespace{
661+ 111111111111111111;
662+ }
663+ namespace test{
664+ 111111111111111111;
665+ }
666+ namespace {
667+ 111111111111111111;
668+ }
669+ namespace test {
670+ 111111111111111111;
671+ namespace test2 {
672+ 22222222222222222;
673+ }
674+ }
675+
676+ /* invalid namespaces use block indent */
677+ namespace test test2 {
678+ 111111111111111111111;
679+ }
680+ namespace11111111111 {
681+ 111111111111;
682+ }
683+ namespace() {
684+ 1111111111111;
685+ }
686+ namespace()
687+ {
688+ 111111111111111111;
689+ }
690+ namespace test test2
691+ {
692+ 1111111111111111111;
693+ }
694+ namespace111111111
695+ {
696+ 111111111111111111;
697+ }
698+ NAMESPACEEND
699+
700+
701+ STARTTEST
702 :g/^STARTTEST/.,/^ENDTEST/d
703 :1;/start of AUTO/,$wq! test.out
704 ENDTEST
705*** ../mercurial/vim73/src/testdir/test3.ok 2011-05-25 13:33:59.000000000 +0200
706--- src/testdir/test3.ok 2011-05-25 14:48:02.000000000 +0200
707***************
708*** 787,792 ****
709--- 787,855 ----
710 df */
711 hello
712 }
713+
714+ /* valid namespaces with normal indent */
715+ namespace
716+ {
717+ {
718+ 111111111111;
719+ }
720+ }
721+ namespace /* test */
722+ {
723+ 11111111111111111;
724+ }
725+ namespace // test
726+ {
727+ 111111111111111111;
728+ }
729+ namespace
730+ {
731+ 111111111111111111;
732+ }
733+ namespace test
734+ {
735+ 111111111111111111;
736+ }
737+ namespace{
738+ 111111111111111111;
739+ }
740+ namespace test{
741+ 111111111111111111;
742+ }
743+ namespace {
744+ 111111111111111111;
745+ }
746+ namespace test {
747+ 111111111111111111;
748+ namespace test2 {
749+ 22222222222222222;
750+ }
751+ }
752+
753+ /* invalid namespaces use block indent */
754+ namespace test test2 {
755+ 111111111111111111111;
756+ }
757+ namespace11111111111 {
758+ 111111111111;
759+ }
760+ namespace() {
761+ 1111111111111;
762+ }
763+ namespace()
764+ {
765+ 111111111111111111;
766+ }
767+ namespace test test2
768+ {
769+ 1111111111111111111;
770+ }
771+ namespace111111111
772+ {
773+ 111111111111111111;
774+ }
775+
776 /* end of AUTO */
777
778
779***************
780*** 1273,1275 ****
781--- 1336,1403 ----
782 baz();
783 }
784
785+
786+ /* valid namespaces with normal indent */
787+ namespace
788+ {
789+ {
790+ 111111111111;
791+ }
792+ }
793+ namespace /* test */
794+ {
795+ 11111111111111111;
796+ }
797+ namespace // test
798+ {
799+ 111111111111111111;
800+ }
801+ namespace
802+ {
803+ 111111111111111111;
804+ }
805+ namespace test
806+ {
807+ 111111111111111111;
808+ }
809+ namespace{
810+ 111111111111111111;
811+ }
812+ namespace test{
813+ 111111111111111111;
814+ }
815+ namespace {
816+ 111111111111111111;
817+ }
818+ namespace test {
819+ 111111111111111111;
820+ namespace test2 {
821+ 22222222222222222;
822+ }
823+ }
824+
825+ /* invalid namespaces use block indent */
826+ namespace test test2 {
827+ 111111111111111111111;
828+ }
829+ namespace11111111111 {
830+ 111111111111;
831+ }
832+ namespace() {
833+ 1111111111111;
834+ }
835+ namespace()
836+ {
837+ 111111111111111111;
838+ }
839+ namespace test test2
840+ {
841+ 1111111111111111111;
842+ }
843+ namespace111111111
844+ {
845+ 111111111111111111;
846+ }
847+ NAMESPACEEND
848+
849+
850*** ../vim-7.3.201/src/version.c 2011-05-25 13:33:59.000000000 +0200
851--- src/version.c 2011-05-25 15:14:20.000000000 +0200
852***************
853*** 711,712 ****
854--- 711,714 ----
855 { /* Add new patch number below this line */
856+ /**/
857+ 202,
858 /**/
859
860--
861hundred-and-one symptoms of being an internet addict:
862107. When using your phone you forget that you don't have to use your
863 keyboard.
864
865 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
866/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
867\\\ an exciting new programming language -- http://www.Zimbu.org ///
868 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///