I like how Bash handles i-search:
C-r, type some characters,
C-r a couple more times to find the desired command, then hit
Return and the command is executed.
If I want to edit the command before it's executed, I type any of
<right>, which exits isearch, leaving the result on the command line.
I love using
C-r to search Emacs' minibuffer history, but having to hit
Return once to accept the search result and a second time to submit it is annoying. I guess it's partly psychological...
- Me (searching): There, that's the one. Enter!
- Emacs: um, this one?
- Me (eyeroll): Yes, that one. Enter.
I want to fix this.
Return is bound to
overriding-terminal-local-map. This appears to be the case both inside and outside the minibuffer. It also seems that the aforementioned map is not defined until you've entered isearch.
My current solution:
(defun ivan/isearch-exit () (interactive) (isearch-exit) (if (minibuffer-window-active-p (selected-window)) (minibuffer-complete-and-exit))) (defun ivan/remap-isearch-exit () (define-key overriding-terminal-local-map [remap isearch-exit] #'ivan/isearch-exit)) (add-hook 'isearch-mode-hook #'ivan/remap-isearch-exit)
So far, this seems to work, but is there a cleaner approach?