On Mi, 25 Sep 2013, Christian Brabandt wrote:
> On Mi, 25 Sep 2013, Christian Brabandt wrote:
>
> > On Wed, September 25, 2013 15:21, Bram Moolenaar wrote:
> > > 'cinoptions' is for 'cindent' options.
> >
> > So do we agree, that cino=#N with N being non-zero would allow to
> > indent 'defines'?
>
> No one complains, so here is an updated patch.
Grmml, It helps to actually attach a file. So let's try that again:
Best,
Christian
--
F: Warum heißt der Trabi Trabi?
A: Wenn er schneller wäre, würde er Galoppi heißen.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt
--- a/runtime/doc/indent.txt
+++ b/runtime/doc/indent.txt
@@ -545,10 +545,9 @@
(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 and
+ preprocessor lines, starting with '#'. Default N is zero: don't
+ recognize '#' comments.
The defaults, spelled out in full, are:
@@ -556,7 +555,7 @@
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.
diff --git a/src/misc1.c b/src/misc1.c
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -6974,7 +6974,7 @@
*/
if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE)))
{
- amount = 0;
+ amount = ind_hash_comment;
}
/*
@@ -10938,3 +10938,59 @@
{
return (p_im && stuff_empty() && typebuf_typed());
}
+
+/* return amount for the # value in the 'cino' options */
+
+ int
+cin_get_hash_amount()
+{
+ int sw = (int)get_sw_value();
+ char_u *options;
+ char_u *digits;
+ char_u *l;
+ int fraction = 0; /* init for GCC */
+ int divider;
+ int n;
+
+ for (options = curbuf->b_p_cino; *options; )
+ {
+ if (*options == '#')
+ {
+ l = options++;
+ if (*options == '-')
+ ++options;
+ digits = options; /* remember where the digits start */
+ n = getdigits(&options);
+ divider = 0;
+ if (*options == '.') /* ".5s" means a fraction */
+ {
+ fraction = atol((char *)++options);
+ while (VIM_ISDIGIT(*options))
+ {
+ ++options;
+ if (divider)
+ divider *= 10;
+ else
+ divider = 10;
+ }
+ }
+ if (*options == 's') /* "2s" means two times 'shiftwidth' */
+ {
+ if (options == digits)
+ n = sw; /* just "s" is one 'shiftwidth' */
+ else
+ {
+ n *= sw;
+ if (divider)
+ n += (sw * fraction + divider / 2) / divider;
+ }
+ ++options;
+ }
+ if (l[1] == '-')
+ n = -n;
+ return n;
+ }
+ options++;
+ }
+ return 0;
+}
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -4022,7 +4022,7 @@
# endif
# endif
# ifdef FEAT_CINDENT
- (curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE))
+ (curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE) && !cin_get_hash_amount())
# endif
;
}
diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro
--- a/src/proto/misc1.pro
+++ b/src/proto/misc1.pro
@@ -101,4 +101,5 @@
char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
void FreeWild __ARGS((int count, char_u **files));
int goto_im __ARGS((void));
+int cin_get_hash_amount __ARGS((void));
/* vim: set ft=c : */