unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
@ 2024-07-24 11:17 Alvaro Ramirez
  2024-08-04  8:06 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Alvaro Ramirez @ 2024-07-24 11:17 UTC (permalink / raw)
  To: 72272

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

Tags: patch

Hi folks,

Sending an initial patch. Happy to iterate on it, add tests, 
etc. if we
reckon the feature is worth pursuing.

Set `dired-hide-details-hide-absolute-location` to non-nil and 
toggle
`dired-hide-details-mode` to hide the current directory's absolute 
path.

This is my first submission, might need some process guidance.

Alvaro

In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin23.5.0, NS
 appkit-2487.60 Version 14.5 (Build 23F79)) of 2024-07-23 built on 
 jiko
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.5

Configured using:
 'configure --with-ns
 --prefix=/Users/alvaro/stuff/active/code/third_party/emacs/nextstep/Emacs.app/Contents/MacOS
 --enable-locallisppath=/Users/alvaro/stuff/active/code/third_party/emacs/nextstep/Emacs.app/Contents/MacOS'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-dired-hide-details.patch --]
[-- Type: text/patch, Size: 2882 bytes --]

From 6f79b6baa00f7087c81b48ef136590634efa059d Mon Sep 17 00:00:00 2001
From: xenodium <me+gh@xenodium.com>
Date: Tue, 23 Jul 2024 21:55:37 +0100
Subject: [PATCH] Hides current location's path via dired-hide-details-mode

---
 lisp/dired.el | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 0d526dfc376..3d92cee2ee5 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -387,6 +387,12 @@ dired-hide-details-hide-information-lines
   :version "24.4"
   :group 'dired)
 
