[implementations-list] Vimpulse update

Alessandro Piras laynor at gmail.com
Mon Jun 22 13:34:34 CEST 2009


it's easy stuff actually :) It works like this:
I modified the viper-prefix-arg-com function to introduce 4 new commands: da
di ca ci. These commands will read-char to get motion command.
ca and ci just call da/di, and then put viper in insert mode.
da/di call the get-text-object-bounds-a/get-text-object-bounds-b function,
that can return nil (no change to the buffer) or a list of two integers,
(beginning end), with the boundaries of the text that will be deleted by the
da/di function

Then I implemented various functions that get the boundaries of the text
object under the cursor, like paren blocks (I couldn't use scan-sexps in
that it doesn't work well with stuff like "( ] )" ) paragraph and such. To
implement the functions I used some regexs, or in the case of paren blocks,
I implemented the scanners ad-hoc. For the quoted strings I also used the
built-in scan-sexps, as it was most convenient to parse the sexp backwards
(it's needed because of escaped quotes). I also used emacs syntax stuff, I
was thinking I could put another more command that deletes stuff based on
emacs' syntax classification.

The get-text-object-bounds-a/i   are very similar, in principle the a
version will enlarge the boundaries including whitespace at the
beginning/end of the text object, and eating trailing newlines too in the
case of paragraphs.
So, schematizing:

   - ca => vimpulse-ca
      -   vimpulse-da
         - char = read-char
         - get-text-object-bounds (char ... )
            - get a (beginning end) object using the relevant function:
            let's say char=W
            - vimpulse-get-vWord-bounds
            - englarge the boundaries with withespace and trailing newlines
            depending on the text object (for example for paren blocks
and string I only
            add the quotes/parens the inner block) and return it
            - delete the text enclosed in the boundaries
      - insert-mode

Hope this is clear enough, I suck a little giving overviews :)
Alessandro


2009/6/22 Marius Andersen <rezonatix3 at yahoo.no>:
>
>> Fra: Alessandro Piras <laynor at gmail.com>
>> Emne: Re: [implementations-list] Vimpulse update
>> Til: "Stephen Bach" <sjbach at sjbach.com>, "Vi/Vim implementations list" <
implementations-list at lists.ourproject.org>
>> Dato: Mandag 22. juni 2009 03.58
>>
>> By the way, new update already, now there's partial text
>> object support. Try some di(, da[, diw, das dip commands and tell
>> me what you think.
>
> Alessandro,
>
> I must say I am impressed of the pace with which you implements things! I
had a go at text objects myself some months ago, but never got any further
than redefining the gigantic `viper-prefix-arg-com' function.
>
> Out of curiosity, what are the technical details behind the new support?
>
>
>      _________________________________________________________
> Alt i ett. Få Yahoo! Mail med adressekartotek, kalender og
> notisblokk. http://no.mail.yahoo.com
>
>
> _______________________________________________
> implementations-list mailing list
> implementations-list at lists.ourproject.org
> https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
>


More information about the implementations-list mailing list