Re: [patch] autocmd: Add event for normal-mode search command
Oops, sorry for the too-hasty reply. I realized after sending I can of course nnoremap the remaining ones that I mentioned. Altogether, seems like I can workaround this issue. Thanks for your time again. -- -- 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.
Re: [patch] autocmd: Add event for normal-mode search command
Hi Christian, Quoting Christian Brabandt (2018/02/13 04:42:25 -0500) > 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'). Thanks for the pointer, I did not realize CmdlineEnter could be used in this way. It looks like this satisfies what I had in mind for / and ?. However, based on testing and reading the code, it does not seem to trigger on the other commands in 'search-commands' that might have multiple results, namely: n, N, *, #, g*, and g# . (Well, this makes sense as these missing ones are not almost-cmd-line commands like / and ? are..., but it is nonetheless a downside for me). If there is something I am still missing, please let me know. Otherwise, I would still like to have this feature in vim; it doesn't seem there is a good workaround. However, if the patch is still not desired, no hard feelings. Thanks, Genki -- -- 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.
Re: [patch] autocmd: Add event for normal-mode search command
Hi, 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'). Best, Christian -- -- 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.