GNU bug report logs - #56355
29.0.50; Implement file-parent-directory

Previous Next

Package: emacs;

Reported by: daanturo <daanturo <at> gmail.com>

Date: Sat, 2 Jul 2022 11:07:01 UTC

Severity: normal

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: daanturo <daanturo <at> gmail.com>
To: "56355 <at> debbugs.gnu.org" <56355 <at> debbugs.gnu.org>
Subject: bug#56355: 29.0.50; Implement file-parent-directory
Date: Sun, 3 Jul 2022 01:24:12 +0700
[Message part 1 (text/plain, inline)]
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 (text/x-patch, attachment)]

This bug report was last modified 2 years and 316 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.