-
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
ctrlf shouldn't require a minor mode #80
Comments
This issue report consists of several parts.
Let me know if I missed anything. |
No, that's it :-)
...I would enable it in the destructive way, and then restart Emacs if I wanted to go back. Maybe that's actually good excuse to want Emacs to fire up in 200 ms! Anyway, I myself would be happy as long as I can use the commands without enabling a minor mode, but I do think there will always be people confused with the inevitable conflicts that the minor mode creates, since every other package is designed around the assumption that
This issue would be solved by mapping
I have absolutely nothing against a fast init. In fact, I would frown upon any package which forces me, for no clear reason, to activate a minor mode in the init, since that (virtually always) means loading a package at start time.
pdf-tools is weird, as I noted in the edit to my original message, but let's take the vterm issue described in the same issue. We have four option: to map commands (1) directly or (2) via remaps to (A) the global map or (B) a minor-mode map. I'm fairly certain that only combination (1B) will clash with a major mode that rebinds |
Ah, but then you have the problem of using |
Yes, the approach I'm suggesting (which I can summarize once again if you like, since the ideas are quite scattered) would be responsive to the user's configuration to enter ctrlf, but not once inside it. I think this is the best you can do before resorting to weird hacks. Note, in any case, that none of "reasonable examples" in my original message strips PS: #67 is yet another issue caused by binding PPS: If you really want it, you can make the hypothetical PPPS: If you really want to make the minibuffer keybindings responsive to the user's config, you could try adding the |
I've come up with a compromise that maintains |
I still see drawbacks in the new scheme, in comparison with the tried-and-true approach of instructing the user to bind some keys to their global-map:
|
Won't pressing
You'd do this by adjusting
What do you think of that? The reason I resist removing the minor mode is that it will reduce the out-of-box user experience. I think it is better when software automatically works without the need for customization. Enabling a single minor mode to turn on a package is the best-case scenario for realizing this goal. If we didn't have a minor mode, then:
|
Fair enough. I only brought this up because you are keen on providing a way to test the package which is reversible without restarting Emacs, and this stopped being possible in this common use-case.
It looks like we both agree that setting up some keybindings in the init file is kinda clunky. However, this is how every other package works, and how everyone expects this to work. On the plus side, copying six lines of
If some random new keybinding appeared on my config just because I updated a package, it's likely I would either never notice it, or be annoyed by the change.
Okay, a global change to Emacs's behavior warrants a minor mode. But why does Ctrlf, being just a collection of search commands, needs to make any global modification to Emacs, apart from some keybindings? Why would it ever need any bookkeeping to run outside of a search session?
This is the only problem you are solving here IMO. The solution is aptly implemented, given Emacs's constraints; unfortunately, it seems complex and brittle. More importantly though: I wanted to bring to your attention that binding Now, concerning #51 and the trick where you bind some stuff to nil: The conventional way to solve this problem would be to bind Ctrlf's forward/backward commands to |
Yeah, unfortunately, there's a serious problem with that, which is that it doesn't work with remaps. If I were to bind
Why thank you! :3
I wouldn't say that's entirely the case, though---for example, looking through the modes enabled in my configuration, Counsel provides Actually, Counsel is just like CTRLF---it mostly provides just keybindings in its minor mode, but enabling the mode also enables a piece of advice :)
See |
I don't understand this, and perhaps we are talking about different things. To me, the upshot of the discussion is: direct bindings in the minibuffer-local map are good; direct bindings in Ctrlf's minor mode map are bad. To expand this a bit, each "minibuffer session" (be it a Concerning #52, note that pdf-tools breaks with any alternative search package, and therefore is the real culprit here. This is so because it assumes
Winner mode is a bona fide minor mode, because it needs to somehow watch for window configuration changes. Counsel's minor mode is a mere convenience, I'd say (and that piece of advice it adds but never removes is not kosher, is it?). I actually prefer the approach of the Consult package, which is to provide a sample configuration for the user to copy and adapt to their taste. Of course that's not the way you want to do it here, which is all fine and good. On a tangent: I generally find those minor mode bindings useless because of their length. Who types
I don't know the details here, but is this supposed so fix said horrifying visual bugs in every minibuffer session, even those not "owned" by Ctrlf? Then perhaps there is a case to make this independent of the search commands. Last but not least: I think I made my point here as well as I could. You have a different vision in some aspects, so please heed or ignore any of these comments as you see fit, and feel free to close the issue. |
Ah, well, the important feature to me is that the binding to start a search is the same as the one to continue one. If I'm used to
Well, presumably, you'd type
Yes. It's mandatory because it needs to apply to commands external to CTRLF that might interfere with CTRLF search sessions asynchronously, unfortunately. Perhaps it would be possible to dynamically install and remove the advice as search sessions start and end. That would be an improvement.
Sounds good! |
After all, it's just a collection of isolated commands that don't change the general behavior of the editor.
I didn't notice any problems when running the ctrlf commands without the minor mode, but it strikes me as wrong to permanently advice
minibuffer-message
. This kind of setup is typically done when entering the minibuffer and torn down afterwards. Are there any technical reasons not to do so?Also, there are a few things in this package that seem to solve simple and common problems in unusual and overengineered ways.
First, concerning the lazy loading setup: is this meant to save a few miliseconds of init time? A normal way to lazy load the main library but not the mode would be to move the mode definition to a separate file. This new ctrlf-mode.el would also include a normal keymap that anyone can customize in the expected way. (Although, to be honest, I don't see why anyone who cares so much about startup time wouldn't just bake their keybindings into the init file).
Now, I would argue that not even the keybinding setup warrants a minor mode for ctrlf. For the user's convenience, there could be a
ctrlf-setup-keybindings
function which adds some remaps (from isearch commands to the ctrlf equivalent) directly in the user's global map. (If you want to autoload the body of that function definition, that would be an okay abuse from my point of view.) For those who like the defaults, calling the function is as easy as enabling the mode; for those who don't, extra configuration is needed either way.The above arrangent also solves issue #52, since the pdf-tools remapping of isearch would take precedence over the global mode remaps done by ctrlf. [EDIT: actually, this wouldn't solve the pdf-tools problem because, apparently, pdf-tools hacks into isearch instead of defining a new command. But it would solve a similar problem with the good old DocView, as well as the problem with vterm described in loc. cit.)
Finally, the approach of adding remaps to the global map also works out of the box for anyone who already tweaks their search bindings in some way (reasonable examples: swapping
C-s
andC-M-s
; adding handier shortcuts for the stuff underM-s
; reclaimC-r
for something more useful; unreasonable example: CUA fan binds isearch, literally, to Ctrl-f).PS: Your argument against Swiper applies even to grep. Hard to argue grep is not useful because it doesn't give context lines—it's useful precisely for this reason. Also, there's swiper-isearch which is not line based.
The text was updated successfully, but these errors were encountered: