Another revision: this time I check if the found parent is null before comparing with the expanded file name by `file-equal-p` (haven't come to this case, though). And return the relative parent when input is relative. Current cases as in shortdoc.el:     (file-parent-directory "/foo/bar")     ⇒ "/foo/"     (file-parent-directory "~")     ⇒ "/home/"     (file-parent-directory "/tmp/")     ⇒ "/"     (file-parent-directory "foo/bar")     ⇒ "foo/"     (file-parent-directory "foo")     ⇒ "./"     (file-parent-directory "/")     ⇒ nil Also, about the comparator to check if the input is already at top-level; `file-equal-p` looks like the most comprehensive one, but it makes use of `file-truename` which is reported to be slow; on the other hand for `f.el`, `dired+.el`, just comparing two strings with `equal` is sufficient. So I wonder in this case, with both FILENAME and the found parent's names expanded, we can opt to use `equal`/`string=` instead of `file-equal-p` for better performance? -- Daanturo.