reddit / emacs

Disable ivy (swiper) from binding C-n C-p?

FrozenOnPluto · 2022-01-27 14:38
I just started using swiper as an isearch replacement (and none of the rest of ivy I'm afraid), but want it more or less to work like isearch after the long years of muscle memory :) Its close (see current config below, notably the ivy-height of 1 and keybinds.) already, with very little tweaking, yet gets some extra features. Love it! C-s and enter 'foo bar' to search kicks swiper off, and then C-s and C-r to cycle through searches. I'm used to using point movement such as C-a or C-n to exit isearch; I'm okay with C-a/etc staying in the minibuf to edit the search criteria. Using enter to complete the search can be okay, though ivy/swiper sometimes gets into this 'need a match!' loop where enter just stays in there... fine. But I'm thinking that C-s/C-r cycle the matches, why also does C-n/C-p do that? and cursor key up/down? It is redundant. For me, I'm feeling like C-n/C-p should exit ivy/swiper and just do their normal function, while C-s/C-r cycle matches; that would be pretty close to isearch and be to my flow - C-s a few times to find the right match and then C-n to start moving to something; usually I'm searching for a function name in code, so that I can get into the body of the code below the name anyway. Ivy seems to have a global table of bindings in it, but not sure I'm looking in the right place, and surely I don't want to just change the ivy code (only for such changes to get undone next update.) Perhaps there is a advice routine that could do the trick, but theres probably a better way entirely that I just didn't see. Thanks for your thoughts, friends in editting! My current config for this is: ;; enable Ivy swiper to use orderless (setq ivy-re-builders-alist '((t . orderless-ivy-re-builder))) ;; replace C-s isearch with swiper's (global-set-key (kbd "C-s") 'swiper-isearch) ; orderless swiper override (global-set-key (kbd "C-r") 'swiper-isearch-backward) ; orderless swiper override ;; set height of the ivy window; we set 1 so that it more or less looks like isearch .. not a huge ;; Ivy window that is distracting as it reformats the display (setq ivy-height 1) ;; show m/n layout for the in-flight counter (setq ivy-count-format "(%d/%d) ")
doolio_ · 2022-01-27 16:07
Consider using [raxod502/ctrlf](https://github.com/raxod502/ctrlf) instead if you won't use anything else ivy/swiper offer.
FrozenOnPluto · 2022-01-27 17:49
I checked ctrlf when it came out, but due to how it performs the searches it can't work with things like orderless, so I juse kept with isearch. Only reason I've looked at swiper is because it can support orderless, but I still want it to work more or less like isearch. With Selectrum + orderless + prescient, I'm sort of hooked on things like file find typing 'foo bar' to find 'bar foo' and succeeding. Just trying to get some similar level of matcing going on in-buffer .. for those days when you can't remember long function names and if its someStupidFanctoryName or someFactoryStupidName, in a codebase of hundreds or thousands of files :)
doolio_ · 2022-01-27 18:02
You can change the search style in ctrl-f or define your own. I've not tried but perhaps you can change it to orderless?
FrozenOnPluto · 2022-01-27 22:45
I should ask the author. I know it had fuzzy (regexp) and literal search types, but not plugging something like orderless in. I think I did ask, but been too long to remember. (And who knows maybe things have changes too) Perhaps I should check the code too. *shrug*
wargxs · 2022-01-29 16:07
what you can also do for isearch: (setq search-whitespace-regexp ".\*") (setq isearch-lax-whitespace t) this way, you can type fo ba to match foobar etc., is still does not ignore the order of the words, but I think as a buffer search it does not matter much, you can always type fo bar and if this does not match anything quickly bar fo ... for project wide search you would use counsel-rg anyways, which supports orderless matching.