Subject: Re: bug#61510: 28.2; dired-hide-details-mode shows symlink targets after entering and exiting wdired

From: Stephen Berman <[email-masked]>
Date: Wed, 15 Feb 2023 00:44:55 +0100

On Tue, 14 Feb 2023 19:10:16 +0200 Eli Zaretskii <[email-masked]> wrote:

>> From: Iñaki Cornejo de la Mora <[email-masked]>
>> Date: Tue, 14 Feb 2023 10:16:52 -0600
>> 
>> When using dired-hide-details-mode with the default of hiding symlink
>> targets (setq dired-hide-details-hide-symlink-targets t), the targets
>> become visible when entering wdired (expected and really useful)
>> but they remain visible after exiting the mode with any of:
>> - wdired-abort-changes
>> - wdired-exit
>> - wdired-finish-edit
>> 
>> The only way to restore the previous look is to toggle
>> dired-hide-details-mode off and on so that symlink targets are
>> hidden again. I assume this is unexpected behaviour and hope this helps.
>
> Thank you for your report.
>
> To make the investigation of this issue easier, could you please post
> a step-by-step recipe for reproducing this starting from "emacs -Q"?

I can reproduce the problem:

0. emacs -Q
1. Visit a directory in Dired where you have write permission, e.g. /tmp
   and on some file line there, e.g. .X0-lock, type `S bla RET' to set
   the symlink "bla" to that file.  Now the directory has e.g. this
   entry:
   lrwxrwxrwx  1 steve steve     13 Feb 15 00:31 bla -> /tmp/.X0-lock
2. Type `(' to enable dired-hide-details-mode; now the previous entry
   looks like this:
   bla ->
3. Type `C-x C-q' to enter wdired-mode; now the previous entry looks
   like this:
   bla -> /tmp/.X0-lock
4. Type `C-x C-s' to return to dired-mode; the previous entry still
   looks like this
   bla -> /tmp/.X0-lock
   instead of like this:
   bla ->

With the patch below the result after step 4 is "bla ->".  But I haven't
tested it with any other case, so maybe it has unwanted consequences.

Steve Berman

diff --git a/lisp/wdired.el b/lisp/wdired.el
index 771458508e6..5572dcb32f3 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -455,6 +455,7 @@ wdired-change-to-dired-mode
   (setq major-mode 'dired-mode)
   (setq mode-name "Dired")
   (dired-advertise)
+  (dired-hide-details-update-invisibility-spec)
   (remove-hook 'kill-buffer-hook #'wdired-check-kill-buffer t)
   (remove-hook 'before-change-functions #'wdired--before-change-fn t)
   (remove-hook 'after-change-functions #'wdired--restore-properties t)