Alex Rivera | Logout

Emacs Elisp dynamic interactive prompt

Asked 2009-04-16T00:29:56.843
11

I am trying to have a dynamic prompt from my elisp function. I want something like replace-regexp where it will show you the last regexp entered. I tried (interactive (concat "sab" "bab"))) that doesnt work!

I also tried message like format (interactive "s %s" last-used-regexp)

and that doesn't work! Anyone know how to do this?

Thank you!

Edit
Report

1 Answer

10

Use a variable for input history, and interactive with a list:

(defvar my-func-history nil)

(defun my-func (str)
  (interactive (list (read-from-minibuffer "Input string: " (car my-func-history) nil nil 'my-func-history)))
  (insert str))

If you don't want the last value entered in there initially, change the (car my-func-history) to nil. You can of course up/down arrow to go through the history at the prompt.

answered 2009-04-16T03:00:07.857

Your Answer