I would like to write a function that starts a search (evil-search-forward
specifically), with some arbitrary text already in the minibuffer.
Following directions in this link I came up with the following:
(defun my/insert-headline-string ()
(insert "foobar"))
(minibuffer-with-setup-hook
(:append 'my/insert-headline-string)
(call-interactively #'evil-search-forward))
But it doesn't work for me: evil-search-forward
runs just fine, but there is no text in the mini-buffer. If I use a different function (eg find-file
) it prefills mini-buffer as expected, like so:
(minibuffer-with-setup-hook
(:append 'my/insert-headline-string)
(call-interactively #'find-file))
Is there a reason this won't work for the search minibuffer?
insert
instead of:append
? (Dunno what:append
does.) And doesevil-search-forward
actually use the minibuffer? Isearch does not, for example, even though it looks like it does.evil-search-forward
, it's basically a wrapper for isearch, which explains why editting the minibuffer doesn't do what I want. Would there be a way to prefill the isearch minibuffer I wonder? (Also, played withinsert
instead of:append
but could not get that to work).(defun the () (setq isearch-string "the")) (defun find-the ()(interactive) (add-hook 'isearch-mode-hook 'the) (isearch-mode t))
remove-hook
after the search to clean things up and it's just what I wanted. I can post the final code I'm using as an answer? Or do you want to? I don't know SE etiquette.