vimpulse bug: visual-line does not select final newline

Vegard Øye vegard_oye at hotmail.com
Thu Aug 19 02:01:25 CEST 2010


On 2010-08-18 20:07, Craig Tenney wrote:

> Here's what I've discovered: If 'vimpulse.elc' exists, 'Vyp' doesn't
> work correctly (i.e. it doesn't grab the final newline). If I delete
> the 'elc' file, 'Vyp' works as expected. If I byte-compile
> 'vimpulse.el' again, the 'Vyp' problem returns.

Thanks for this very valuable information. I've confirmed the bug,
which should be fixed in commit [edcc432584]; please test. :)

What caused the bug is that Vimpulse inspects the `interactive' form
of the command to be executed to determine if it is an operator (like
"c", "d", "y") or not. That form looks a little different when
compiled, obviously, so the inspection failed. The relation of this to
the missing newline is explained below.

> I'm still lost on the vimpulse-surround thing, but that is
> presumably someone else's domain.

I can now explain this, too. Vimpulse intentionally drops the final
newline when a non-Vimpulse command is issued on a line selection.
I've found that this integrates better with other packages, like
skeleton-mode and AUCTeX. Say you edit a TeX document and want to
convert the following line to a heading:

    Lorem ipsum

If you press "V C-c C-s" (followed by a couple of RET's), you get:

    \section{Lorem ipsum}

However, if Vimpulse included the newline, you would get this instead:

    \section{Lorem ipsum
    }

So Vimpulse tries to be clever and do the "right thing", depending on
the circumstances. If you execute one of Vimpulse's operator commands,
then the right thing is to include the newline -- to provide the
selection "as-is", so to speak. The operator will handle the rest.
In other cases, the newline is omitted.

Which is why vimpulse-surround's `vimpulse-delete-surround-or-delete'
command fails: it is not an operator -- or is not identified as one,
anyway. To be identified as an operator, the command has to call
`vimpulse-range' in its `interactive' form. Rewriting the code along
the lines of approach #2 in the post below is one solution.[1]
Another is to list the commands in `vimpulse-newline-cmds':

    (add-to-list 'vimpulse-newline-cmds 'vimpulse-change-surround-or-change)
    (add-to-list 'vimpulse-newline-cmds 'vimpulse-delete-surround-or-delete)

At this point, I think it would be beneficial to define operators with
a dedicated `vimpulse-define-operator' macro to make their special
standing more explicit. I recall Štěpán has proposed this already.

[1] http://permalink.gmane.org/gmane.emacs.vim-emulation/524

-- 
Vegard



More information about the implementations-list mailing list