unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Harald Judt <h.judt@gmx.at>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : dired cons bug?
Date: Thu, 11 Aug 2022 13:38:53 +0000	[thread overview]
Message-ID: <SJ0PR10MB54880372E3886F60F817FDB0F3649@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <cebed6c6-16b9-0ec6-a05d-a03337ee1c9e@gmx.at>

> (dired (cons "/home/user" '("/home/user/tmp/test/a/a"
> "/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
> 
> after hitting "x" to execute, then confirming the deletion,
> the buffer will refresh...
> I can revert the buffer using "g".

I think you mean that dired _without_ such a cons arg
can be reverted OK in that scenario.  With a cons arg
it cannot - you'll get an error such as this:

"Reading directory: Directory doesn't exist or is
inaccessible, home/user/tmp/test/a/a", where the
"directory" named is actually the file (or directory)
that you deleted.  (At least when `ls-lisp.el' is
used, as is the case on MS Windows, and probably in
general.)

(The error msg says "directory" because the code that
inserts each file or dir in your cons thinks it's
inserting a directory.  That msg, at least, could be
fixed up.)

Yes, as Eli said, you can file a bug report for this.

However, it's definitely not the case that everything
you can do with a normal Dired buffer you can do with
such a Dired buffer, which lists arbitrary files,
from anywhere.

Dired is not using `ls' to manage such a buffer.  It
lists the files and dirs in the cons you pass it, and
it lets you do many operations on them (marking,...),
but there are some Dired operations that aren't
supported in this context.

When you pass a cons, `dired' just lists those files.
If you then perform operations (in Dired or elsewhere)
that change those files, reverting just tries to do
again what you initially did - list the same set of
files from your cons.

So yes, you can revert, but only as long as the list
of files you used is still valid.  If you've deleted
or renamed any of them then you can't revert - Dired 
just tries to relist the same list you provided in
your cons, when you use `g'.

IOW, Dired is showing you a snapshot.  If you change
the state, so the snapshot is no longer faithful of
what the real state is, Dired won't know that, any
more than it would if you gave it a cons in the first
place that had file names that don't correspond to
real files.

Dired listings of arbitrary files and dirs are still
_very_ useful.  They can be from anywhere, including
multiple drives, local and remote, etc.  (And if you
use Bookmark+ you can bookmark them for reuse.)

Dired+ supports the use of cons this way a bit more
than vanilla Emacs.  But the essential limitation
(bug, if you like) remains.

These emacs.SE posts say more about how you can
create and use such Dired buffers that list
arbitrary files:

https://emacs.stackexchange.com/a/71831

https://emacs.stackexchange.com/a/72065

https://emacs.stackexchange.com/a/72064

___

Dired+ is here:

https://www.emacswiki.org/emacs/DiredPlus

https://www.emacswiki.org/emacs/download/dired%2b.el

      parent reply	other threads:[~2022-08-11 13:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10 11:26 dired cons bug? Harald Judt
2022-08-11  5:55 ` Jean Louis
2022-08-11  6:42   ` Eli Zaretskii
2022-08-11  9:32     ` Jean Louis
2022-08-11  8:11   ` Harald Judt
2022-08-11  9:23 ` Harald Judt
2022-08-12  5:50   ` Eli Zaretskii
2022-08-11 13:30 ` Eli Zaretskii
2022-08-11 13:38 ` Drew Adams [this message]

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=SJ0PR10MB54880372E3886F60F817FDB0F3649@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=h.judt@gmx.at \
    --cc=help-gnu-emacs@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.
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).