Christian Brabandt wrote:
> Hi Michał!
>
> On Di, 07 Aug 2012, Michał Górny wrote:
>
> > Hello,
> >
> > I am working on a C project where the coding style enforces using tab
> > indentation only. Thus, I would like to enforce that policy via
> > modeline without affecting user preferred tabstop.
> >
> > In order to do that, right now I use:
> > // vim:noet:sts=0
> >
> > Sadly, I don't think it is currently possible to reset shiftwidth to
> > the value of tabstop. Thus, a user having 'ts=8:sw=4' in his
> > preferences will still be inserting spaces.
> >
> > Thus, I'd like to request the following feature: option to reset
> > the shiftwidth to the value of tabstop. Practically, it could be
> > implemented by allowing 'sw=0' (much like 'sts=0'), and using the value
> > of 'ts' in that case.
> >
> > Right now, setting 'sw=0' is prohibited so I don't think this would
> > introduce any compatibility problems. Of course, the 'sw=0' will be
> > useful only in modelines for newer vim versions.
>
> Actually, I think, although Vim complains, It already sets 'sw' to the
> current value of 'ts', if 'sw' is less than 1.
>
>
> ,----[ option.c ]-
> | [...]
> | if (curbuf->b_p_sw <= 0)
> | {
> | errmsg = e_positive;
> | curbuf->b_p_sw = curbuf->b_p_ts;
> | }
> | [...]
> `----
>
> But anyhow, here is a patch, which should do what you want. Let's see,
> what Bram thinks.
I think the idea to have 'sw' set to zero behave like it's set to 'ts'
makes a lot of sense.
In your patch you have an awful lot of:
sw = curbuf->b_p_sw ? curbuf->b_p_sw : curbuf->b_p_ts;
I think we should have a function get_sw_value(); Calling a function
without arguments is efficient, no need to have this code in many
places. It appears curbuf is used in all cases.
Can you also make a patch for the help?
--
hundred-and-one symptoms of being an internet addict:
219. Your spouse has his or her lawyer deliver the divorce papers...
via e-mail.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
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