all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: 61785@debbugs.gnu.org
Subject: bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode
Date: Sat, 25 Feb 2023 12:30:14 +0100	[thread overview]
Message-ID: <87sfeu3ruh.fsf@gmail.com> (raw)

[-- 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


             reply	other threads:[~2023-02-25 11:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-25 11:30 Augusto Stoffel [this message]
2023-03-02 12:04 ` bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfeu3ruh.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=61785@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.