Hi James
Hi Bram

On 2015-07-29 Wednesday at 21:51 -0400 James McCoy wrote:
> On Wed, Jul 29, 2015 at 10:17:25PM +0200, Bram Moolenaar wrote:
> > > > 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.
> > > 
> > > Just to clarify, was that a suggested replacement for the last bullet in
> > > my description or for the entire interface?
> > 
> > It would replace the register and variables.
> 
> Updated patch attached.
> …

> diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
> index d9f49ae..893624a 100644
> --- a/runtime/doc/eval.txt
> +++ b/runtime/doc/eval.txt
> @@ -1822,6 +1822,7 @@ getbufvar( {expr}, {varname} [, {def}])
>                               any     variable {varname} in buffer {expr}
>  getchar( [expr])             Number  get one character from the user
>  getcharmod( )                        Number  modifiers for the last typed 
> character
> +getcharsearch()                      Dict    last character search
>  getcmdline()                 String  return the current command-line
>  getcmdpos()                  Number  return cursor position in command-line
>  getcmdtype()                 String  return current command-line type
> @@ -1971,6 +1972,7 @@ server2client( {clientid}, {string})
>                               Number  send reply string
>  serverlist()                 String  get a list of available servers
>  setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val}
> +setcharsearch( {dict})               Dict    set character search from {dict}
>  setcmdpos( {pos})            Number  set cursor position in command-line
>  setline( {lnum}, {line})     Number  set line {lnum} to {line}
>  setloclist( {nr}, {list}[, {action}])
> @@ -3361,6 +3363,26 @@ getcharmod()                                           
> *getcharmod()*
>               character itself are obtained.  Thus Shift-a results in "A"
>               without a modifier.
>  
> +getcharsearch()                                              
> *getcharsearch()*
> +             Return the current character search information as a {dict}
> +             with the following entries:
> +
> +                 char        character previously used for a character
> +                             search (|t|, |f|, |T|, or |F|); empty string
> +                             if no character search has been performed
> +                 forward     direction of character search; 1 for forward,
> +                             0 for backward
> +                 until       type of character search; 1 for a |t| or |T|
> +                             character search, 0 for an |f| or |F|
> +                             character search

Instead of “forward” and “until” entries having an entry “command” with the 
four 
legal values “f” “F” “t” “T” would be easier to memorize.

What do you think?

> +
> +             This can be useful to always have |;| and |,| search
> +             forward/backward regardless of the direction of the previous
> +             character search: >
> +                     :nnoremap <expr> ; getcharsearch().forward ? ';' : ','
> +                     :nnoremap <expr> , getcharsearch().forward ? ',' : ';'

Exactly this usage would be my first addition to my vimrc after rebuilding vim 
with this patch applied.  Adjusted for the variant I proposed above:

    :nnoremap <expr> ; getcharsearch().command =~# /[ft]/ ? ';' : ','
    :nnoremap <expr> , getcharsearch().command =~# /[FT]/ ? ',' : ';'

For string search repetition we have
    :nnoremap n /<CR>
    :nnoremap N ?<CR>
but the analogy with “f<CR>” “F<CR>” does not work.  Therefore this patch seems 
very useful to me.

Thank you!



-- 
Best regards,
Roland Eggner

-- 
-- 
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.

Attachment: pgp4caJma_xY8.pgp
Description: PGP signature

Raspunde prin e-mail lui