To: vim-dev@vim.org Subject: patch 7.0.222 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.0.222 Problem: Perl indenting using 'cindent' works almost right. Solution: Recognize '#' to start a comment. (Alex Manoussakis) Added '#' flag in 'cinoptions'. Files: runtime/doc/indent.txt, src/misc1.c *** ../vim-7.0.221/runtime/doc/indent.txt Sun May 7 17:00:59 2006 --- runtime/doc/indent.txt Sat Mar 17 16:27:57 2007 *************** *** 1,4 **** ! *indent.txt* For Vim version 7.0. Last change: 2006 Apr 30 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *indent.txt* For Vim version 7.0. Last change: 2007 Mar 17 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 434,443 **** limits the time needed to search for the start of a comment. (default 30 lines). The defaults, spelled out in full, are: cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,c3,C0, ! /0,(2s,us,U0,w0,W0,m0,j0,)20,*30 Vim puts a line in column 1 if: - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'. --- 434,448 ---- limits the time needed to search for the start of a comment. (default 30 lines). + #N When N is non-zero recognize shell/Perl comments, starting with + '#'. Default N is zero: don't recognizes '#' comments. Note + that lines starting with # will still be seen as preprocessor + lines. + The defaults, spelled out in full, are: cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,c3,C0, ! /0,(2s,us,U0,w0,W0,m0,j0,)20,*30,#0 Vim puts a line in column 1 if: - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'. *** ../vim-7.0.221/src/misc1.c Tue Oct 24 21:15:09 2006 --- src/misc1.c Sat Mar 17 16:36:00 2007 *************** *** 4796,4803 **** --- 4796,4806 ---- static int find_last_paren __ARGS((char_u *l, int start, int end)); static int find_match __ARGS((int lookfor, linenr_T ourscope, int ind_maxparen, int ind_maxcomment)); + static int ind_hash_comment = 0; /* # starts a comment */ + /* * Skip over white space and C comments within the line. + * Also skip over Perl/shell comments if desired. */ static char_u * cin_skipcomment(s) *************** *** 4805,4811 **** --- 4808,4824 ---- { while (*s) { + char_u *prev_s = s; + s = skipwhite(s); + + /* Perl/shell # comment comment continues until eol. Require a space + * before # to avoid recognizing $#array. */ + if (ind_hash_comment != 0 && s != prev_s && *s == '#') + { + s += STRLEN(s); + break; + } if (*s != '/') break; ++s; *************** *** 6133,6139 **** if (l[1] == '-') n = -n; /* When adding an entry here, also update the default 'cinoptions' in ! * change.txt, and add explanation for it! */ switch (*l) { case '>': ind_level = n; break; --- 6146,6152 ---- if (l[1] == '-') n = -n; /* When adding an entry here, also update the default 'cinoptions' in ! * doc/indent.txt, and add explanation for it! */ switch (*l) { case '>': ind_level = n; break; *************** *** 6166,6171 **** --- 6179,6185 ---- case 'h': ind_scopedecl_code = n; break; case 'j': ind_java = n; break; case 'l': ind_keep_case_label = n; break; + case '#': ind_hash_comment = n; break; } } *** ../vim-7.0.221/src/version.c Tue Mar 27 10:20:59 2007 --- src/version.c Tue Mar 27 10:56:50 2007 *************** *** 668,669 **** --- 668,671 ---- { /* Add new patch number below this line */ + /**/ + 222, /**/ -- My Go , this amn keyboar oesn't have a . /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///