unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Eli Zaretskii" <eliz@gnu.org>
Cc: sbaugh@catern.com, 62732@debbugs.gnu.org
Subject: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD
Date: Sun, 09 Jul 2023 22:04:54 -0400	[thread overview]
Message-ID: <jwv4jmcr11v.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87o7kklf9c.fsf@catern.com> (sbaugh@catern.com's message of "Mon,  10 Jul 2023 01:36:00 +0000 (UTC)")

>>> 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






  reply	other threads:[~2023-07-10  2:04 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-09  1:37 bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD sbaugh
2023-04-09  1:49 ` sbaugh
2023-04-09 12:13   ` sbaugh
2023-04-21 20:59     ` sbaugh
2023-05-05  6:06       ` Eli Zaretskii
2023-07-03 18:54         ` sbaugh
2023-07-03 19:19           ` Eli Zaretskii
2023-05-05 20:30     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-08 17:48       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09 14:49         ` sbaugh
2023-05-05 20:13   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-05 20:37     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-05 21:14     ` Spencer Baugh
2023-07-09 15:38     ` sbaugh
2023-07-09 16:15       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-10  1:36         ` sbaugh
2023-07-10  2:04           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-07-10  2:55             ` sbaugh
2023-07-10  3:38               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-10 12:57             ` Eli Zaretskii
2023-07-10 12:56           ` Eli Zaretskii
2023-07-10 13:39             ` Spencer Baugh
2023-07-10 14:25               ` Eli Zaretskii
2023-07-10 16:53             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-10 19:12               ` Eli Zaretskii
2023-07-10 19:18                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-11  2:25                   ` Eli Zaretskii
2023-07-11  2:55                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-11 12:01                       ` Eli Zaretskii
2023-07-11 12:31                         ` Spencer Baugh
2023-07-11 15:31                           ` Eli Zaretskii
2023-07-12 13:04                             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-12 13:42                               ` Eli Zaretskii
2023-07-12 13:57                                 ` Spencer Baugh
2023-07-12 19:43                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-13  4:50                                 ` Eli Zaretskii
2023-07-13 15:52                                   ` sbaugh
2023-07-13 16:02                                     ` Eli Zaretskii
2023-07-13 16:21                                       ` sbaugh
2023-07-17  5:03                                         ` Michael Heerdegen
2023-07-17 11:35                                           ` Eli Zaretskii
2023-07-18  4:13                                             ` Michael Heerdegen
2023-07-18 11:12                                               ` Eli Zaretskii
2023-07-13 21:51                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv4jmcr11v.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=62732@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=sbaugh@catern.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).