jupyter
jupyter copied to clipboard
Add an option to keep default isearch behavior in REPL buffers
Thanks for the awesome package!
I am a heavy user of emacs-jupyter REPLs. I occasionally find that I want to navigate the output history using isearch, however the function (jupyter-repl-isearch-setup), which is called when the REPL is created, changes the behavior of isearch to operate only on the REPL command history rather than the entire REPL buffer itself.
Could we add an option to disable this override? In other words, to keep the standard behavior of isearch.
Not sure what would be a good naming convention but happy to submit a PR.
It would be even nicer if one could keep the usual isearch behavior mapped to C-s/C-r, but add the additional jupyter-repl-history-isearch-search under a different binding, e.g., S-C-s/S-C-r
You can get a comint-like behavior using (in doom):
(defun my/jupyter-repl-isearch-reset ()
(setq-local isearch-search-fun-function
#'isearch-search-fun-default
isearch-wrap-function
'nil
isearch-push-state-function
'nil))
(after! jupyter
(add-hook 'jupyter-repl-mode-hook #'my/jupyter-repl-isearch-reset)
(add-hook 'jupyter-repl-mode-hook
(lambda() (add-hook 'isearch-mode-end-hook #'my/jupyter-repl-isearch-reset nil t))))
(map! :map jupyter-repl-mode-map
"M-r" (cmd! (jupyter-repl-isearch-setup) (isearch-backward)))
With this, the normal behavior of isearch is retained. To use isearch to search the history, you just do Meta-r, just like comint.