[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27982: 25.1.50; expand-file-name docstring on how to traverse the fi
From: |
Nicolas Richard |
Subject: |
bug#27982: 25.1.50; expand-file-name docstring on how to traverse the filesystem |
Date: |
Wed, 23 Aug 2017 21:18:53 +0200 |
User-agent: |
mu4e 0.9.19; emacs 25.2.1 |
Eli Zaretskii <eliz@gnu.org> writes:
> Crystal ball says that current-directory (which you probably meant to
> be default-directory instead) ends in a slash, in which case remove
> it, and the 2 results will match.
Your crystal ball is working fine. Sorry for leaving that detail out.
FWIW I have (defvaralias 'current-directory 'default-directory) because
I used to forget the name of the variable (and I still do, it seems).
Note however that default-directory ends in a slash when using "emacs
-Q" too.
Ok so now I'm saying that, with the suggestion in the docstring, output
will be different if "dirname" ends in a slash. IOW if it is a
"directory name" as opposed to "directory's file name".
(let ((dirname "/home/youngfrog/"))
(format "%s versus %s"
(directory-file-name (file-name-directory dirname))
(expand-file-name ".." dirname)))
=> output is different
(let ((dirname "/home/youngfrog"))
(format "%s versus %s"
(directory-file-name (file-name-directory dirname))
(expand-file-name ".." dirname)))
=> output the same
With the function calls swapped the output is always similar:
(let ((dirname "/home/youngfrog/"))
(format "%s versus %s"
(file-name-directory (directory-file-name dirname))
(expand-file-name ".." dirname)))
=> output is similar
(let ((dirname "/home/youngfrog"))
(format "%s versus %s"
(file-name-directory (directory-file-name dirname))
(expand-file-name ".." dirname)))
=> output is similar
Nicolas.