GNU bug report logs -
#62732
29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD
Previous Next
Reported by: sbaugh <at> catern.com
Date: Sun, 9 Apr 2023 01:38:02 UTC
Severity: normal
Found in version 29.0.60
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #53 received at 62732 <at> debbugs.gnu.org (full text, mbox):
>>> This inspired me to do something not exactly this but which also gets
>>> rid of the new argument to create-file-buffer. How about this:
>>
>> Now you're talking! :-)
>> LGTM! Thank you very much,
>
> Great! Here's that as a complete patch again.
Eli, OK to install on `master`?
Stefan
PS: Nitpicks:
> + (let* ((lastname (if (directory-name-p filename)
> + (file-name-nondirectory (directory-file-name filename))
> + (file-name-nondirectory filename)))
Aka
(let* ((lastname (file-name-nondirectory
(if (directory-name-p filename)
(directory-file-name filename)
filename)))
or even just
(let* ((lastname (file-name-nondirectory
(directory-file-name filename)))
> + (lastname (if (and (directory-name-p filename) uniquify-trailing-separator-p)
> + (cond ((eq uniquify-buffer-name-style 'forward)
> + (file-name-as-directory lastname))
> + ((eq uniquify-buffer-name-style 'reverse)
> + (concat (or uniquify-separator "\\") lastname))
> + (t lastname))
> + lastname))
Here you can merge the `if` into the `cond` and I'd test
`uniquify-trailing-separator-p` first (cheaper and nil by default)
and since we know (directory-name-p filename), I'd be tempted to replace
(file-name-as-directory lastname) with just `filename`. Also I'd argue
that when `uniquify-trailing-separator-p` and (directory-name-p
filename) are both true we never want to use just `lastname` so the
default should be to return `filename`:
(lastname (cond
((not (and uniquify-trailing-separator-p (directory-name-p filename)))
lastname)
((eq uniquify-buffer-name-style 'reverse)
(concat (or uniquify-separator "\\") lastname))
(t filename)))
so for `post-forward` (my personal favorite) /foo/bar/mumble/name/ would
turn into name/|bar/mumble.
WDYT?
Stefan
This bug report was last modified 1 year and 312 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.