Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
In the case we have optional argument and there is a .m file with the options according to this answer on the Prompt a set of possible options, how would it be possible to achieve string autocompletion on my custom function ? – Athanassios Dec 14 '15 at 14:11
@Athanassios Sorry, I do not know the answer to that. I don't really like to customize Mathematica to such an extent by editing installation files. It seems that autocompletion can only be customized by editing installation files (though I might be wrong). – Szabolcs Dec 15 '15 at 11:30
up vote 21 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 – Rojo Aug 10 '14 at 1:00
This is fine if you need file-completion, what about string auto-completion from a list of defined possible options for a custom function, see my question above ? – Athanassios Dec 14 '15 at 14:15
@Athanassios shows an example for a function with a hard-coded list of acceptable values for the first argument: "MyPlanetInfo"->{{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Uranus", "Neptune"}} – WReach Dec 14 '15 at 15:29
@WReach I played a bit more with auto-completion feature and I noticed that when you define an enumerated list of options, in a .m file according to this (…)How to Answer, then string auto-completion is not needed because the drop-down list is filtered automatically as you start typing the name of the option, e.g. com->getD.... and drop-down list displays only "getDatabase". – Athanassios Dec 15 '15 at 15:25
@Athanassios Yes, the method in (78935) enables autocompletion for option arguments, whereas the method here using enables autocompletion for regular (non-option) arguments. – WReach Dec 15 '15 at 16:50

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.