On Tue, 26 Jul 2016, Ben Fritz wrote:

On Tuesday, July 26, 2016 at 12:47:43 AM UTC-5, Rob Foehl wrote:
On Mon, 25 Jul 2016, Ben Fritz wrote:

Makefiles are the only place I can think of where I use 'preserveindent' and 
'copyindent'.

This way recipes always have the syntactically required leading TAB indent, but 
any spaces used for indent or alignment afterward are maintained when I 
add/remove indent or create a new line in the recipe.

Are you sure?  Try adding indentation across lines with tabs-before-spaces
indentation and alignment, with 'listchars' set to some value that'll make
the tabs obvious.  I don't think it does what you expect, which is kinda
my point here... ;)


Yes, I'm sure. I tested with 'expandtab' set on a makefile with a single tab 
and 4 spaces on a line, with 'shiftwidth' and 'tabstop' both set to 4.

Okay, but you're testing something different than I am:

(For reference, this was with ':set lcs=tab:>- ci pi noet ts=8 sw=8 sts=0'
in Vim 7.4.1868, as currently packaged in Fedora.  The 'ci' setting
doesn't actually matter here, nor does the exact shift method used.)

Setting 'expandtab' changes the way indentation is counted and filled, resulting in spaces alone. There are completely separate code paths in misc1.c:set_indent(), so you won't get the behavior I'm describing unless you set the combined 'pi noet'.

Also, setting 'expandtab' for a Makefile is... adventurous, but probably qualifies as one of those corner cases I was looking for...

Modifying the leading indentation is only what you want, if you assume the leading 
indentation matches the 'expandtab' setting. I see 'preserveindent' (especially when 
combined with 'copyindent') as explicitly telling Vim "I know my indent is weird 
here, please don't mess with it". I think it deserves a separate option if you want 
to change what part of the indentation Vim is allowed to mess with, since leading indent 
is syntactically important sometimes.

Fair enough. My assertion is that 'preserveindent' is currently not what anybody wants when 'noexpandtab' is in effect and it's inserting mixed runs of tabs and spaces. With 'expandtab' set, it results in unchanged leading indentation where possible and only new spaces inserted, which is probably reasonable behavior for that combination.

Since the behavior of 'preserveindent' is already dependent on 'expandtab', would you or anyone else be opposed to changing the 'noet' case to avoid alternating tabs and spaces? Oversimplifying a bit, and particularly glossing over 'shiftwidth' and the actual modification point, the effective behavior would be:

'pi et': preferentially adjust spaces after tabs
'pi noet': preferentially adjust tabs before spaces

This looks doable, although I haven't tried anything yet...  Thoughts?

-Rob

--
--
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/d/optout.

Raspunde prin e-mail lui