unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52395: 27.2; Expansion of DIR arg of `dired-buffers-for-dir'
@ 2021-12-09 21:59 Drew Adams
  2021-12-10 11:33 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Drew Adams @ 2021-12-09 21:59 UTC (permalink / raw)
  To: 52395

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






^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#52395: 27.2; Expansion of DIR arg of `dired-buffers-for-dir'
  2021-12-09 21:59 bug#52395: 27.2; Expansion of DIR arg of `dired-buffers-for-dir' Drew Adams
@ 2021-12-10 11:33 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-10 11:33 UTC (permalink / raw)
  To: Drew Adams; +Cc: 52395

Drew Adams <drew.adams@oracle.com> writes:

> 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')?

Makes sense to me.  Now done in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-10 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 21:59 bug#52395: 27.2; Expansion of DIR arg of `dired-buffers-for-dir' Drew Adams
2021-12-10 11:33 ` Lars Ingebrigtsen

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