-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
customise default search style without needing to rebind default keys #83
Comments
Agreed, the first thing I went looking for after trying ctrlf was how to make fuzzy my default search style. |
I think a simple way to add this functionality would be to add new commands You'd probably also want a default way to adjust the "alternate" search style (i.e. the one on |
It seems that even rebinding the keys doesn't work. After rebinding This is because only EDIT: I implemented @raxod502 suggestions which handles this issue. |
How did you get the search style to stick? (after changing with m-s s?) |
I believe with the aforementioned pull request (thank you!), this issue should be solved in a nice way. |
Sorry to be slow, but does this address the search style sticking? If I switch to literal I really want it to stay in literal until I switch back ;) |
Yes, the new implementation should work for this. But you should set |
Maybe we're at odds here in our understanding. I just removed my bindings, the default search is literal, I alt-s r to change to regexp. I finish my search. A little later, I do a continued search with C-s C-s and it's back to defaulting to literal. Is it only me? That this drives me insane? lol. I want it to stick to the last format I selected. I don't want it permanent over emacs sessions just that session. I switched to regexp from literal in that search session for a reason: I find the first occurrence of something, do some work there and want to continue my search using the same search style I had set it to on the last search. |
When you finish your search the state is lost. This is by design and I think it's the correct behavior. (define-advice
ctrlf-change-search-style
(:after (&rest _))
(setq ctrlf-default-search-style ctrlf--style)) This will change the behaviour globally (in all buffers). You can probably make it buffer specific by using EDIT: a buffer-local setting is slightly more complicated (define-advice
ctrlf-change-search-style
(:after (&rest _))
(with-current-buffer (window-buffer (minibuffer-selected-window))
(setq-local ctrlf-default-search-style ctrlf--style))) I actually like this and might include it in my setup :) |
Thanks for taking the time to reply and look into it. I shall test it and let you know. (Just one disagreement ;) : I can't think of any case where I use a search style once or twice with C-s then hit enter and work on the result and resume the search with C-s C-s to find the search style reset is desirable - Id want the continuing search to continue with the same search type! EDIT : didn't work I'm afraid. After I M-r to change literal to regexp and then C-s followed by enter, when I continue the search with C-s C-s it is literal again.
EDIT EDIT Does work with M-s to change style but not with quick-change hot keys eg M-r So, works with M-s s and this is great. Thank you! |
+company snippet tinkering
Hey @haji-ali , again thanks for your help. If you don't mind I shall add a custom and make this a PR (I already did it on my clone here: https://github.com/rileyrg/ctrlf/tree/sticky-search-style . I need to practice my PR submissions anyway ;) @raxod502 is your README.md generated from some meta data or do you write it manually? edit for posterity : https://github.com/raxod502/contributor-guide |
You would need to add the same code to
Feel free to adapt the idea into a PR. Perhaps you should check with @raxod502 or others to see if such a behaviour is desirable; including the behaviour that |
Personally I'm happy with it only working with the primary search forward/backwards. But happy to extend it - to the other cases if @raxod502 is happy with it - not sure it makes sense with the "alternate" as that's a fixed style anyway set up to be that fixed style. As I mentioned before, I can't imagine a case of search/edit/continue search where I wouldn't want this behaviour - I'm already very happy with it ;) buffer local seems the common-sense approach - certainly I wouldn't want it persisting across multiple unrelated buffers. https://github.com/rileyrg/ctrlf/tree/sticky-search-style . Anyway to get the ball running and better localise discussion : #89 |
It's written manually.
Great, will continue discussion there. Thanks! |
There doesn't seem to be a way to set the default search style. I find literal pretty limiting after getting lazy using other search tools. Ideally, I could set the default in a :custom form . Currently, I'm rebinding C-s which isn't nice.
The text was updated successfully, but these errors were encountered: