using wildcards in expand-file-name in elisp?

Viewed 1211

Is it possible to use wildcards such as * in elisp to expand filenames?

For example, I saw that

(expand-file-name "~/.emacs.d/elpa/babel-repl-20160504.1501")

expands to /home/username/.emacs.d/elpa/babel-repl-20160504.1501.

Is there a function to also expand filenames containing wildcards so that we can do:

(expand-file-name "~/.emacs.d/elpa/babel-repl*")

(taking the first filename if multiple matches exist)?

I tried the above, but expand-file-name does not seem to recognize * (Emacs 24.5 from Ubuntu 16.04)

-- EDIT --

@Drew I tried (byte-recompile-directory (file-expand-wildcards "~/.emacs.d/elpa/babel-repl*/") 0) but got an error Wrong type argument: stringp, nil.

I am not very familiar with elisp and the stringp type (a list of strings, I guess). I tried to use a (car ) on the returned value of file-expand-wildcards in order to get the first matched filename. But Emacs still work start correctly.

Any pointers?

1 Answers
Related