Vimpulse and vim-mode
frank.fischer at mathematik.tu-chemnitz.de
Mon Feb 28 21:57:20 CET 2011
On Mon, Feb 28, 2011 at 04:33:59PM +0100, Vegard Øye wrote:
> > The other question that comes into my mind is the following. In
> > vim-mode, as I told, I prevent an operator to be executed until the
> > following motion has been executed. This can be done as above if the
> > interactive form uses some kind of recursive edit (right?).
> I don't understand ... the motion is executed in the operator's
> `interactive' specification, /before/ the operator's body. When you
> press "dw", "d" calls `delete', `delete' reads "w", "w" is bound to
> `forward-word', `forward-word' is executed to get buffer positions,
> and the positions are passed to the operator's arguments. Then the
> operator's body is executed. Are we talking about the same thing?
It's just the difference to how vim-mode combines motions and
operators. In vim-mode operator-pending is just a state as any other
state, insert, normal or visual. When an operator is executed, the
command's body is not executed immediately. Instead it is remembered
for later use, then vim-mode switches to operator-pending mode and
gives the control completely back to Emacs. When a motion is executed
in operator-pending mode the stored operator is finally executed along
with the motion. Similar things happen when a register is selected. In
this case the register is stored and then vim-mode returns to normal
mode and proceeds as usual.
So vim-mode never uses interactive stuff, that's all. But I like the
idea of using interactive extensively.
Little question: do you really use Emacs's default forward-word? I ask
because it behaves differently than Vim's.
> > And I have a further question. We must certainly specify some
> > additional properties for commands, e.g., some commands are
> > repeatable while others are not repeatable, some should preserve
> > visual-mode (e.g., several window and scrolling commands which are
> > not really motions - they cannot be used with an operator and
> > sometimes don't even change point) while others disable visual-mode
> > (most editing commands). How do we specify theses properties?
> I prefer to use keyword arguments:
> (vimpulse-define-operator vimpulse-indent (beg end)
> "Indent text."
> :repeat nil
> :whole-lines t
> (indent-region beg end nil))
Sounds okay. In fact, this was the old style I used in earlier versions ;)
More information about the implementations-list