The docstring of expand-file-name suggest (directory-file-name (file-name-directory dirname)) to traverse a directory This looks wrong to me, e.g. (list current-directory (directory-file-name (file-name-directory current-directory))) => ("/home/youngfrog/" "/home/youngfrog") I think it should be (file-name-directory (directory-file-name dirname)) instead. Then the example becomes: (list current-directory (file-name-directory (directory-file-name current-directory))) => ("/home/youngfrog/" "/home/") Am I overlooking something ? Is this patch ok to commit ? In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu) of 2016-11-15 built on phie-fixe Repository revision: f994c2046588b168c1a4a900879cdffaf9d02f01 Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Ubuntu 16.04.2 LTS