unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: 52395@debbugs.gnu.org
Subject: bug#52395: 27.2; Expansion of DIR arg of `dired-buffers-for-dir'
Date: Thu, 9 Dec 2021 21:59:46 +0000	[thread overview]
Message-ID: <CO6PR10MB54732C589C62484EFC68A032F3709@CO6PR10MB5473.namprd10.prod.outlook.com> (raw)

This bug report is in the form of a question.  Shouldn't this function
expand the DIR argument using `expand-file-name' (e.g. with
`default-directory')?

I think the answer is "yes", but perhaps there's some good reason the
answer should be "no".

All uses of `dired-buffers-for-dir' I'm aware of call `expand-file-name'
on the directory passed as arg.

If you instead pass, say, "~/some/dir/", then a Dired buffer for that
directory won't be found.  To me, that seems like a bug.  The "problem"
is that the code just uses `assoc' to look up the given DIR argument in
the value of `dired-subdir-alist', and entries in that alist have
absolute (i.e., expanded) dir names as their cars.

At the very least, the doc should tell you about the gotcha - it should
tell you to expand the DIR arg before calling.

I'd propose changing the first line of the `dired-buffers-for-dir' code
from this:

  (setq dir  (file-name-as-directory dir))

to this:

  (setq dir  (expand-file-name (file-name-as-directory dir)))

That way, there's no need for callers to themselves expand the dir name.

(A question is whether `file-truename' should be used instead of
`expand-file-name'.  I guess not.)

Such a code change shouldn't change the behavior of any existing code,
since that seems to always use `expand-file-name' before calling
`dired-buffers-for-dir'.

If this code change is made then it would be good to also change the
doc to say that DIR is expanded relative to `default-directoy'.  Code
that needs a name expanded properly relative to some other directory will
then be sure to expand the name before calling `dired-buffers-for-dir'.
___

If you don't agree to such a code change, fine.  But in that case I
suggest that the doc of `dired-buffers-for-dir' say explicitly that
argument DIR needs to be an expanded absolute file name.  The doc needs
to explicitly say "expanded", because `file-absolute-p' doesn't test for
this meaning of "absolute" file name - the name cannot use `~' for a
home directory.

In GNU Emacs 27.2 (build 1, x86_64-w64-mingw32)
 of 2021-03-26 built on CIRROCUMULUS
Repository revision: deef5efafb70f4b171265b896505b92b6eef24e6
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.19042
System Description: Microsoft Windows 10 Pro (v10.0.2009.19042.1348)

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static''






             reply	other threads:[~2021-12-09 21:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 21:59 Drew Adams [this message]
2021-12-10 11:33 ` bug#52395: 27.2; Expansion of DIR arg of `dired-buffers-for-dir' Lars Ingebrigtsen

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=CO6PR10MB54732C589C62484EFC68A032F3709@CO6PR10MB5473.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=52395@debbugs.gnu.org \
    /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).