如何为 helm-swoop 使用单独的输入历史记录?

How to use a separate input history for helm-swoop?

我知道我可以通过将以下代码添加到 helm-swoop.el 来 use a separate input history 用于 helm-swoop,但我不想编辑包源代码。

:history 'my-helm-swoop-input-history

我已经尝试了以下代码,但它不起作用(当我在 my-helm-swoop 期间使用 M-p 时根本没有历史记录):

(defvar my-helm-swoop-input-history nil)
(defun my-helm-swoop() (interactive) (let ((minibuffer-history 'my-helm-swoop-input-history)) (helm-swoop)))

您的代码不起作用有两个原因:

  1. 不要在 let 绑定中引用 my-helm-swoop-input-history。您需要它的值,而不是符号。

  2. 您的 minibuffer-history 无法在 let 范围内存活。

试试这个,对我有用:

(defun my-helm-swoop() (interactive)
       (setq my-helm-swoop-input-history
             (let ((minibuffer-history my-helm-swoop-input-history)) 
               (helm-swoop) minibuffer-history)))