* dired cons bug?
@ 2022-08-10 11:26 Harald Judt
2022-08-11 5:55 ` Jean Louis
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Harald Judt @ 2022-08-10 11:26 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1132 bytes --]
Hi,
I have a question regarding using dired programmatically in Emacs 28.1. Say I
do the following call to open a dired buffer and insert the files:
(dired (cons "/home/user" '("/home/user/tmp/test/a/a"
"/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
It works fine, I get a nice listing and can move around like expected, mark
files and try to delete them. Now it gets interesting: Usually after hitting
"x" to execute, then confirming the deletion, the buffer will refresh. But not
in this case, not when I open dired using the cons above. I can revert the
buffer using "g".
Note that when I simply do (dired "/home/user/tmp/test"), then insert the
subdir to show the files and delete them, this is not reproducible. The buffer
will be refreshed immediately after the delete operation completes.
Why? Am I missing something? Is this a (known) bug or expected behaviour? I've
tried with emacs -Q, so it seems to be no configuration problem.
Regards,
Harald
--
`Experience is the best teacher.'
PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
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 8:11 ` Harald Judt
2022-08-11 9:23 ` Harald Judt
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Jean Louis @ 2022-08-11 5:55 UTC (permalink / raw)
To: Harald Judt; +Cc: help-gnu-emacs
* Harald Judt <h.judt@gmx.at> [2022-08-11 08:05]:
> Hi,
>
> I have a question regarding using dired programmatically in Emacs 28.1. Say I
> do the following call to open a dired buffer and insert the files:
>
> (dired "/home/"(cons "/home/admin" '("/home/user/tmp/test/a/a" "/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
Function is not intended to be use that way.
(dired DIRNAME &optional SWITCHES)
DIRNAME must be directory name. Not cons and some files inside.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
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
1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2022-08-11 6:42 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Thu, 11 Aug 2022 08:55:40 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
>
> * Harald Judt <h.judt@gmx.at> [2022-08-11 08:05]:
> > Hi,
> >
> > I have a question regarding using dired programmatically in Emacs 28.1. Say I
> > do the following call to open a dired buffer and insert the files:
> >
> > (dired "/home/"(cons "/home/admin" '("/home/user/tmp/test/a/a" "/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
>
> Function is not intended to be use that way.
>
> (dired DIRNAME &optional SWITCHES)
>
> DIRNAME must be directory name. Not cons and some files inside.
Did you consult the doc string before writing the above? It says:
If DIRNAME is a string, Dired displays a list of files in DIRNAME (which
may also have shell wildcards appended to select certain files).
If DIRNAME is a cons, its first element is taken as the directory name
and the rest as an explicit list of files to make directory entries for.
In this case, SWITCHES are applied to each of the files separately, and
therefore switches that control the order of the files in the produced
listing have no effect.
So yes, passing a cons as an argument _is_ supported.
To the OP: please report this as a bug using report-emacs-bug, so that
we could fix it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
2022-08-11 6:42 ` Eli Zaretskii
@ 2022-08-11 9:32 ` Jean Louis
0 siblings, 0 replies; 10+ messages in thread
From: Jean Louis @ 2022-08-11 9:32 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
* Eli Zaretskii <eliz@gnu.org> [2022-08-11 09:43]:
> > Date: Thu, 11 Aug 2022 08:55:40 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> >
> > * Harald Judt <h.judt@gmx.at> [2022-08-11 08:05]:
> > > Hi,
> > >
> > > I have a question regarding using dired programmatically in Emacs 28.1. Say I
> > > do the following call to open a dired buffer and insert the files:
> > >
> > > (dired "/home/"(cons "/home/admin" '("/home/user/tmp/test/a/a" "/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
> >
> > Function is not intended to be use that way.
> >
> > (dired DIRNAME &optional SWITCHES)
> >
> > DIRNAME must be directory name. Not cons and some files inside.
>
> Did you consult the doc string before writing the above? It says:
You are right, I did not. Next time I will.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
2022-08-11 5:55 ` Jean Louis
2022-08-11 6:42 ` Eli Zaretskii
@ 2022-08-11 8:11 ` Harald Judt
1 sibling, 0 replies; 10+ messages in thread
From: Harald Judt @ 2022-08-11 8:11 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1780 bytes --]
Am 11.08.22 um 07:55 schrieb Jean Louis:
> * Harald Judt <h.judt@gmx.at> [2022-08-11 08:05]:
>> Hi,
>>
>> I have a question regarding using dired programmatically in Emacs 28.1. Say I
>> do the following call to open a dired buffer and insert the files:
>>
>> (dired "/home/"(cons "/home/admin" '("/home/user/tmp/test/a/a" "/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
>
> Function is not intended to be use that way.
>
> (dired DIRNAME &optional SWITCHES)
>
> DIRNAME must be directory name. Not cons and some files inside.
Documentation says something different, and why should it work if that was not
true?
------------------------------------------------------------------------
If DIRNAME is a string, Dired displays a list of files in DIRNAME (which
may also have shell wildcards appended to select certain files).
If DIRNAME is a cons, its first element is taken as the directory name
and the rest as an explicit list of files to make directory entries for.
In this case, SWITCHES are applied to each of the files separately, and
therefore switches that control the order of the files in the produced
listing have no effect.
You can flag files for deletion with d and then
delete them by typing x.
Type h after entering Dired for more info.
------------------------------------------------------------------------
But then it also says this, which I have missed until now:
`If DIRNAME is already in a Dired buffer, that buffer is used without refresh.'
Maybe that has something to do with my problem? How could I get the buffer to
be used *WITH* refresh?
Regards,
Harald
--
`Experience is the best teacher.'
PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
2022-08-10 11:26 dired cons bug? Harald Judt
2022-08-11 5:55 ` Jean Louis
@ 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 ` [External] : " Drew Adams
3 siblings, 1 reply; 10+ messages in thread
From: Harald Judt @ 2022-08-11 9:23 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1852 bytes --]
Am 10.08.22 um 13:26 schrieb Harald Judt:
> Hi,
>
> I have a question regarding using dired programmatically in Emacs 28.1. Say I
> do the following call to open a dired buffer and insert the files:
>
> (dired (cons "/home/user" '("/home/user/tmp/test/a/a"
> "/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
>
> It works fine, I get a nice listing and can move around like expected, mark
> files and try to delete them. Now it gets interesting: Usually after hitting
> "x" to execute, then confirming the deletion, the buffer will refresh. But not
> in this case, not when I open dired using the cons above. I can revert the
> buffer using "g".
>
> Note that when I simply do (dired "/home/user/tmp/test"), then insert the
> subdir to show the files and delete them, this is not reproducible. The buffer
> will be refreshed immediately after the delete operation completes.
>
> Why? Am I missing something? Is this a (known) bug or expected behaviour? I've
> tried with emacs -Q, so it seems to be no configuration problem.
>
> Regards,
> Harald
I have found an explanation for my own question: The problem is that after a
dired-do-xxxx command, the buffer of the _target_ directory will be refreshed.
But the target directory of /home/user/tmp/test/a/a would be
/home/user/tmp/test/a/, and that is different from the one used in the base
dir of the cons (/home/user/). In fact, if I add a file /home/user/x and add
that to the file list and delete it, the buffer will be reverted correctly. If
I delete any of the other files, it won't.
Now, what could I do to programmatically revert the current dired buffer after
executing a dired-do command?
Harald
--
`Experience is the best teacher.'
PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
2022-08-11 9:23 ` Harald Judt
@ 2022-08-12 5:50 ` Eli Zaretskii
0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2022-08-12 5:50 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Thu, 11 Aug 2022 11:23:52 +0200
> From: Harald Judt <h.judt@gmx.at>
>
> I have found an explanation for my own question: The problem is that after a
> dired-do-xxxx command, the buffer of the _target_ directory will be refreshed.
> But the target directory of /home/user/tmp/test/a/a would be
> /home/user/tmp/test/a/, and that is different from the one used in the base
> dir of the cons (/home/user/). In fact, if I add a file /home/user/x and add
> that to the file list and delete it, the buffer will be reverted correctly. If
> I delete any of the other files, it won't.
>
> Now, what could I do to programmatically revert the current dired buffer after
> executing a dired-do command?
I have posted a patch that's supposed to fix this. Please try it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
2022-08-10 11:26 dired cons bug? Harald Judt
2022-08-11 5:55 ` Jean Louis
2022-08-11 9:23 ` Harald Judt
@ 2022-08-11 13:30 ` Eli Zaretskii
2022-08-11 13:38 ` [External] : " Drew Adams
3 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2022-08-11 13:30 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 10 Aug 2022 13:26:25 +0200
> From: Harald Judt <h.judt@gmx.at>
>
> I have a question regarding using dired programmatically in Emacs 28.1. Say I
> do the following call to open a dired buffer and insert the files:
>
> (dired (cons "/home/user" '("/home/user/tmp/test/a/a"
> "/home/user/tmp/test/b/b" "/home/user/tmp/test/c/c")))
>
> It works fine, I get a nice listing and can move around like expected, mark
> files and try to delete them. Now it gets interesting: Usually after hitting
> "x" to execute, then confirming the deletion, the buffer will refresh. But not
> in this case, not when I open dired using the cons above. I can revert the
> buffer using "g".
>
> Note that when I simply do (dired "/home/user/tmp/test"), then insert the
> subdir to show the files and delete them, this is not reproducible. The buffer
> will be refreshed immediately after the delete operation completes.
>
> Why? Am I missing something? Is this a (known) bug or expected behaviour? I've
> tried with emacs -Q, so it seems to be no configuration problem.
I think it's a bug. Please see if the patch below gives good results.
diff --git a/lisp/dired.el b/lisp/dired.el
index f261f9f..f7651c6 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3674,7 +3674,10 @@ dired-internal-do-deletions
(progress-reporter-update progress-reporter succ)
(dired-fun-in-all-buffers
(file-name-directory fn) (file-name-nondirectory fn)
- #'dired-delete-entry fn))
+ #'dired-delete-entry fn)
+ ;; For when FN's directory name is different
+ ;; from the current buffer's dired-directory.
+ (dired-delete-entry fn))
(quit (throw '--delete-cancel (message "OK, canceled")))
(error ;; catch errors from failed deletions
(dired-log "%s: %s\n" (car err) (error-message-string err))
^ permalink raw reply related [flat|nested] 10+ messages in thread
* RE: [External] : dired cons bug?
2022-08-10 11:26 dired cons bug? Harald Judt
` (2 preceding siblings ...)
2022-08-11 13:30 ` Eli Zaretskii
@ 2022-08-11 13:38 ` Drew Adams
3 siblings, 0 replies; 10+ messages in thread
From: Drew Adams @ 2022-08-11 13:38 UTC (permalink / raw)
To: Harald Judt, help-gnu-emacs@gnu.org
> (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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: dired cons bug?
@ 2022-08-13 23:05 Harald Judt
0 siblings, 0 replies; 10+ messages in thread
From: Harald Judt @ 2022-08-13 23:05 UTC (permalink / raw)
To: eliz, help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1218 bytes --]
Hi Eli,
> >/Date: Thu, 11 Aug 2022 11:23:52 +0200/
> >/From: Harald Judt <h.judt@gmx.at>/
> >//
> >/I have found an explanation for my own question: The problem is that after a /
> >/dired-do-xxxx command, the buffer of the _target_ directory will be /
> >/refreshed. /
> >/But the target directory of /home/user/tmp/test/a/a would be /
> >//home/user/tmp/test/a/, and that is different from the one used in the base /
> >/dir of the cons (/home/user/). In fact, if I add a file /home/user/x and add /
> >/that to the file list and delete it, the buffer will be reverted correctly. /
> >/If /
> >/I delete any of the other files, it won't./
> >//
> >/Now, what could I do to programmatically revert the current dired buffer /
> >/after /
> >/executing a dired-do command?/
>
> I have posted a patch that's supposed to fix this. Please try it.
Thanks for your patch, I have tried it and it indeed fixes my problems. I have
not noticed any new problems caused by it so far, but I'll give it some more
thorough testing next week.
Regards,
Harald
--
`Experience is the best teacher.'
PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-08-13 23:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [External] : " Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2022-08-13 23:05 Harald Judt
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).