unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Spencer Baugh <sbaugh@janestreet.com>
Cc: sbaugh@catern.com, monnier@iro.umontreal.ca, 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: Mon, 10 Jul 2023 17:25:45 +0300	[thread overview]
Message-ID: <83jzv7972u.fsf@gnu.org> (raw)
In-Reply-To: <ierh6qbsx6p.fsf@janestreet.com> (message from Spencer Baugh on Mon, 10 Jul 2023 09:39:10 -0400)

> From: Spencer Baugh <sbaugh@janestreet.com>
> Cc: sbaugh@catern.com,  monnier@iro.umontreal.ca,  62732@debbugs.gnu.org
> Date: Mon, 10 Jul 2023 09:39:10 -0400
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> -        (setq buffer (create-file-buffer (directory-file-name dirname))))
> >> +        (setq buffer (create-file-buffer dirname)))
> >
> > This seems to imply that callers of create-file-buffer will now have
> > to remember to ensure the argument ends in a slash if it is the name
> > of a directory.  If so, I'd prefer that create-file-buffer did that
> > internally, when its argument is a directory.  Callers shouldn't know
> > to much about the internals of the callee.
> 
> I can (and should) add this to the docstring of create-file-buffer.  It
> seems intuitive to me that the last non-empty component of the filename
> passed in by the caller is what create-file-buffer uses, including if
> that "last component" ends in a slash.  (It's a nice way to avoid the
> additional DIRECTORY argument which says whether the filename is
> intended to refer to a directory)

If the only reason is to avoid an additional argument, I'd prefer an
additional argument.  Documenting a problematic design doesn't mean
the design ceases to be problematic, and relies too heavily on people
paying attention to subtle aspects of the documented behavior.

> By doing this internally in create-file-buffer, you mean running
> file-directory-p to see if the filename actually points to an existing
> directory?  I'm hesitant to do that:
> 
> - That prevents running create-file-buffer to create a buffer to visit a
> directory which does not yet exist (in the same way you can visit a file
> which does not yet exist).  dired doesn't currently support that but
> other packages might want to.

Didn't that problem exist before your changes?

And anyway, if we want to support that, adding an extra variable, or
even requiring the trailing slash only for non-existing directories,
would be a better solution.

> - Checking file-directory-p is what uniquify did which caused these bugs
> in the first place, and I think this could partially recreate the same
> bug, where we add a trailing slash just because there happens to be a
> directory of the right name.  (Although I'm not sure, just worried)

I don't see why that would follow.  It is a very minor change in the
code, and doesn't affect the logic, AFAICT.

> - It adds filesystem access to what is currently a pure function.

But create-file-buffer is not documented as not hitting the disk, so I
don't see a problem here.

> > Does this changeset have any user-facing behavior changes?  If so,
> > they should be at least in NEWS.
> 
> The only user-facing behavior change is fixing the two bugs mentioned in
> the commit message.  Is that appropriate to include in NEWS?

Does the fix result in different buffer names?  If so, it is not just
a bugfix, it changes user-facing behavior.





  reply	other threads:[~2023-07-10 14:25 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
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 [this message]
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=83jzv7972u.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=62732@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=sbaugh@catern.com \
    --cc=sbaugh@janestreet.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).