jupyter icon indicating copy to clipboard operation
jupyter copied to clipboard

Add an option to keep default isearch behavior in REPL buffers

Open egr95 opened this issue 1 year ago • 1 comments

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.

egr95 avatar Aug 02 '24 04:08 egr95

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

egr95 avatar Aug 22 '24 21:08 egr95

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.

gpanago avatar Jun 27 '25 15:06 gpanago