Hi,
 The general format of a vi command is.
[repeat count] action [target]
the . [dot]  command just executes the last action for the same target,
when in insert/append etc.. mode,  the last input is the action.
so for example, you did some edits, and pressed i to insert and entered
 yi in haskell
then escape.  pressing . (dot) now will enter yi in haskell. not just the
last l.

<action> does not include movement commands, but any thing that can change
the buffer's current state
<target> can be a movement command to indicate the area of the buffer on
which to operate.

basically the mental model is that you are always in the command mode. Any
change to the buffer is the effect of the last command.

I am not sure how well that is abstracted out in Yi, but my understanding is
that any command that can change the current state of the buffer has to be
in a certain monad.  In that case, all that needs to be done is to save the
last action and its target somewhere and re use it when the dot is pressed.
the dot is syntactic sugar for typing the last command out again.

Could some thing like the following work?
1. key map actions to functions
   1.1 dot is mapped to its own function

2. execute the function in a monad
  2.1 push the function and its args on a stack
  2.2 pop the stack and  execute that function

3. when dot is pressed, peek the stack and execute that function

Since this is an Editor and needs to deal with state anyway adding another
[secret?] buffer just for commands should be easy :)

Hope that helped.
cheers
Ram


On Tue, Dec 16, 2008 at 5:02 AM, nicolas. pouillard <
nicolas.pouill...@gmail.com> wrote:

>
> Excerpts from Jean-Philippe Bernardy's message of Tue Dec 16 09:40:47 +0100
> 2008:
> > Ok, so if we have "start recording", "stop recording" and "replay"
> > that should at least help to implement the thing.
>
> Hum, that may help to implement the macro mechanism, but here what one need
> to
> record is the last change. And what is a change, is very precise. Moreover
> when changes are parameterized by a counter (like "3dw" which means delete
> 3
> words), giving a count to '.' (like "2.") will override the old counter,
> giving no count will reuse the same. Moreover as you can see the recored
> change is semantics, it will delete words regardless their size.
>
> That's why I record the last action as merely a pair of an action and a
> count:
>  ((Int -> EditorM ()), Int)
>
> In fact this repeating mechanism is very subtle and it took me a while to
> realize what structure to use and how to cleanly change the keymap.
>
> There is another part of this mechanism that may require a support from the
> core editor. That's about inserting text, inserting some text will be
> stored
> as only one change, moreover since one can also edit while inserting
> (backspace, CTRL-W, moving...), it's not clear to me what we should store:
>  - a stack of events:
>       - finished when leaving insert mode
>       - cut when moving then inserting again
>       - updated carefully when doing CTRL-W
>  - a couple of points:
>       With the same rules for cutting but less work
>       for things like CTRL-W
>  - other ideas?
>
> > On Mon, Dec 15, 2008 at 11:28 PM, Kalman Noel
> > <noel.kal...@googlemail.com> wrote:
> > >
> > > Александър Л. Димитров:
> > >> Thus spoke Jean-Philippe Bernardy:
> > >> > I am not sure what "." is supposed to do exactly, but maybe this
> would be easier
> > >> > to implement with support from the core?
> > >>
> > >> '.' should repeat the last action, exactly from the point where it
> started, to
> > >> the point where it ended.
> > >
> > > We should add that it shall do so with respect to the current cursor
> > > position.
>
> --
> Nicolas Pouillard aka Ertai
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
Yi development mailing list
yi-devel@googlegroups.com
http://groups.google.com/group/yi-devel
-~----------~----~----~----~------~----~------~--~---

Reply via email to