+(defcustom dired-hide-details-hide-absolute-location t
+  "Non-nil means `dired-hide-details-mode' hides current location's absolute path."
+  :type 'boolean
+  :version "31.1"
+  :group 'dired)
+
 (defcustom dired-always-read-filesystem nil
   "Non-nil means revert buffers visiting files before searching them.
 By default,  commands like `dired-mark-files-containing-regexp' will
@@ -3243,8 +3249,9 @@ dired-hide-details-mode
 When this minor mode is enabled, details such as file ownership and
 permissions are hidden from view.
 
-See options: `dired-hide-details-hide-symlink-targets' and
-`dired-hide-details-hide-information-lines'."
+See options: `dired-hide-details-hide-symlink-targets',
+`dired-hide-details-hide-information-lines' and
+`dired-hide-details-hide-absolute-location'."
   :group 'dired
   (unless (derived-mode-p '(dired-mode wdired-mode))
     (error "Not a Dired buffer"))
@@ -3268,6 +3275,11 @@ dired-hide-details-update-invisibility-spec
 	       'add-to-invisibility-spec
 	     'remove-from-invisibility-spec)
 	   'dired-hide-details-information)
+  (funcall (if (and dired-hide-details-mode
+		    dired-hide-details-hide-absolute-location)
+	       'add-to-invisibility-spec
+	     'remove-from-invisibility-spec)
+	   'dired-hide-details-absolute-location)
   (funcall (if (and dired-hide-details-mode
 		    dired-hide-details-hide-symlink-targets
 		    (not (derived-mode-p 'wdired-mode)))
@@ -3674,7 +3686,14 @@ dired-build-subdir-alist
 				(substring new-dir-name (match-end 0)))
 		      (expand-file-name new-dir-name))))
 	    (delete-region (point) (match-end 1))
-	    (insert new-dir-name))
+            (if-let ((dir-base (file-name-nondirectory new-dir-name))
+                     (dir-path (file-name-directory new-dir-name))
+                     (hide-dir-path (and dired-hide-details-hide-absolute-location
+                                         (not (string-empty-p dir-base)))))
+                (insert (concat
+                         (propertize dir-path 'invisible 'dired-hide-details-absolute-location)
+                         dir-base))
+	      (insert new-dir-name)))
 	  (setq count (1+ count))
 	  ;; Undo any escaping of newlines and \ by dired-insert-directory.
 	  ;; Convert "n" preceded by odd number of \ to newline, and \\ to \.
-- 
2.39.3 (Apple Git-146)


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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-07-24 11:17 bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path Alvaro Ramirez
@ 2024-08-04  8:06 ` Eli Zaretskii
  2024-08-05  9:45   ` Andrea Corallo
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-08-04  8:06 UTC (permalink / raw)
  To: Alvaro Ramirez, Stefan Monnier, Andrea Corallo; +Cc: 72272

> From: Alvaro Ramirez <alvaro@xenodium.com>
> Date: Wed, 24 Jul 2024 12:17:58 +0100
> 
> Hi folks,
> 
> Sending an initial patch. Happy to iterate on it, add tests, 
> etc. if we
> reckon the feature is worth pursuing.
> 
> Set `dired-hide-details-hide-absolute-location` to non-nil and 
> toggle
> `dired-hide-details-mode` to hide the current directory's absolute 
> path.
> 
> This is my first submission, might need some process guidance.

Thanks.

Stefan and Andrea, any comments?

I have a few minor ones:

> From: xenodium <me+gh@xenodium.com>
> Date: Tue, 23 Jul 2024 21:55:37 +0100
> Subject: [PATCH] Hides current location's path via dired-hide-details-mode
                                            ^^^^
Please don't use "path" for anything except PATH-style directory
lists.  The GNU Coding Standards frown on such usage.

> +(defcustom dired-hide-details-hide-absolute-location t
> +  "Non-nil means `dired-hide-details-mode' hides current location's absolute path."

Same here.

> +            (if-let ((dir-base (file-name-nondirectory new-dir-name))
> +                     (dir-path (file-name-directory new-dir-name))
> +                     (hide-dir-path (and dired-hide-details-hide-absolute-location

And here.

Also, this change needs a NEWS entry.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-08-04  8:06 ` Eli Zaretskii
@ 2024-08-05  9:45   ` Andrea Corallo
       [not found]     ` <d75b2eb4e45413d468c15f4d6e8c3d0ce568d28ddbf7a828a4f917f29e54cbcb@mu.id>
  0 siblings, 1 reply; 17+ messages in thread
From: Andrea Corallo @ 2024-08-05  9:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Alvaro Ramirez, 72272, Stefan Monnier

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alvaro Ramirez <alvaro@xenodium.com>
>> Date: Wed, 24 Jul 2024 12:17:58 +0100
>> 
>> Hi folks,
>> 
>> Sending an initial patch. Happy to iterate on it, add tests, 
>> etc. if we
>> reckon the feature is worth pursuing.
>> 
>> Set `dired-hide-details-hide-absolute-location` to non-nil and 
>> toggle
>> `dired-hide-details-mode` to hide the current directory's absolute 
>> path.
>> 
>> This is my first submission, might need some process guidance.
>
> Thanks.
>
> Stefan and Andrea, any comments?
>
> I have a few minor ones:
>
>> From: xenodium <me+gh@xenodium.com>
>> Date: Tue, 23 Jul 2024 21:55:37 +0100
>> Subject: [PATCH] Hides current location's path via dired-hide-details-mode
>                                             ^^^^
> Please don't use "path" for anything except PATH-style directory
> lists.  The GNU Coding Standards frown on such usage.
>
>> +(defcustom dired-hide-details-hide-absolute-location t
>> +  "Non-nil means `dired-hide-details-mode' hides current location's absolute path."
>
> Same here.
>
>> +            (if-let ((dir-base (file-name-nondirectory new-dir-name))
>> +                     (dir-path (file-name-directory new-dir-name))
>> +                     (hide-dir-path (and dired-hide-details-hide-absolute-location
>
> And here.
>
> Also, this change needs a NEWS entry.

No further comments other than:

> @@ -3268,6 +3275,11 @@ dired-hide-details-update-invisibility-spec
>  	       'add-to-invisibility-spec
>  	     'remove-from-invisibility-spec)
>  	   'dired-hide-details-information)
> +  (funcall (if (and dired-hide-details-mode
> +		    dired-hide-details-hide-absolute-location)
> +	       'add-to-invisibility-spec
> +	     'remove-from-invisibility-spec)
> +	   'dired-hide-details-absolute-location)

don't we favor #' in place of ' when quoting functions?

Thanks

  Andrea





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
       [not found]     ` <d75b2eb4e45413d468c15f4d6e8c3d0ce568d28ddbf7a828a4f917f29e54cbcb@mu.id>
@ 2024-08-05 14:34       ` Alvaro Ramirez
  2024-08-17  8:53         ` Eli Zaretskii
  2024-10-01 21:17         ` Stefan Kangas
  0 siblings, 2 replies; 17+ messages in thread
From: Alvaro Ramirez @ 2024-08-05 14:34 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: eliz, 72272

[-- Attachment #1: Type: text/plain, Size: 2569 bytes --]

+cc 72272@debbugs.gnu.org

Thank you for the comments Andrea and Eli.

Andrea Corallo <acorallo@gnu.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>
>> Thanks.
>>
>> Stefan and Andrea, any comments?
>>
>> I have a few minor ones:
>>
>>> From: xenodium <me+gh@xenodium.com>
>>> Date: Tue, 23 Jul 2024 21:55:37 +0100
>>> Subject: [PATCH] Hides current location's path via
>>> dired-hide-details-mode
>>                                             ^^^^
>> Please don't use "path" for anything except PATH-style
>> directory
>> lists.  The GNU Coding Standards frown on such usage.
>>

Ah got it. TIL the naming convention used for functions like of 
file-name-as-directory.

>>> +(defcustom dired-hide-details-hide-absolute-location t
>>> +  "Non-nil means `dired-hide-details-mode' hides current
>>> location's absolute path."
>>
>> Same here.

Done

>>
>>> +            (if-let ((dir-base (file-name-nondirectory
>>> new-dir-name))
>>> +                     (dir-path (file-name-directory
>>> new-dir-name))
>>> +                     (hide-dir-path (and
>>> dired-hide-details-hide-absolute-location
>>
>> And here.

Done

>>
>> Also, this change needs a NEWS entry.

Added

>
> No further comments other than:
>
>> @@ -3268,6 +3275,11 @@
>> dired-hide-details-update-invisibility-spec
>>  	       'add-to-invisibility-spec
>>  	     'remove-from-invisibility-spec)
>>  	   'dired-hide-details-information)
>> +  (funcall (if (and dired-hide-details-mode
>> +		    dired-hide-details-hide-absolute-location)
>> +	       'add-to-invisibility-spec
>> +	     'remove-from-invisibility-spec)
>> +	   'dired-hide-details-absolute-location)
>
> don't we favor #' in place of ' when quoting functions?

Added

I also modified the patch a little to cater for 
`dired-maybe-insert-subdir` (see 
https://lists.gnu.org/archive/html/emacs-devel/2024-08/msg00033.html) 
and to include a couple of tests.

May be worth noting, the following dired.el comment seemed
outdated 
https://github.com/emacs-mirror/emacs/blob/c7d9cd722e5a7042a52c92f8497f903bfe9870b8/lisp/dired.el#L1805

 ;; Note that dired-build-subdir-alist will replace the name
 ;; by its expansion, so it does not matter whether what we insert
 ;; here is fully expanded, but it should be absolute.

The mentioned replacement doesn't take place when using 
`dired-maybe-insert-subdir`, so I tweaked the comment. Setting 
invisible property is now needed in two places (to handle current 
location and now subdirs).

Please take a look at the latest patch. Happy to go with a 
different direction if preferred.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Hides-directory-absolute-location-via-dired-hide-det.patch --]
[-- Type: text/x-patch; size=7.83KiB, Size: 8013 bytes --]

From 6702ccac4b818f77cb3d7afe4d002127ac2a77c6 Mon Sep 17 00:00:00 2001
From: xenodium <me+gh@xenodium.com>
Date: Tue, 23 Jul 2024 21:55:37 +0100
Subject: [PATCH] Hides directory absolute location via dired-hide-details-mode

---
 etc/NEWS                 |  6 +++++
 lisp/dired.el            | 47 ++++++++++++++++++++++++++++++++--------
 test/lisp/dired-tests.el | 44 +++++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index b89a80aa14d..51a4a658467 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -210,6 +210,12 @@ The host name for Kubernetes connections can be of kind
 used.  This overrides the setiing in 'tramp-kubernetes-namespace', if
 any.
 
+** Dired
+
++++
+*** New option 'dired-hide-details-hide-absolute-location', enabled by default.
+If non-nil, 'dired-hide-details-mode' also hides directories' absolute locations.
+
 \f
 * New Modes and Packages in Emacs 31.1
 
diff --git a/lisp/dired.el b/lisp/dired.el
index 0d526dfc376..18cde9f6e6a 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -387,6 +387,12 @@ dired-hide-details-hide-information-lines
   :version "24.4"
   :group 'dired)
 
+(defcustom dired-hide-details-hide-absolute-location t
+  "Non-nil means `dired-hide-details-mode' hides directory absolute location."
+  :type 'boolean
+  :version "31.1"
+  :group 'dired)
+
 (defcustom dired-always-read-filesystem nil
   "Non-nil means revert buffers visiting files before searching them.
 By default,  commands like `dired-mark-files-containing-regexp' will
@@ -1802,12 +1808,20 @@ dired-insert-directory
 	  (when (and (or hdr wildcard)
 		     (not (and (looking-at "^  \\(.*\\):$")
 			       (file-name-absolute-p (match-string 1)))))
-	    ;; Note that dired-build-subdir-alist will replace the name
-	    ;; by its expansion, so it does not matter whether what we insert
-	    ;; here is fully expanded, but it should be absolute.
-	    (insert "  " (or (car-safe dir-wildcard)
-                             (directory-file-name (file-name-directory dir)))
-                    ":\n")
+            (let* ((dir-indent "  ")
+                   (dir-name (or (car-safe dir-wildcard)
+                                 (directory-file-name (file-name-directory dir))))
+                   (dir-name-point (+ (point) (length dir-indent)))
+                   (hideable-location (and dired-hide-details-hide-absolute-location
+                                           (not (string-empty-p (file-name-nondirectory dir-name))))))
+	      ;; Inserted directory name must be absolute, but keep in mind it
+              ;; may be replaced in some instances (e.g. dired-build-subdir-alist).
+              (insert dir-indent dir-name ":\n")
+              (when hideable-location
+                (put-text-property dir-name-point
+                                   (+ dir-name-point
+                                      (length (file-name-directory dir-name)))
+                                   'invisible 'dired-hide-details-absolute-location)))
 	    (setq content-point (point)))
 	  (when wildcard
 	    ;; Insert "wildcard" line where "total" line would be for a full dir.
@@ -3243,8 +3257,9 @@ dired-hide-details-mode
 When this minor mode is enabled, details such as file ownership and
 permissions are hidden from view.
 
-See options: `dired-hide-details-hide-symlink-targets' and
-`dired-hide-details-hide-information-lines'."
+See options: `dired-hide-details-hide-symlink-targets',
+`dired-hide-details-hide-information-lines' and
+`dired-hide-details-hide-absolute-location'."
   :group 'dired
   (unless (derived-mode-p '(dired-mode wdired-mode))
     (error "Not a Dired buffer"))
@@ -3268,6 +3283,11 @@ dired-hide-details-update-invisibility-spec
 	       'add-to-invisibility-spec
 	     'remove-from-invisibility-spec)
 	   'dired-hide-details-information)
+  (funcall (if (and dired-hide-details-mode
+		    dired-hide-details-hide-absolute-location)
+	       #'add-to-invisibility-spec
+	     #'remove-from-invisibility-spec)
+	   'dired-hide-details-absolute-location)
   (funcall (if (and dired-hide-details-mode
 		    dired-hide-details-hide-symlink-targets
 		    (not (derived-mode-p 'wdired-mode)))
@@ -3674,7 +3694,16 @@ dired-build-subdir-alist
 				(substring new-dir-name (match-end 0)))
 		      (expand-file-name new-dir-name))))
 	    (delete-region (point) (match-end 1))
-	    (insert new-dir-name))
+            (let ((new-dir-name-pos (point))
+                  (hideable-location (and dired-hide-details-hide-absolute-location
+                                          (not (string-empty-p
+                                                (file-name-nondirectory new-dir-name))))))
+              (insert new-dir-name)
+              (when hideable-location
+                (put-text-property new-dir-name-pos
+                                   (+ new-dir-name-pos
+                                      (length (file-name-directory new-dir-name)))
+			           'invisible 'dired-hide-details-absolute-location))))
 	  (setq count (1+ count))
 	  ;; Undo any escaping of newlines and \ by dired-insert-directory.
 	  ;; Convert "n" preceded by odd number of \ to newline, and \\ to \.
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 3b1f80d3d3d..be0a8a36d84 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -524,6 +524,50 @@ dired-test-directory-files-and-attributes
       (when (file-directory-p testdir)
         (delete-directory testdir t)))))
 
+(ert-deftest dired-test-hide-absolute-location-enabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location t)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible)))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible))))
+      (kill-buffer buffer))))
+
+(ert-deftest dired-test-hide-absolute-location-disabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location nil)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible)))
+      (kill-buffer buffer))))
+
 ;; `dired-insert-directory' output tests.
 (let* ((data-dir "insert-directory")
        (test-dir (file-name-as-directory
-- 
2.39.3 (Apple Git-146)


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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-08-05 14:34       ` Alvaro Ramirez
@ 2024-08-17  8:53         ` Eli Zaretskii
  2024-08-17  9:27           ` Alvaro Ramirez
  2024-10-01 21:17         ` Stefan Kangas
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-08-17  8:53 UTC (permalink / raw)
  To: Alvaro Ramirez; +Cc: 72272, acorallo

> From: Alvaro Ramirez <alvaro@xenodium.com>
> Cc: eliz@gnu.org, 72272@debbugs.gnu.org
> Date: Mon, 05 Aug 2024 15:34:17 +0100
> 
> I also modified the patch a little to cater for 
> `dired-maybe-insert-subdir` (see 
> https://lists.gnu.org/archive/html/emacs-devel/2024-08/msg00033.html) 
> and to include a couple of tests.
> 
> May be worth noting, the following dired.el comment seemed
> outdated 
> https://github.com/emacs-mirror/emacs/blob/c7d9cd722e5a7042a52c92f8497f903bfe9870b8/lisp/dired.el#L1805
> 
>  ;; Note that dired-build-subdir-alist will replace the name
>  ;; by its expansion, so it does not matter whether what we insert
>  ;; here is fully expanded, but it should be absolute.
> 
> The mentioned replacement doesn't take place when using 
> `dired-maybe-insert-subdir`, so I tweaked the comment. Setting 
> invisible property is now needed in two places (to handle current 
> location and now subdirs).
> 
> Please take a look at the latest patch. Happy to go with a 
> different direction if preferred.

Thanks, this LGTM.  However, AFAIU your copyright-assignment paperwork
is not yet completed, so we should wait for that, and then we can
install.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-08-17  8:53         ` Eli Zaretskii
@ 2024-08-17  9:27           ` Alvaro Ramirez
  2024-10-01 20:31             ` Alvaro Ramirez
  0 siblings, 1 reply; 17+ messages in thread
From: Alvaro Ramirez @ 2024-08-17  9:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72272, copyright-clerk, acorallo


> On 17 Aug 2024, at 09:53, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> 
>> 
>> From: Alvaro Ramirez <alvaro@xenodium.com>
>> Cc: eliz@gnu.org, 72272@debbugs.gnu.org
>> Date: Mon, 05 Aug 2024 15:34:17 +0100
>> 
>> I also modified the patch a little to cater for
>> `dired-maybe-insert-subdir` (see
>> https://lists.gnu.org/archive/html/emacs-devel/2024-08/msg00033.html)
>> and to include a couple of tests.
>> 
>> May be worth noting, the following dired.el comment seemed
>> outdated
>> https://github.com/emacs-mirror/emacs/blob/c7d9cd722e5a7042a52c92f8497f903bfe9870b8/lisp/dired.el#L1805
>> 
>> ;; Note that dired-build-subdir-alist will replace the name
>> ;; by its expansion, so it does not matter whether what we insert
>> ;; here is fully expanded, but it should be absolute.
>> 
>> The mentioned replacement doesn't take place when using
>> `dired-maybe-insert-subdir`, so I tweaked the comment. Setting
>> invisible property is now needed in two places (to handle current
>> location and now subdirs).
>> 
>> Please take a look at the latest patch. Happy to go with a
>> different direction if preferred.
> 
> Thanks, this LGTM.

Thanks Eli!

>  However, AFAIU your copyright-assignment paperwork
> is not yet completed, so we should wait for that, and then we can
> install.

+copyright-clerk@fsf.org

Sounds good. It’s submitted. Waiting for response. 




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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-08-17  9:27           ` Alvaro Ramirez
@ 2024-10-01 20:31             ` Alvaro Ramirez
  0 siblings, 0 replies; 17+ messages in thread
From: Alvaro Ramirez @ 2024-10-01 20:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72272, copyright-clerk, acorallo

Hi Eli

>> On 17 Aug 2024, at 09:53, Eli Zaretskii <eliz@gnu.org> wrote:

>> 
>> Thanks, this LGTM. However, AFAIU your copyright-assignment 
>> paperwork
>> is not yet completed,

My copyright-assignment is now approved as of today.

> > so we should wait for that, and then we can
>> install.

Is it Ok to install patch?





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-08-05 14:34       ` Alvaro Ramirez
  2024-08-17  8:53         ` Eli Zaretskii
@ 2024-10-01 21:17         ` Stefan Kangas
  2024-10-02 10:55           ` Alvaro Ramirez
  1 sibling, 1 reply; 17+ messages in thread
From: Stefan Kangas @ 2024-10-01 21:17 UTC (permalink / raw)
  To: Alvaro Ramirez, Andrea Corallo; +Cc: eliz, 72272

Alvaro Ramirez <alvaro@xenodium.com> writes:

> +** Dired
> +
> ++++
> +*** New option 'dired-hide-details-hide-absolute-location', enabled by default.
> +If non-nil, 'dired-hide-details-mode' also hides directories' absolute locations.

I don't understand what this does, based on this description.  Could
this please be expanded to explain this in more concrete terms?

It also seems like this is not wrapped to 72 characters, so please amend
that as well.  I think the header could be shortened by removing the
"enabled by default" part.

However, if we are talking about hiding the directory in the first line,
i.e. here:

  /home/nisse:

then I think this should better be _off_ by default.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-01 21:17         ` Stefan Kangas
@ 2024-10-02 10:55           ` Alvaro Ramirez
  2024-10-02 21:32             ` Stefan Kangas
  0 siblings, 1 reply; 17+ messages in thread
From: Alvaro Ramirez @ 2024-10-02 10:55 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 72272, eliz, Andrea Corallo

[-- Attachment #1: Type: text/plain, Size: 1252 bytes --]

Thanks for the comments Stefan!

Stefan Kangas <stefankangas@gmail.com> writes:

> Alvaro Ramirez <alvaro@xenodium.com> writes:
>
>> +** Dired
>> +
>> ++++
>> +*** New option 'dired-hide-details-hide-absolute-location', 
>> enabled by default.
>> +If non-nil, 'dired-hide-details-mode' also hides directories' 
>> absolute locations.
>
> I don't understand what this does, based on this description. 
> Could
> this please be expanded to explain this in more concrete terms?

Updated in patch. Hope that's clearer.

>
> It also seems like this is not wrapped to 72 characters, so 
> please amend
> that as well.  I think the header could be shortened by removing 
> the
> "enabled by default" part.

Ah, thanks for spotting. Updated patch.

>
> However, if we are talking about hiding the directory in the 
> first line,
> i.e. here:
>
>   /home/nisse:

Included a with/without sample in the NEWS for clarity.

>
> then I think this should better be _off_ by default.

Any chance we can consider on by default? If folks aren't enabling 
dired-hide-details-mode, then this feature is technically already 
off by default. I'm thinking for those who do use 
dired-hide-details-mode, there's possibly a likelihood they may 
want to hide this detail also.


[-- Attachment #2: 0001-Hide-default-directory-absolute-location-via-dired-h.patch --]
[-- Type: text/x-patch, Size: 8513 bytes --]

From 54b865a182e7df2862d2e691b4d15a02dd1a4c48 Mon Sep 17 00:00:00 2001
From: Álvaro Ramírez <alvaro@xenodium.com>
Date: Wed, 2 Oct 2024 11:36:57 +0100
Subject: [PATCH] Hide default-directory absolute location via
 dired-hide-details-mode

---
 etc/NEWS                 | 14 ++++++++++++
 lisp/dired.el            | 47 ++++++++++++++++++++++++++++++++--------
 test/lisp/dired-tests.el | 44 +++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index abe316547aa..c78c0922bbf 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -426,6 +426,20 @@ fontifying them, which can be slow for remote directories.  Setting
 'dired-check-symlinks' to nil disables these checks.  Defaults to t, can
 be set as a connection-local variable.
 
++++
+*** New user option 'dired-hide-details-hide-absolute-location'
+When dired's 'dired-hide-details-mode' is enabled, also hide the
+'default-directory' absolute location, typically displayed as the first
+line in a dired buffer. Enabled by default.
+
+With dired-hide-details-hide-absolute-location:
+
+  project: (100 GiB available)
+
+Without dired-hide-details-hide-absolute-location:
+
+  /absolute/path/to/my/important/project: (100 GiB available)
+
 ** Grep
 
 +++
diff --git a/lisp/dired.el b/lisp/dired.el
index 2bf5a221f4e..c5a62c1a68d 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -387,6 +387,12 @@ dired-hide-details-hide-information-lines
   :version "24.4"
   :group 'dired)
 
+(defcustom dired-hide-details-hide-absolute-location t
+  "Non-nil means `dired-hide-details-mode' hides directory absolute location."
+  :type 'boolean
+  :version "31.1"
+  :group 'dired)
+
 (defcustom dired-always-read-filesystem nil
   "Non-nil means revert buffers visiting files before searching them.
 By default,  commands like `dired-mark-files-containing-regexp' will
@@ -1816,12 +1822,20 @@ dired-insert-directory
 	  (when (and (or hdr wildcard)
 		     (not (and (looking-at "^  \\(.*\\):$")
 			       (file-name-absolute-p (match-string 1)))))
-	    ;; Note that dired-build-subdir-alist will replace the name
-	    ;; by its expansion, so it does not matter whether what we insert
-	    ;; here is fully expanded, but it should be absolute.
-	    (insert "  " (or (car-safe dir-wildcard)
-                             (directory-file-name (file-name-directory dir)))
-                    ":\n")
+            (let* ((dir-indent "  ")
+                   (dir-name (or (car-safe dir-wildcard)
+                                 (directory-file-name (file-name-directory dir))))
+                   (dir-name-point (+ (point) (length dir-indent)))
+                   (hideable-location (and dired-hide-details-hide-absolute-location
+                                           (not (string-empty-p (file-name-nondirectory dir-name))))))
+	      ;; Inserted directory name must be absolute, but keep in mind it
+              ;; may be replaced in some instances (e.g. dired-build-subdir-alist).
+              (insert dir-indent dir-name ":\n")
+              (when hideable-location
+                (put-text-property dir-name-point
+                                   (+ dir-name-point
+                                      (length (file-name-directory dir-name)))
+                                   'invisible 'dired-hide-details-absolute-location)))
 	    (setq content-point (point)))
 	  (when wildcard
 	    ;; Insert "wildcard" line where "total" line would be for a full dir.
@@ -3257,8 +3271,9 @@ dired-hide-details-mode
 When this minor mode is enabled, details such as file ownership and
 permissions are hidden from view.
 
-See options: `dired-hide-details-hide-symlink-targets' and
-`dired-hide-details-hide-information-lines'."
+See options: `dired-hide-details-hide-symlink-targets',
+`dired-hide-details-hide-information-lines' and
+`dired-hide-details-hide-absolute-location'."
   :group 'dired
   (unless (derived-mode-p '(dired-mode wdired-mode))
     (error "Not a Dired buffer"))
@@ -3282,6 +3297,11 @@ dired-hide-details-update-invisibility-spec
 	       'add-to-invisibility-spec
 	     'remove-from-invisibility-spec)
 	   'dired-hide-details-information)
+  (funcall (if (and dired-hide-details-mode
+		    dired-hide-details-hide-absolute-location)
+	       #'add-to-invisibility-spec
+	     #'remove-from-invisibility-spec)
+	   'dired-hide-details-absolute-location)
   (funcall (if (and dired-hide-details-mode
 		    dired-hide-details-hide-symlink-targets
 		    (not (derived-mode-p 'wdired-mode)))
@@ -3688,7 +3708,16 @@ dired-build-subdir-alist
 				(substring new-dir-name (match-end 0)))
 		      (expand-file-name new-dir-name))))
 	    (delete-region (point) (match-end 1))
-	    (insert new-dir-name))
+            (let ((new-dir-name-pos (point))
+                  (hideable-location (and dired-hide-details-hide-absolute-location
+                                          (not (string-empty-p
+                                                (file-name-nondirectory new-dir-name))))))
+              (insert new-dir-name)
+              (when hideable-location
+                (put-text-property new-dir-name-pos
+                                   (+ new-dir-name-pos
+                                      (length (file-name-directory new-dir-name)))
+			           'invisible 'dired-hide-details-absolute-location))))
 	  (setq count (1+ count))
 	  ;; Undo any escaping of newlines and \ by dired-insert-directory.
 	  ;; Convert "n" preceded by odd number of \ to newline, and \\ to \.
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 3b1f80d3d3d..be0a8a36d84 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -524,7 +524,50 @@ dired-test-directory-files-and-attributes
       (when (file-directory-p testdir)
         (delete-directory testdir t)))))
 
+(ert-deftest dired-test-hide-absolute-location-enabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location t)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible)))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible))))
+      (kill-buffer buffer))))
+
+(ert-deftest dired-test-hide-absolute-location-disabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location nil)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible)))
+      (kill-buffer buffer))))
+
 ;; `dired-insert-directory' output tests.
 (let* ((data-dir "insert-directory")
        (test-dir (file-name-as-directory
--
2.39.5 (Apple Git-154)


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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-02 10:55           ` Alvaro Ramirez
@ 2024-10-02 21:32             ` Stefan Kangas
  2024-10-03  8:19               ` Alvaro Ramirez
  2024-10-03 14:57               ` Visuwesh
  0 siblings, 2 replies; 17+ messages in thread
From: Stefan Kangas @ 2024-10-02 21:32 UTC (permalink / raw)
  To: Alvaro Ramirez; +Cc: 72272, eliz, Andrea Corallo

Alvaro Ramirez <alvaro@xenodium.com> writes:

> Included a with/without sample in the NEWS for clarity.

Thanks.

> Any chance we can consider on by default? If folks aren't enabling
> dired-hide-details-mode, then this feature is technically already
> off by default. I'm thinking for those who do use
> dired-hide-details-mode, there's possibly a likelihood they may
> want to hide this detail also.

I always use `dired-hide-details-mode', and I definitely would _not_
want this feature on.  It doesn't help and makes Dired much less useful
for me.  That's only one data point, of course.

