ctrlf icon indicating copy to clipboard operation
ctrlf copied to clipboard

Go to next match after "ending" search

Open ghosty141 opened this issue 3 years ago • 5 comments

Hi, I'm currently checking out ctrlf, fantastic package, but I'm missing one "key" functionality. I come from vim and I really like the way when searching with "/" you press enter, navigate around and edit some text, and then you can press "n" to go to the next occurence.

How do I replicate this behavior with ctrlf? In isearch I can do this via isearch-repeat-forward. I kinda need ctrlf-repeat-forward.

Thanks for the help in advance :)

ghosty141 avatar Oct 25 '22 19:10 ghosty141

The default binding for this would be C-s C-s. I suppose you want something shorter?

raxod502 avatar Oct 28 '22 00:10 raxod502

Ah yes this comes close! isearch keeps the highlighting, that's quite neat, maybe there is a way to use the search term as input for the corresponding highlight-<...> function or ctrlf could implement similar behavior to isearch in that regard.

For now, how would I bind C-s C-s though? As "macro" ?

ghosty141 avatar Oct 28 '22 05:10 ghosty141

Sure, those things all seem like reasonable possibilities, however I'm not sure offhand what the best approach would be.

I don't think it would be possible to bind C-s C-s as a single command, directly, since each of the C-s instances are actually different commands.

I think what we'd probably want to do is copy this function but have it use the last search query rather than using symbol at point:

https://github.com/radian-software/ctrlf/blob/63d27a0209f2b4fa08a3fac752a20cfae56d54b9/ctrlf.el#L1414-L1431

raxod502 avatar Nov 12 '22 03:11 raxod502

I think what we'd probably want to do is copy this function but have it use the last search query rather than using symbol at point:

I played around with this a little bit, what we basically need is use (car ctrlf-search-history) + the position of the next result if there is one. I didn't find a function that returns the position of the next match though, if that would exist this would be possible right?

ghosty141 avatar Nov 13 '22 17:11 ghosty141

Why do you need the position of the next match, rather than simply moving to it by invoking ctrlf-forward?

raxod502 avatar Nov 27 '22 02:11 raxod502