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?
insertinstead of:append? (Dunno what:appenddoes.) And doesevil-search-forwardactually use the minibuffer? Isearch does not, for example, even though it looks like it does. – Drew Jul 09 '22 at 15:42evil-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 withinsertinstead of:appendbut could not get that to work). – randouser Jul 10 '22 at 01:44(defun the () (setq isearch-string "the")) (defun find-the ()(interactive) (add-hook 'isearch-mode-hook 'the) (isearch-mode t))– Drew Jul 10 '22 at 04:11remove-hookafter 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. – randouser Jul 12 '22 at 09:47