I would like to call a function (find-file
) interactively and then set the initial content of the mini buffer to my server's home folder. I got as far as using call-interactively
, but after that I'm lost. Any suggestions?
-
1Possible duplicate of Call a function and insert text in minibuffer prompt– DrewDec 29, 2017 at 18:01
-
If the question is specifically about find-file, please make it clear. Otherwise it should be closed as duplicate imo.– YoungFrogJan 1, 2018 at 7:41
1 Answer
find-file
uses the buffer-local default-directory
value as the default filename (see also find-file-read-args
), so all you need to do is bind that value for the scope of the call to find-file
:
(let ((default-directory "/home/"))
(call-interactively 'find-file))
-
Great! For reference is there any generic way to insert text into the mini-buffer programmatically when calling a function interactively? Dec 29, 2017 at 15:30
-
-
2OP: The question you pose in your comment is the one posed here. The question about
find-file
inserting a directory name is a special case, which can be taken care of as @phils said. For that solution, however, be sure to have optioninsert-default-directory
be non-nil
(which it is by default). Otherwise, you can insert the directory into the minibuffer interactively, usingM-n
.– DrewDec 29, 2017 at 18:05