But given that we're usually pretty conservative with changing the
defaults, I recommend adding this as an optional feature at first.
If it picks up in popularity, we could always reconsider later.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-02 21:32             ` Stefan Kangas
@ 2024-10-03  8:19               ` Alvaro Ramirez
  2024-10-03  8:23                 ` Alvaro Ramirez
  2024-10-03 14:57               ` Visuwesh
  1 sibling, 1 reply; 17+ messages in thread
From: Alvaro Ramirez @ 2024-10-03  8:19 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 72272, eliz, Andrea Corallo

[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]

Stefan Kangas <stefankangas@gmail.com> writes:

> Alvaro Ramirez <alvaro@xenodium.com> writes:
>
>> Included a with/without sample in the NEWS for clarity.
>
> Thanks.
>
>> Any chance we can consider on by default? If folks aren't 
>> enabling
>> dired-hide-details-mode, then this feature is technically 
>> already
>> off by default. I'm thinking for those who do use
>> dired-hide-details-mode, there's possibly a likelihood they may
>> want to hide this detail also.
>
> I always use `dired-hide-details-mode', and I definitely would 
> _not_
> want this feature on.  It doesn't help and makes Dired much less 
> useful
> for me.  That's only one data point, of course.

Ah interesting. Strangely, I haven't really missed always knowing 
the full path. If I need it, I can quickly toggle via "(" 
binding. Then again, I'm also only one data point. Maybe give the 
setting a try? Might grow on you ;)

In any case, off by default it is. Updated the patch.

>
> But given that we're usually pretty conservative with changing 
> the
> defaults, I recommend adding this as an optional feature at 
> first.
YuYup. The feature remains optional (it's got its own boolean 
setting). Off by default now.

> If it picks up in popularity, we could always reconsider later.

Sounds good. Is there an emacs-devel/maintainers preferred method 
to determine settings popularity?

Out

[-- Attachment #2: 0001-Hide-default-directory-absolute-location-via-dired-h.patch --]
[-- Type: text/x-patch, Size: 8491 bytes --]

From 24137250336e9f9c3af9c496436e1c8a69361076 Mon Sep 17 00:00:00 2001
From: Álvaro Ramírez <me@xenodium.com>
Date: Wed, 2 Oct 2024 11:36:57 +0100
Subject: [PATCH] Hide default-directory absolute location via
 dired-hide-details-mode

---
 etc/NEWS                 | 14 ++++++++++++
 lisp/dired.el            | 47 ++++++++++++++++++++++++++++++++--------
 test/lisp/dired-tests.el | 44 +++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index abe316547aa..52dd73abe02 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -426,6 +426,20 @@ fontifying them, which can be slow for remote directories.  Setting
 'dired-check-symlinks' to nil disables these checks.  Defaults to t, can
 be set as a connection-local variable.
 
++++
+*** New user option 'dired-hide-details-hide-absolute-location'
+When dired's 'dired-hide-details-mode' is enabled, also hide the
+'default-directory' absolute location, typically displayed as the first
+line in a dired buffer.
+
+With dired-hide-details-hide-absolute-location:
+
+  project: (100 GiB available)
+
+Without dired-hide-details-hide-absolute-location:
+
+  /absolute/path/to/my/important/project: (100 GiB available)
+
 ** Grep
 
 +++
diff --git a/lisp/dired.el b/lisp/dired.el
index 2bf5a221f4e..a2b1c065d0b 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -387,6 +387,12 @@ dired-hide-details-hide-information-lines
   :version "24.4"
   :group 'dired)
 
+(defcustom dired-hide-details-hide-absolute-location nil
+  "Non-nil means `dired-hide-details-mode' hides directory absolute location."
+  :type 'boolean
+  :version "31.1"
+  :group 'dired)
+
 (defcustom dired-always-read-filesystem nil
   "Non-nil means revert buffers visiting files before searching them.
 By default,  commands like `dired-mark-files-containing-regexp' will
@@ -1816,12 +1822,20 @@ dired-insert-directory
 	  (when (and (or hdr wildcard)
 		     (not (and (looking-at "^  \\(.*\\):$")
 			       (file-name-absolute-p (match-string 1)))))
-	    ;; Note that dired-build-subdir-alist will replace the name
-	    ;; by its expansion, so it does not matter whether what we insert
-	    ;; here is fully expanded, but it should be absolute.
-	    (insert "  " (or (car-safe dir-wildcard)
-                             (directory-file-name (file-name-directory dir)))
-                    ":\n")
+            (let* ((dir-indent "  ")
+                   (dir-name (or (car-safe dir-wildcard)
+                                 (directory-file-name (file-name-directory dir))))
+                   (dir-name-point (+ (point) (length dir-indent)))
+                   (hideable-location (and dired-hide-details-hide-absolute-location
+                                           (not (string-empty-p (file-name-nondirectory dir-name))))))
+	      ;; Inserted directory name must be absolute, but keep in mind it
+              ;; may be replaced in some instances (e.g. dired-build-subdir-alist).
+              (insert dir-indent dir-name ":\n")
+              (when hideable-location
+                (put-text-property dir-name-point
+                                   (+ dir-name-point
+                                      (length (file-name-directory dir-name)))
+                                   'invisible 'dired-hide-details-absolute-location)))
 	    (setq content-point (point)))
 	  (when wildcard
 	    ;; Insert "wildcard" line where "total" line would be for a full dir.
@@ -3257,8 +3271,9 @@ dired-hide-details-mode
 When this minor mode is enabled, details such as file ownership and
 permissions are hidden from view.
 
-See options: `dired-hide-details-hide-symlink-targets' and
-`dired-hide-details-hide-information-lines'."
+See options: `dired-hide-details-hide-symlink-targets',
+`dired-hide-details-hide-information-lines' and
+`dired-hide-details-hide-absolute-location'."
   :group 'dired
   (unless (derived-mode-p '(dired-mode wdired-mode))
     (error "Not a Dired buffer"))
@@ -3282,6 +3297,11 @@ dired-hide-details-update-invisibility-spec
 	       'add-to-invisibility-spec
 	     'remove-from-invisibility-spec)
 	   'dired-hide-details-information)
+  (funcall (if (and dired-hide-details-mode
+		    dired-hide-details-hide-absolute-location)
+	       #'add-to-invisibility-spec
+	     #'remove-from-invisibility-spec)
+	   'dired-hide-details-absolute-location)
   (funcall (if (and dired-hide-details-mode
 		    dired-hide-details-hide-symlink-targets
 		    (not (derived-mode-p 'wdired-mode)))
@@ -3688,7 +3708,16 @@ dired-build-subdir-alist
 				(substring new-dir-name (match-end 0)))
 		      (expand-file-name new-dir-name))))
 	    (delete-region (point) (match-end 1))
-	    (insert new-dir-name))
+            (let ((new-dir-name-pos (point))
+                  (hideable-location (and dired-hide-details-hide-absolute-location
+                                          (not (string-empty-p
+                                                (file-name-nondirectory new-dir-name))))))
+              (insert new-dir-name)
+              (when hideable-location
+                (put-text-property new-dir-name-pos
+                                   (+ new-dir-name-pos
+                                      (length (file-name-directory new-dir-name)))
+			           'invisible 'dired-hide-details-absolute-location))))
 	  (setq count (1+ count))
 	  ;; Undo any escaping of newlines and \ by dired-insert-directory.
 	  ;; Convert "n" preceded by odd number of \ to newline, and \\ to \.
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 3b1f80d3d3d..be0a8a36d84 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -524,7 +524,50 @@ dired-test-directory-files-and-attributes
       (when (file-directory-p testdir)
         (delete-directory testdir t)))))
 
