James McCoy wrote:
> Recently, I've heard some script authors ponder whether there was a way
> to access information about the last character search a user performed.
> The ideas being explored were overriding ; and , to always search
> forward/backward respectively, or providing visual cues for where a
> character search would move the cursor.
>
> There exists a mechanism for script authors to interact with normal
> searches via the / register and the v:searchforward variable.
>
> The attached patch implements comparable functionality for character
> searches.
>
> * A new, read-write ; register exposes the character which would be the
> target for a subsequent ; or , command. If this register is set, then
> the direction and type of character search are (re)set as if the user
> had used t to perform the search.
>
> * A new, read-write v:csearchforward variable exposes the direction of
> the character search, similar to v:searchforward.
>
> * A new, read-write v:csearchuntil variable exposes whether the search
> is an "until" (t) search.
>
> * Any normal character searches which happen within a function or
> autocmd will not affect the user's character search state, similar to
> the handling of normal searches. However, a script author may affect
> that through using the above listed variables/register.
>
> Aside from enabling script authors to better interact with character
> searches, this also makes it easier to search for composed characters
> using character search. One currently has to create a keymap file and
> use “:loadkeymap” to easily enter a composed character as the character
> search value. With this functionality, one can instead simply “:let
> @;="a\u0301"” to search for á.
Thanks for taking the initiative for this.
How about this alternative, use functions:
getcharsearch() returns a dict with the relevant info
setcharsearch() stores the relevant info
It should be easier to save and restore the search, while all the
information is present in one place.
I think character searches are not very common in plugins, thus having
to manually save and restore is simpler and more efficient than having
all function calls do this.
--
hundred-and-one symptoms of being an internet addict:
10E. You start counting in hex.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.