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