+(ert-deftest dired-test-hide-absolute-location-enabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location t)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible)))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible))))
+      (kill-buffer buffer))))
+
+(ert-deftest dired-test-hide-absolute-location-disabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location nil)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible)))
+      (kill-buffer buffer))))
+
 ;; `dired-insert-directory' output tests.
 (let* ((data-dir "insert-directory")
        (test-dir (file-name-as-directory
--
2.39.5 (Apple Git-154)


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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-03  8:19               ` Alvaro Ramirez
@ 2024-10-03  8:23                 ` Alvaro Ramirez
  0 siblings, 0 replies; 17+ messages in thread
From: Alvaro Ramirez @ 2024-10-03  8:23 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 72272, eliz, Andrea Corallo

Alvaro Ramirez <alvaro@xenodium.com> writes:

> YuYup
> Out

Sorry. Typos :/





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-02 21:32             ` Stefan Kangas
  2024-10-03  8:19               ` Alvaro Ramirez
@ 2024-10-03 14:57               ` Visuwesh
  2024-10-03 17:37                 ` Alvaro Ramirez
  1 sibling, 1 reply; 17+ messages in thread
From: Visuwesh @ 2024-10-03 14:57 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Andrea Corallo, Alvaro Ramirez, 72272, eliz

[புதன் அக்டோபர் 02, 2024] Stefan Kangas wrote:

> Alvaro Ramirez <alvaro@xenodium.com> writes:
>
>> Included a with/without sample in the NEWS for clarity.
>
> Thanks.
>
>> Any chance we can consider on by default? If folks aren't enabling
>> dired-hide-details-mode, then this feature is technically already
>> off by default. I'm thinking for those who do use
>> dired-hide-details-mode, there's possibly a likelihood they may
>> want to hide this detail also.
>
> I always use `dired-hide-details-mode', and I definitely would _not_
> want this feature on.  It doesn't help and makes Dired much less useful
> for me.  That's only one data point, of course.

If the full filename is hidden, then one cannot easily go to the parent
directory by clicking on the filename component.  This is a rather
useful feature when one is already using the mouse.

To add on to your data point, I have many similarly named directories in
different parents.  Just looking at the uniquifier inside the <> of the
buffer's name does not help since I cannot immediately recognise the
parent directory from it.

> But given that we're usually pretty conservative with changing the
> defaults, I recommend adding this as an optional feature at first.
> If it picks up in popularity, we could always reconsider later.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-03 14:57               ` Visuwesh
@ 2024-10-03 17:37                 ` Alvaro Ramirez
  2024-10-09 17:31                   ` Alvaro Ramirez
  0 siblings, 1 reply; 17+ messages in thread
From: Alvaro Ramirez @ 2024-10-03 17:37 UTC (permalink / raw)
  To: Visuwesh; +Cc: Andrea Corallo, eliz, 72272, Stefan Kangas


> On 3 Oct 2024, at 15:57, Visuwesh <visuweshm@gmail.com> wrote:
> 
> [புதன் அக்டோபர் 02, 2024] Stefan Kangas wrote:
> 
>> Alvaro Ramirez <alvaro@xenodium.com> writes:
>> 
>>> Included a with/without sample in the NEWS for clarity.
>> 
>> Thanks.
>> 
>>> Any chance we can consider on by default? If folks aren't enabling
>>> dired-hide-details-mode, then this feature is technically already
>>> off by default. I'm thinking for those who do use
>>> dired-hide-details-mode, there's possibly a likelihood they may
>>> want to hide this detail also.
>> 
>> I always use `dired-hide-details-mode', and I definitely would _not_
>> want this feature on.  It doesn't help and makes Dired much less useful
>> for me.  That's only one data point, of course.
> 
> If the full filename is hidden, then one cannot easily go to the parent
> directory by clicking on the filename component.  This is a rather
> useful feature when one is already using the mouse.

Neat. TIL about this mouse flow. Thanks! I typically C-x C-f to visit parents.

> To add on to your data point, I have many similarly named directories in
> different parents.  Just looking at the uniquifier inside the <> of the
> buffer's name does not help since I cannot immediately recognise the
> parent directory from it.

Your use cases are safe. The feature is setting-guarded, and now off by default. In the event you do enable it, toggling dired-hide-details-mode via “(“ binding can quickly expose the current location’s absolute path.

>> But given that we're usually pretty conservative with changing the
>> defaults, I recommend adding this as an optional feature at first.
>> If it picks up in popularity, we could always reconsider later.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-03 17:37                 ` Alvaro Ramirez
@ 2024-10-09 17:31                   ` Alvaro Ramirez
  2024-10-12 11:33                     ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Alvaro Ramirez @ 2024-10-09 17:31 UTC (permalink / raw)
  To: Stefan Kangas, eliz; +Cc: Andrea Corallo, 72272, Visuwesh

Hi Eli / Stefan

With the latest patch disabling the feature by default, is it good to apply?

Cheers,

Alvaro 

> 
> On 3 Oct 2024, at 18:37, Alvaro Ramirez <alvaro@xenodium.com> wrote:
> 
> 
>>> On 3 Oct 2024, at 15:57, Visuwesh <visuweshm@gmail.com> wrote:
>>> 
>>> [புதன் அக்டோபர் 02, 2024] Stefan Kangas wrote:
>>> 
>>> Alvaro Ramirez <alvaro@xenodium.com> writes:
>>> 
>>>> Included a with/without sample in the NEWS for clarity.
>>> 
>>> Thanks.
>>> 
>>>> Any chance we can consider on by default? If folks aren't enabling
>>>> dired-hide-details-mode, then this feature is technically already
>>>> off by default. I'm thinking for those who do use
>>>> dired-hide-details-mode, there's possibly a likelihood they may
>>>> want to hide this detail also.
>>> 
>>> I always use `dired-hide-details-mode', and I definitely would _not_
>>> want this feature on.  It doesn't help and makes Dired much less useful
>>> for me.  That's only one data point, of course.
>> 
>> If the full filename is hidden, then one cannot easily go to the parent
>> directory by clicking on the filename component.  This is a rather
>> useful feature when one is already using the mouse.
> 
> Neat. TIL about this mouse flow. Thanks! I typically C-x C-f to visit parents.
> 
>> To add on to your data point, I have many similarly named directories in
>> different parents.  Just looking at the uniquifier inside the <> of the
>> buffer's name does not help since I cannot immediately recognise the
>> parent directory from it.
> 
> Your use cases are safe. The feature is setting-guarded, and now off by default. In the event you do enable it, toggling dired-hide-details-mode via “(“ binding can quickly expose the current location’s absolute path.
> 
>>> But given that we're usually pretty conservative with changing the
>>> defaults, I recommend adding this as an optional feature at first.
>>> If it picks up in popularity, we could always reconsider later.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-09 17:31                   ` Alvaro Ramirez
@ 2024-10-12 11:33                     ` Eli Zaretskii
  2024-10-12 18:27                       ` Alvaro Ramirez
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-10-12 11:33 UTC (permalink / raw)
  To: Alvaro Ramirez; +Cc: acorallo, 72272, stefankangas, visuweshm

> From: Alvaro Ramirez <alvaro@xenodium.com>
> Date: Wed, 9 Oct 2024 18:31:35 +0100
> Cc: 72272@debbugs.gnu.org, Andrea Corallo <acorallo@gnu.org>,
>  Visuwesh <visuweshm@gmail.com>
> 
> Hi Eli / Stefan
> 
> With the latest patch disabling the feature by default, is it good to apply?

It is good, but it no longer applies.  Would you please rebase it on
the latest master branch and resubmit?

Also, please fix the following minor nits while you are at it:

> ++++
> +*** New user option 'dired-hide-details-hide-absolute-location'

The heading lines in NEWS should end in a period.

Also, since this new variable is not documented in the manual, the
entry should be marked as "---", not "+++".

> +            (let* ((dir-indent "  ")
> +                   (dir-name (or (car-safe dir-wildcard)
> +                                 (directory-file-name (file-name-directory dir))))
> +                   (dir-name-point (+ (point) (length dir-indent)))
> +                   (hideable-location (and dired-hide-details-hide-absolute-location
> +                                           (not (string-empty-p (file-name-nondirectory dir-name))))))
> +	      ;; Inserted directory name must be absolute, but keep in mind it
> +              ;; may be replaced in some instances (e.g. dired-build-subdir-alist).
> +              (insert dir-indent dir-name ":\n")
> +              (when hideable-location
> +                (put-text-property dir-name-point
> +                                   (+ dir-name-point
> +                                      (length (file-name-directory dir-name)))
> +                                   'invisible 'dired-hide-details-absolute-location)))

Here (and elsewhere in the patch) please break too-long lines into
two.

Thanks.





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

* bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path
  2024-10-12 11:33                     ` Eli Zaretskii
@ 2024-10-12 18:27                       ` Alvaro Ramirez
  0 siblings, 0 replies; 17+ messages in thread
From: Alvaro Ramirez @ 2024-10-12 18:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: acorallo, 72272, stefankangas, visuweshm

[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]

Thanks for the comments Eli.

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alvaro Ramirez <alvaro@xenodium.com>
>> Date: Wed, 9 Oct 2024 18:31:35 +0100
>> Cc: 72272@debbugs.gnu.org, Andrea Corallo <acorallo@gnu.org>,
>>  Visuwesh <visuweshm@gmail.com>
>> 
>> Hi Eli / Stefan
>> 
>> With the latest patch disabling the feature by default, is it 
>> good to apply?
>
> It is good, but it no longer applies.  Would you please rebase 
> it on
> the latest master branch and resubmit?

Yup. Rebased. See latest patch attached.

>
> Also, please fix the following minor nits while you are at it:
>
>> ++++
>> +*** New user option 
>> 'dired-hide-details-hide-absolute-location'
>
> The heading lines in NEWS should end in a period.
>
> Also, since this new variable is not documented in the manual, 
> the
> entry should be marked as "---", not "+++".

Thanks. Did not know this.

>> +            (let* ((dir-indent "  ")
>> +                   (dir-name (or (car-safe dir-wildcard)
>> +                                 (directory-file-name 
>> (file-name-directory dir))))
>> +                   (dir-name-point (+ (point) (length 
>> dir-indent)))
>> +                   (hideable-location (and 
>> dired-hide-details-hide-absolute-location
>> +                                           (not 
>> (string-empty-p (file-name-nondirectory dir-name))))))
>> +	      ;; Inserted directory name must be absolute, but 
>> keep in mind it
>> +              ;; may be replaced in some instances 
>> (e.g. dired-build-subdir-alist).
>> +              (insert dir-indent dir-name ":\n")
>> +              (when hideable-location
>> +                (put-text-property dir-name-point
>> +                                   (+ dir-name-point
>> +                                      (length 
>> (file-name-directory dir-name)))
>> +                                   'invisible 
>> 'dired-hide-details-absolute-location)))
>
> Here (and elsewhere in the patch) please break too-long lines 
> into
> two.

Used 80 character limit. Happy to use a different limit if needed.

>
> Thanks.

[-- Attachment #2: 0001-Hide-default-directory-absolute-location-via-dired-h.patch --]
[-- Type: text/x-patch, Size: 8642 bytes --]

From 0ed4df0ae090a96bc40f19a15e4d62be58900d3b Mon Sep 17 00:00:00 2001
From: Álvaro Ramírez <me@xenodium.com>
Date: Wed, 2 Oct 2024 11:36:57 +0100
Subject: [PATCH] Hide default-directory absolute location via
 dired-hide-details-mode

---
 etc/NEWS                 | 14 +++++++++++
 lisp/dired.el            | 54 +++++++++++++++++++++++++++++++++-------
 test/lisp/dired-tests.el | 46 ++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index daaae54d7d3..3ae46b45e7e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -490,6 +490,20 @@ fontifying them, which can be slow for remote directories.  Setting
 'dired-check-symlinks' to nil disables these checks.  Defaults to t, can
 be set as a connection-local variable.
 
+---
+*** New user option 'dired-hide-details-hide-absolute-location'.
+When dired's 'dired-hide-details-mode' is enabled, also hide the
+'default-directory' absolute location, typically displayed as the first
+line in a dired buffer.
+
+With dired-hide-details-hide-absolute-location:
+
+  project: (100 GiB available)
+
+Without dired-hide-details-hide-absolute-location:
+
+  /absolute/path/to/my/important/project: (100 GiB available)
+
 ** Grep
 
 +++
diff --git a/lisp/dired.el b/lisp/dired.el
index 2bf5a221f4e..625de019d3b 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -387,6 +387,12 @@ dired-hide-details-hide-information-lines
   :version "24.4"
   :group 'dired)
 
+(defcustom dired-hide-details-hide-absolute-location nil
+  "Non-nil means `dired-hide-details-mode' hides directory absolute location."
+  :type 'boolean
+  :version "31.1"
+  :group 'dired)
+
 (defcustom dired-always-read-filesystem nil
   "Non-nil means revert buffers visiting files before searching them.
 By default,  commands like `dired-mark-files-containing-regexp' will
@@ -1816,12 +1822,25 @@ dired-insert-directory
 	  (when (and (or hdr wildcard)
 		     (not (and (looking-at "^  \\(.*\\):$")
 			       (file-name-absolute-p (match-string 1)))))
-	    ;; Note that dired-build-subdir-alist will replace the name
-	    ;; by its expansion, so it does not matter whether what we insert
-	    ;; here is fully expanded, but it should be absolute.
-	    (insert "  " (or (car-safe dir-wildcard)
-                             (directory-file-name (file-name-directory dir)))
-                    ":\n")
+            (let* ((dir-indent "  ")
+                   (dir-name (or (car-safe dir-wildcard)
+                                 (directory-file-name
+                                  (file-name-directory dir))))
+                   (dir-name-point (+ (point) (length dir-indent)))
+                   (hideable-location
+                    (and dired-hide-details-hide-absolute-location
+                         (not (string-empty-p (file-name-nondirectory
+                                               dir-name))))))
+	      ;; Inserted directory name must be absolute, but keep in
+              ;; mind it may be replaced in some instances like in
+              ;; `dired-build-subdir-alist'.
+              (insert dir-indent dir-name ":\n")
+              (when hideable-location
+                (put-text-property
+                 dir-name-point
+                 (+ dir-name-point
+                    (length (file-name-directory dir-name)))
+                 'invisible 'dired-hide-details-absolute-location)))
 	    (setq content-point (point)))
 	  (when wildcard
 	    ;; Insert "wildcard" line where "total" line would be for a full dir.
@@ -3257,8 +3276,9 @@ dired-hide-details-mode
 When this minor mode is enabled, details such as file ownership and
 permissions are hidden from view.
 
-See options: `dired-hide-details-hide-symlink-targets' and
-`dired-hide-details-hide-information-lines'."
+See options: `dired-hide-details-hide-symlink-targets',
+`dired-hide-details-hide-information-lines' and
+`dired-hide-details-hide-absolute-location'."
   :group 'dired
   (unless (derived-mode-p '(dired-mode wdired-mode))
     (error "Not a Dired buffer"))
@@ -3282,6 +3302,11 @@ dired-hide-details-update-invisibility-spec
 	       'add-to-invisibility-spec
 	     'remove-from-invisibility-spec)
 	   'dired-hide-details-information)
+  (funcall (if (and dired-hide-details-mode
+		    dired-hide-details-hide-absolute-location)
+	       #'add-to-invisibility-spec
+	     #'remove-from-invisibility-spec)
+	   'dired-hide-details-absolute-location)
   (funcall (if (and dired-hide-details-mode
 		    dired-hide-details-hide-symlink-targets
 		    (not (derived-mode-p 'wdired-mode)))
@@ -3688,7 +3713,18 @@ dired-build-subdir-alist
 				(substring new-dir-name (match-end 0)))
 		      (expand-file-name new-dir-name))))
 	    (delete-region (point) (match-end 1))
-	    (insert new-dir-name))
+            (let ((new-dir-name-pos (point))
+                  (hideable-location
+                   (and dired-hide-details-hide-absolute-location
+                        (not (string-empty-p
+                              (file-name-nondirectory new-dir-name))))))
+              (insert new-dir-name)
+              (when hideable-location
+                (put-text-property
+                 new-dir-name-pos
+                 (+ new-dir-name-pos
+                    (length (file-name-directory new-dir-name)))
+		 'invisible 'dired-hide-details-absolute-location))))
 	  (setq count (1+ count))
 	  ;; Undo any escaping of newlines and \ by dired-insert-directory.
 	  ;; Convert "n" preceded by odd number of \ to newline, and \\ to \.
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 3b1f80d3d3d..5a9ba14b402 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -524,6 +524,52 @@ dired-test-directory-files-and-attributes
       (when (file-directory-p testdir)
         (delete-directory testdir t)))))
 
+(ert-deftest dired-test-hide-absolute-location-enabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location t)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory
+                                                          "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible)))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should (equal 'dired-hide-details-absolute-location
+                         (get-text-property (match-beginning 1) 'invisible))))
+      (kill-buffer buffer))))
+
+(ert-deftest dired-test-hide-absolute-location-disabled ()
+  "Test for https://debbugs.gnu.org/72272 ."
+  (let* ((dired-hide-details-hide-absolute-location nil)
+         (dir-name (expand-file-name "lisp" source-directory))
+         (buffer (prog1 (dired (list dir-name "dired.el" "play"))
+                   (dired-insert-subdir (file-name-concat default-directory
+                                                          "play")))))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "lisp" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible))
+          (re-search-forward dired-subdir-regexp)
+          (goto-char (match-beginning 1))
+          (should (equal "play" (file-name-nondirectory
+                                 (directory-file-name (dired-get-subdir)))))
+          (should-not (get-text-property (match-beginning 1) 'invisible)))
+      (kill-buffer buffer))))
+
 ;; `dired-insert-directory' output tests.
 (let* ((data-dir "insert-directory")
        (test-dir (file-name-as-directory
--
2.39.5 (Apple Git-154)


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

end of thread, other threads:[~2024-10-12 18:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24 11:17 bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path Alvaro Ramirez
2024-08-04  8:06 ` Eli Zaretskii
2024-08-05  9:45   ` Andrea Corallo
     [not found]     ` <d75b2eb4e45413d468c15f4d6e8c3d0ce568d28ddbf7a828a4f917f29e54cbcb@mu.id>
2024-08-05 14:34       ` Alvaro Ramirez
2024-08-17  8:53         ` Eli Zaretskii
2024-08-17  9:27           ` Alvaro Ramirez
2024-10-01 20:31             ` Alvaro Ramirez
2024-10-01 21:17         ` Stefan Kangas
2024-10-02 10:55           ` Alvaro Ramirez
2024-10-02 21:32             ` Stefan Kangas
2024-10-03  8:19               ` Alvaro Ramirez
2024-10-03  8:23                 ` Alvaro Ramirez
2024-10-03 14:57               ` Visuwesh
2024-10-03 17:37                 ` Alvaro Ramirez
2024-10-09 17:31                   ` Alvaro Ramirez
2024-10-12 11:33                     ` Eli Zaretskii
2024-10-12 18:27                       ` Alvaro Ramirez

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