emacsemacs-helm

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


I know that I can use a separate input history for helm-swoop by adding the following code to helm-swoop.el, but I don't want to edit the package source code.

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

I've tried the following codes, but it doesn't work (no history at all when I use M-p during my-helm-swoop):

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

Solution

  • Your code doesn't work for two reasons:

    1. Do not quote my-helm-swoop-input-history in the let-binding. You want its value, not the symbol.

    2. Your minibuffer-history does not survive the let scope.

    Try this, it works for me:

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