2013-02-28 99 views
5

你知道怎么当你在bash中向上箭头时,它会填写你输入的最后一个命令吗?有没有办法在nrepl中做到这一点?有没有办法在nrepl中进行历史搜索?

到目前为止,我一直在做一个反向搜索(),输入这行的前几个字符,杀线(S)(CK ),跳转到缓冲区末尾(M->)并且杀死死亡的细胞系(Cy)。有没有更简单的方法来做到这一点?

回答

12

您可以使用M-pM-n在输入历史记录中上下导航。而且,当前输入可以用作搜索模式,即键入要匹配的命令的开始,然后M-p将带您到下一个匹配。这使用功能nrepl-previous-inputnrepl-next-input。如果你不喜欢那些按键组合,你也可以重新绑定到<up><down>

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

刚(每行后和评估C-x C-e,如果你不希望重新启动您的Emacs)添加到您的.emacs。此外,请注意M-nM-p可能会绑定到其他REPL和comint模式中的类似功能。

+1

谢谢!这工作完美。 – 2013-02-28 07:17:36

3

如果您使用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) 

要坚持你打开一个REPL下一次的历史,你也有以下选项:

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

cider-repl-history-file是必需的,如果你想要一个持久的历史。如果您使用相对路径,则历史记录将在当前项目的本地。

相关问题