I remember reading about this function (it's part of Emacs) somewhere, but I can't for the life of me remember what it's called.
It takes a single argument arg
(not sure if there's any more optional args)
- By default it looks for
(expand-file-name arg "~/")
and returns the path if it exists. - If not, it looks for
(expand-file-name arg user-emacs-directory)
and returns the path if it exists. - Otherwise, it creates the subdirectory in
user-emacs-directory
and returns the path.