radian-software / radian

🍉 Dotfiles that marry elegance and practicality.
MIT License
490 stars 47 forks source link

Disable ctrl-f bindings in the minibuffer #476

Closed haji-ali closed 3 years ago

haji-ali commented 3 years ago

I use selectrum for minibuffer completion and so I rarely need to search for a string in the minibuffer. I would like to disable ctrlf bindings there (to use the key sequences for more useful commands, in that context).

Is this possible at all? In particular, it seems that ctrlf bindings override local ones. This might be related to raxod502/ctrlf#62 and raxod502/ctrlf#64, but I am not sure.

haji-ali commented 3 years ago

I read more about define-globalized-minor-mode. One way to resolve this is

(add-hook 'minibuffer-setup-hook
          (lambda () (when (not ctrlf--active-p)
                       (ctrlf-local-mode -1))))
raxod502 commented 3 years ago

I think this should be done by default. There is no good reason for CTRLF to be active in the minibuffer.

raxod502 commented 3 years ago

OK, so:

You shouldn't have to disable CTRLF in the minibuffer explicitly for the above to work.

haji-ali commented 3 years ago

Hmmm.. That's exactly what I tried in the beginning and it didn't work for me (CTRLF is still called when I press C-s, despite the fact that I see the correct binding when inspecting minibuffer-local-map).

I am using Radian for my config which enables the global mode of CTRLF. The documentation of define-globalized-minor-mode, which is used in CTRLF, says that "When a major mode is initialized, MODE is actually turned on just after running the major mode's hook. However, MODE is not turned on if the hook has explicitly disabled it."

So if I am understanding this correctly, the CTRLF mode is turned on after the minibuffer mode and the keybindings in minibuffer-local-map are overridden. That is why disabling CTRLF worked for me (although I had to change the code a little to make sure CTRLF is not disabled in a CTRLF session).

raxod502 commented 3 years ago

This is probably a Radian bug, then, so I'll transfer the issue. Radian may have still been on an old commit of CTRLF. I've pushed a new commit to develop updating the lockfile to the latest version of CTRLF. Try now? (M-x straight-thaw-versions)

haji-ali commented 3 years ago

Updating worked and remapping C-s is now possible! As a plus, when I don't override it, pressing C-s now searches the active buffer instead of the minibuffer.