【问题标题】:Is there a way to do a history search in nrepl?有没有办法在 nrepl 中进行历史搜索?
【发布时间】:2013-02-28 05:52:39
【问题描述】:

你知道当你在 bash 中点击向上箭头时,它会填充你最后输入的命令吗?有没有办法在 nrepl 中做到这一点?

到目前为止,我一直在进行反向搜索 (C-r),输入相关行的前几个字符,然后终止该行 (C-k ),跳转到缓冲区的末尾 (M->) 并拉出终止行 (C-y)。有没有更简单的方法来做到这一点?

【问题讨论】:

    标签: emacs clojure nrepl


    【解决方案1】:

    您可以使用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)
    

    只需将其添加到您的.emacs(如果您不想重新启动 Emacs,请在每行之后评估 C-x C-e)。另请注意,M-nM-p 可能会绑定到其他 REPL 和类似comint 模式中的类似功能。

    【讨论】:

      【解决方案2】:

      如果您使用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 如果你想要一个持久的历史记录是必需的。如果您使用相对路径,则历史记录将是当前项目的本地记录。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-24
        • 2021-08-22
        • 2017-04-02
        • 2013-06-15
        • 1970-01-01
        • 2019-09-27
        • 1970-01-01
        • 2019-01-15
        相关资源
        最近更新 更多