I implemented a fuzzy filter, which

  • accept a list argument,
  • open a window with a scratch buffer whose content set to the list, then
  • waiting for use input and do filtering.

Here is why I ask this question, in the key loop, I want

  • after / was type, go into a pass through mode, just like / was typed in normal mode, thus subsquent keys will do search, and move cursor of the scratch window, since incsearch was set,
  • after <C-c> or <C-m> was typed, return back to previous key loop mode.

Is there any way to achieve above effect? I tried define a Handler for /, which getchar() then feedkeys() after feedkeys('/'), but seems caused infinite recursion/loop, which bumps cpu usage to 24%.

  • let me see if I've got this right: you create a scratch buffer with content. On /, you want to feedkeys('/') in order to search (so you probably did a mapping). feedkeys() takes a flag to not use mappings... but you could also consider using whatever other programs like :FZF or Unite is using these days – D. Ben Knoble Nov 12 '19 at 3:10
  • using sleep might help with the cpu – Mass Nov 12 '19 at 3:51
  • @D.BenKnoble Ben Knoble, I do use plugins, ctrlp and LearderF, both used extensively actually. But non of the plugins around support behavior I wanted, thus I want implement it myself. – qeatzy Nov 12 '19 at 4:24
  • @Mass No, the problem is I was in a loop of getchar(), call feedkeys() there cause the arguments of feedkeys() feeded to the loop itself, thus resulting infinite loop. – qeatzy Nov 12 '19 at 4:26
  • What I want is inside of key loop that accept user input, to switch to search mode, to move cursor faster than press <up> <down>, its kinda like a key loop inside of key loop, or switch to normal mode, doing search, then restore previous key loop after search finished. – qeatzy Nov 12 '19 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.