all messages for Emacs-related lists mirrored at yhetil.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

* bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-03-02 12:04 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 61785-done

> From: Augusto Stoffel <arstoffel@gmail.com>
> Date: Sat, 25 Feb 2023 12:30:14 +0100
> 
> 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.

Thanks, installed on the master branch.  Feel free to post further
enhancements if you think they will be useful.





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

* bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode
  2023-03-02 12:04 ` Eli Zaretskii
@ 2023-03-04  6:07   ` Augusto Stoffel
  2023-03-04  7:54     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Augusto Stoffel @ 2023-03-04  6:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61785-done

On Thu,  2 Mar 2023 at 14:04, Eli Zaretskii wrote:

> Thanks, installed on the master branch.  Feel free to post further
> enhancements if you think they will be useful.

I was having second thoughts about this idea 😬.  The feature is useful
but difficult to implement right.

The problem is that some columns of 'ls -l' are left aligned, so it's
impossible to know where a column starts or ends by looking at an
individual line.

I think I would rather revert the commit until someone comes up with a
better idea, if you don't mind.  The ideal would be if 'ls --dired'
would report the names and positions of the columns.





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

* bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode
  2023-03-04  6:07   ` Augusto Stoffel
@ 2023-03-04  7:54     ` Eli Zaretskii
  2023-03-04 11:26       ` Augusto Stoffel
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-03-04  7:54 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 61785-done

> From: Augusto Stoffel <arstoffel@gmail.com>
> Cc: 61785-done@debbugs.gnu.org
> Date: Sat, 04 Mar 2023 07:07:02 +0100
> 
> I think I would rather revert the commit until someone comes up with a
> better idea, if you don't mind.

I'm not sure I see a problem with counting columns.

What is the harm of keeping the commit on master?  If we get
complaints about it, we have ample time to remove the feature when and
if we get those complaints.





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

* bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode
  2023-03-04  7:54     ` Eli Zaretskii
@ 2023-03-04 11:26       ` Augusto Stoffel
  2023-03-04 12:35         ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Augusto Stoffel @ 2023-03-04 11:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61785-done

On Sat,  4 Mar 2023 at 09:54, Eli Zaretskii wrote:

>> From: Augusto Stoffel <arstoffel@gmail.com>
>> Cc: 61785-done@debbugs.gnu.org
>> Date: Sat, 04 Mar 2023 07:07:02 +0100
>> 
>> I think I would rather revert the commit until someone comes up with a
>> better idea, if you don't mind.
>
> I'm not sure I see a problem with counting columns.
>
> What is the harm of keeping the commit on master?  If we get
> complaints about it, we have ample time to remove the feature when and
> if we get those complaints.

The problem is that the code asssumes the columns are right-aligned,
which is not true for user and group.  So for instance this listing:

  drwx------.  43 augusto augusto    69632 Mar  4 12:21 .
  drwxr-xr-x.   4 root    root        4096 Aug  9  2022 ..
  drwx------. 171 augusto augusto    12288 Feb 27 11:52 .cache

will get abridged like this:

      69632 Mar  4 12:21 .
          4096 Aug  9  2022 ..
      12288 Feb 27 11:52 .cache

But if you don't mind that, we can keep the code and see if someone
finds a nice way to deal with it.





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

* bug#61785: [PATCH] Add option to keep some columns in dired-hide-details-mode
  2023-03-04 11:26       ` Augusto Stoffel
@ 2023-03-04 12:35         ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2023-03-04 12:35 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 61785-done

> From: Augusto Stoffel <arstoffel@gmail.com>
> Cc: 61785-done@debbugs.gnu.org
> Date: Sat, 04 Mar 2023 12:26:36 +0100
> 
> On Sat,  4 Mar 2023 at 09:54, Eli Zaretskii wrote:
> 
> >> From: Augusto Stoffel <arstoffel@gmail.com>
> >> Cc: 61785-done@debbugs.gnu.org
> >> Date: Sat, 04 Mar 2023 07:07:02 +0100
> >> 
> >> I think I would rather revert the commit until someone comes up with a
> >> better idea, if you don't mind.
> >
> > I'm not sure I see a problem with counting columns.
> >
> > What is the harm of keeping the commit on master?  If we get
> > complaints about it, we have ample time to remove the feature when and
> > if we get those complaints.
> 
> The problem is that the code asssumes the columns are right-aligned,
> which is not true for user and group.  So for instance this listing:
> 
>   drwx------.  43 augusto augusto    69632 Mar  4 12:21 .
>   drwxr-xr-x.   4 root    root        4096 Aug  9  2022 ..
>   drwx------. 171 augusto augusto    12288 Feb 27 11:52 .cache
> 
> will get abridged like this:
> 
>       69632 Mar  4 12:21 .
>           4096 Aug  9  2022 ..
>       12288 Feb 27 11:52 .cache
> 
> But if you don't mind that, we can keep the code and see if someone
> finds a nice way to deal with it.

We could perhaps mention the caveat with right-aligned columns to the
doc string, and expect users to avoid those columns?





^ permalink raw reply	[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 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.