On Di, 13 Feb 2018, Genki Sky wrote:

> --> Motivation
> The attached patch adds a new autocmd event that is triggered on
> normal-mode search commands. The use case I have is the following:
>   :au SearchCommand * setl cursorline | setl cursorcolumn
> which would make it easier to see which search result your cursor is
> focused on while jumping around. I also found someone online asking
> for an autocmd that did this:
>   https://stackoverflow.com/q/37812852
> --> Thoughts on where to trigger the autocmd
> First, I thought about triggering the event only if !(opts &
> SEARCH_KEEP) inside do_search(), as a general way to catch search
> commands that are to some extent user-visible. So in addition to the
> normal-mode search commands, this would also trigger on:
>   - :/ and :? due to get_address() and cmdline_not_changed case in
>     getcmdline().
>   - gui_do_find_repl()
>   - jumpto_tag(), if 'cpoption' contains 't'
> However, I didn't like this for a few reasons:
>   - Complicated to describe in the documentation
>   - It's nice that one can use :/ and :? as an easy escape-hatch to do
>     what / and ? do without triggering the autocmd.
>   - gui_do_find_repl() and jumpto_tag() didn't seem to match the use
>     cases I had in mind.
>   - It loses context about how the search is being used; looking at
>     SEARCH_KEEP is insufficient. More on this below.
> So I thought about doing it in normal_search(). However, I noticed
> that nv_next() calls normal_search() twice in a special cirumstance.
> --> The patch
> So, rather than adding some boolean flag, and because there were only
> three functions that call normal_search(), I decided to trigger the
> event in those three functions instead.
> As suggested by CONTRIBUTING.md, I have attached a unified-diff format
> patch, along with documentation updates and an accompanying test.
> Specifically, I modified test_autocmd.vim to check that normal-mode
> search commands trigger the event exactly-once, and that other similar
> search features do not trigger it at all.
> Let me know if anything else needs to be done.

thanks for contributing. However I wonder what the Search autocommand 
can do, what cannot be achieved using the CmdlineEnter and CmdlineLeave 
event (see the example given at :h 'incsearch').


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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui