On Wed, Jun 03, 2009 at 11:53:37AM +0200, Bram Moolenaar wrote: > > James - > > > Using = when Vim was built with -cindent and the user hasn't set > > 'equalprg' filters the text through the external command `indent'. As > > this behavior isn't documented, it's a surprise to the user and can > > cause the text-to-be-indented to be deleted or replaced with error > > messages from the shell. > > This is old Vi behavior, AFAIK.
Taking a look at Opengroup's documentation for vi[0] and the actual vi (now called ex-vi) code[1], this doesn't seem to be the case. Opengroup doesn't mention an = command (except that POSIX specifies a reindent command) and ex-vi shows that it simply indents as if 'lisp' were set -- no filtering. > > The attached patch is a proposed solution which instead emits an error > > telling the user that 'equalprg' needs to be set. I've added the > > explanation to ='s help as well, with a help tag for the new error > > number. > > I don't think changing the behavior is a good idea. Executing an arbitrary command which the user may or may not have installed, in contrast to the behavior when Vim has +cindent, doesn't seem like a good idea. Especially since the only visible difference between using = in a Vim with -cindent may be that indenting deletes the content of your line. It's likely that the scenarios where Vim is compiled without cindent are for systems with minimal installs (since you need to use --with-features=small or tiny). So using such a Vim seems like a situation where you're more likely to not have indent installed than otherwise. This is why it seemed that being explicit and telling the user 'equalprg' needs to be set sounded like a viable option to me. > I'll add a comment > at 'equalprg' about what happens when it's empty. And in change.txt: > > ={motion} Filter {motion} lines through the external program > given with the 'equalprg' option. When the 'equalprg' > option is empty (this is the default), use the > internal formatting function |C-indenting|. But when > 'indentexpr' is not empty, it will be used instead > |indent-expression|. When Vim was compiled without > internal formatting then the "indent" program is used > as a last resort. If I haven't swayed you, this looks like a good addition. Thanks. :) [0] - http://www.opengroup.org/onlinepubs/009695399/utilities/vi.html [1] - http://ex-vi.sourceforge.net/ -- James GPG Key: 1024D/61326D40 2003-09-02 James Vega <james...@debian.org>
signature.asc
Description: Digital signature