ftravers
ftravers

Reputation: 4009

How to use: ido-find-file in an elisp function?

I wanted to write a script that required a filename as an argument. I wanted to leverage 'ido-find-file' to get the file, since it's such a nice way to select a filename, but I didn't want to open the file as such, just use it as the argument to my function.

Upvotes: 2

Views: 120

Answers (2)

Stefan
Stefan

Reputation: 28571

Just use read-file-name. This will use IDO's method if IDO is enabled (i.e. if the user likes IDO) and will use another method if the user prefers the other method.

Upvotes: 2

ido-find-file internally uses ido-read-file-name to ask for the file path in the minibuffer.

You can use it like this:

(ido-read-file-name "my prompt: ")

Upvotes: 3

Related Questions