Subject: bug#72272: [PATCH] dired-hide-details-mode hides directory's absolute path

From: Alvaro Ramirez <[email-masked]>
Date: Wed, 24 Jul 2024 12:17:58 +0100

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'

>From 6f79b6baa00f7087c81b48ef136590634efa059d Mon Sep 17 00:00:00 2001
From: xenodium <[email-masked]>
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)