[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56355: 29.0.50; Implement file-parent-directory
From: |
daanturo |
Subject: |
bug#56355: 29.0.50; Implement file-parent-directory |
Date: |
Sun, 3 Jul 2022 01:24:12 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 |
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.
0001-Define-file-parent-directory.patch
Description: Text Data