Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Mathematica 10 has introduces file name completion. It works only with certain built-in functions such as Import, SetDirectory, ReadList, etc.

Is it possible to add file name completion for user-defined functions?

For example,

readCSV[file_] := Import[file, "CSV"]

I would like file name completion to be triggered after typing readCSV["...

share|improve this question
Link to W Community version – Szabolcs Aug 8 '14 at 18:37

1 Answer 1

up vote 15 down vote accepted

There is an undocumented file in the installation directory named

NotebookOpen @ FileNameJoin @
  { $InstallationDirectory, "SystemFiles", "FrontEnd", "SystemResources"
  , "FunctionalFrequency", ""

This file describes in detail how to attach completion actions to each parameter of listed functions. For example, it contains the entry:

"Import"->{2, "ImportFormats_Names.trie"},

and explains that 2 specifies absolute pathname completion for the first argument, and that the second argument should be completed from a compiled list found in the file ImportFormats_Names.trie in the same directory.

So, we can achieve the desired goal by adding the following entry for readCSV:


filename completion screenshot

The rules use symbol names unqualified by context. Thus, they apply equally well for symbols in any context. In fact, experimentation shows that the parameters of qualified symbols are not completed, even for the shipped rules (e.g. try completing System`Import["c:\\).

As usual, the undocumented nature of this feature means that it could change at any time.

share|improve this answer
+1 Great! It would be nice if there was some kind of fileplaceholder that one could put in the usage message in the function template – Rojolalalalalalalalalalalalala Aug 10 '14 at 1:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.