Subject: bug#59047: closed (Re: bug#59047: 29.0.50; [PATCH] dired-hide-subdir breaks dired-hide-details-mode)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 10 Nov 2022 10:10:02 +0000

Your bug report

#59047: 29.0.50; [PATCH] dired-hide-subdir breaks dired-hide-details-mode

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
59047: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59047
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#59047: 29.0.50; [PATCH] dired-hide-subdir breaks dired-hide-details-mode
From: Eli Zaretskii <[email-masked]>
To: Gabriel <[email-masked]>
Cc: [email-masked]
Date: Thu, 10 Nov 2022 12:09:25 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Gabriel <[email-masked]>
> Date: Sat, 05 Nov 2022 08:32:16 -0300
> 
> Description:
> In Dired, the use of `dired-hide-subdir' breaks the subsequent
> invocations of `dired-hide-details-mode'.
> 
> Steps to reproduce:
> Emacs 29.0.50 (master 8721e87a6ec0874057f83f54498a0e3a64475a53)
> 1) emacs -Q
> 2) Open any Dired buffer, e.g.: C-x C-f ~/
> 3) Press key ( a couple of times to toggle `dired-hide-details-mode'
> 4) Press key $ twice to hide and unhide the current directory list
> 5) Press key ( a couple of times to toggle `dired-hide-details-mode'
> 
> On step 5), the `dired-hide-details-mode' ceases to work.
> 
> Patch:
> The patch below adds a call to `dired-insert-set-properties` to restore
> the text properties lost by `dired-hide-subdir'. More specifically, the
> `dired--hide' removes the 'invisible text property that is used by Dired
> to toggle the visibility of some information, such as
> details-information, details-detail and details-link.

Thanks, installed.

Subject: 29.0.50; [PATCH] dired-hide-subdir breaks dired-hide-details-mode
From: Gabriel <[email-masked]>
To: [email-masked]
Date: Sat, 05 Nov 2022 08:32:16 -0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Description:
In Dired, the use of `dired-hide-subdir' breaks the subsequent
invocations of `dired-hide-details-mode'.

Steps to reproduce:
Emacs 29.0.50 (master 8721e87a6ec0874057f83f54498a0e3a64475a53)
1) emacs -Q
2) Open any Dired buffer, e.g.: C-x C-f ~/
3) Press key ( a couple of times to toggle `dired-hide-details-mode'
4) Press key $ twice to hide and unhide the current directory list
5) Press key ( a couple of times to toggle `dired-hide-details-mode'

On step 5), the `dired-hide-details-mode' ceases to work.

Patch:
The patch below adds a call to `dired-insert-set-properties` to restore
the text properties lost by `dired-hide-subdir'. More specifically, the
`dired--hide' removes the 'invisible text property that is used by Dired
to toggle the visibility of some information, such as
details-information, details-detail and details-link.

>From 24100cce5eca106d5019def99ba39848fff1a901 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <[email-masked]>
Date: Sat, 5 Nov 2022 08:27:50 -0300
Subject: [PATCH 1/1] Make dired-hide-details-mode work after
 dired-hide-subdir.

* lisp/dired.el (dired--unhide): Restore text properties.
---
 lisp/dired.el            |  3 ++-
 test/lisp/dired-tests.el | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 209e270942..825d0e4750 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3034,7 +3034,8 @@ dired--unhide
       (remove-list-of-text-properties
        (progn (goto-char start) (line-end-position))
        (progn (goto-char end) (line-end-position))
-       '(invisible)))))
+       '(invisible))
+      (dired-insert-set-properties start end))))
 
 ;;; Functions for finding the file name in a dired buffer line
 
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 09becc7fe7..fd7ff73267 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -288,6 +288,16 @@ dired-test-bug27631
             (should (cdr (dired-get-marked-files))))
         (when (buffer-live-p buf) (kill-buffer buf))))))
 
+(ert-deftest dired-test-bugXXXX ()
+  "Test for https://debbugs.gnu.org/XXXX ."
+  (dired (list (expand-file-name "src" source-directory)
+               "cygw32.c" "alloc.c" "w32xfns.c" "xdisp.c"))
+  (dired-hide-all)
+  (dired-hide-all)
+  (dired-next-line 1)
+  (should (equal 'dired-hide-details-detail
+                 (get-text-property (1+ (line-beginning-position)) 'invisible))))
+
 (ert-deftest dired-test-bug27899 ()
   "Test for https://debbugs.gnu.org/27899 ."
   :tags '(:unstable)
-- 
2.34.1

I did some tests and could not find any regression. I wrote a simple
test case. If there is a better way to fix the issue or to improve the
test case, let me know.

---
Gabriel