Is there a way to do a history search in nrepl?

Do you know how, when you press the up arrow in bash, it fills the last command entered? Is there a way to do this in nrepl?

So far I have been doing a reverse search ( C-r), typing the first few characters of this line, killing the lines ( C-k), jumping to the end of the buffer ( M->) and pulling out the killed line ( C-y). Is there an easier way to do this?

+5
source share
2 answers

You can use M-pboth M-nto navigate up and down in the input history. In addition, the current input can be used as a search pattern, i.e. Enter the start of the command you want to match, then M-ptake you to the next match. This uses the functions nrepl-previous-inputand nrepl-next-input. If you do not like these bindings, you can also re-confirm before <up>and <down>:

(define-key nrepl-mode-map (kbd "<up>") 'nrepl-previous-input)
(define-key nrepl-mode-map (kbd "<down>") 'nrepl-next-input)

Just add this to yours .emacs(and evaluate C-x C-eafter each line if you don't want to restart Emacs). Also note that M-nthey M-pwill most likely be tied to similar functionality in other REPL and comint modes.

+12
source

Cider, :

(define-key cider-repl-mode-map (kbd "<up>") 'cider-repl-previous-input)
(define-key cider-repl-mode-map (kbd "<down>") 'cider-repl-next-input)

, :

(setq cider-repl-wrap-history t)
(setq cider-repl-history-size 1000)
(setq cider-repl-history-file "~/.cider-repl-history")

cider-repl-history-file , . , .

+3

All Articles