unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode
@ 2023-02-25 11:30 Augusto Stoffel
  2023-03-02 12:04 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Augusto Stoffel @ 2023-02-25 11:30 UTC (permalink / raw)
  To: 61785

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

Tags: patch

I find the normal dired buffer a bit too busy but
dired-hide-details-mode a bit too lacking.  So I'd like show only the
details I care most about, for instance like this:

--8<---------------cut here---------------start------------->8---
  /home/augusto/emacs:
  4.0K Feb 25 .
  4.0K Feb 20 ..
  4.0K Feb 25 admin
  4.0K Feb 20 autom4te.cache
  4.0K Feb 25 build-aux
  3.6K Feb 20 aclocal.m4
   11K Feb 25 autogen.sh
   932 Jun  6 BUGS
  ...
--8<---------------cut here---------------end--------------->8---

The above can be obtained by setting

  (setq dired-hide-details-preserved-columns '(5 6 7))

After writing this, I realized one could easily modify the new user
option to be an alist mapping column numbers to arbitrary text
properties to be applied to that column.  If anyone thinks this variant
is useful, I'd be happy to adapt the patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-option-to-keep-some-columns-in-dired-hide-detail.patch --]
[-- Type: text/patch, Size: 1814 bytes --]

From 58ed1d179e4b9a66f21a3507787033bd94d7107d Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Sat, 25 Feb 2023 12:15:43 +0100
Subject: [PATCH] Add option to keep some columns in dired-hide-details-mode

* lisp/dired.el (dired-hide-details-preserved-columns): New user
option.
(dired-insert-set-properties): Use it.
---
 lisp/dired.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 2bcb28a0e00..7a9076ecb49 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -490,6 +490,11 @@ dired-guess-shell-znew-switches
                  (string :tag "Switches"))
   :version "29.1")
 
+(defcustom dired-hide-details-preserved-columns nil
+  "List of columns which are not hidden in `dired-hide-details-mode'."
+  :type '(repeat integer)
+  :version "30.1")
+
 \f
 ;;; Internal variables
 
@@ -1880,8 +1885,15 @@ dired-insert-set-properties
 	      (put-text-property (line-beginning-position)
 				 (1+ (line-end-position))
 				 'invisible 'dired-hide-details-information))
-	  (put-text-property (+ (line-beginning-position) 1) (1- (point))
-			     'invisible 'dired-hide-details-detail)
+	  (save-excursion
+            (let ((end (1- (point)))
+                  (opoint (goto-char (1+ (pos-bol))))
+                  (i 0))
+              (put-text-property opoint end 'invisible 'dired-hide-details-detail)
+              (while (re-search-forward "[^ ]+" end t)
+                (when (member (cl-incf i) dired-hide-details-preserved-columns)
+                  (put-text-property opoint (point) 'invisible nil))
+                (setq opoint (point)))))
           (when (and dired-mouse-drag-files (fboundp 'x-begin-drag))
             (put-text-property (point)
 	                       (save-excursion
-- 
2.39.2


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

end of thread, other threads:[~2023-03-04 12:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-25 11:30 bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode Augusto Stoffel
2023-03-02 12:04 ` Eli Zaretskii
2023-03-04  6:07   ` Augusto Stoffel
2023-03-04  7:54     ` Eli Zaretskii
2023-03-04 11:26       ` Augusto Stoffel
2023-03-04 12:35         ` Eli Zaretskii

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