Subject: bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline

From: Drew Adams <[email-masked]>
Date: Fri, 15 May 2020 15:19:03 -0700 (PDT)

> I have just one question/suggestion:

(Actually, it seems like several. ;-)

> You first choice: indicate by name or date, else full. Does it really
> need to be there? 

Not sure I understand.  Define "need".

I kept the longstanding behavior, by default (option
value nil).  If you customize then you override that
default behavior.  If you don't customize then nothing
changes for you (good).

> ls-switches are displayed only when dired is not
> sorted by name or date, i.e. custom

My intention is to let a user impose showing switches
even in the case where name or date regexp matches.
And to let a user instead prefer "by name" and "by
date" when they match, but default to showing all
(as now).

> Thus this customization only touches displaying of
> switches when they are displayd. I.e. it should be
> about "how", not "when".

Sorry, I don't follow.  Please say what behavior
you want to be able to specify that the proposed
code doesn't provide for.

> To explain my thought: that is a hard-coded behaviour which user can't
> customize anway. 

What is "this"?  Please give an example of the
behavior you'd like that you don't think you
can get, or that you think is too difficult to
get.

> By looking at your code, that bevahviour indeed
> persists.

If you mean that the longstanding behavior is
still possible, and is even the default, yes.
If you mean something else, please rephrase.

> 2nd choice is the one that actually
> consider how switches will be displayed.

By "2nd choice" I guess you mean showing the
full switches?  Or do you mean truncating that?

> I have same consideration about 3rd choice too.
> Function choice

(That's the 4th choice.)

> gives option to run custom hook as format. I think it is cool to have custom
> format function to display when in dired mode, so I like it, but it is
> a bit different purpose then regulating display of switches.

What do you mean?  The switches string is passed
as an arg to the function, which can return
anything.  It can format and return any part of
that string, or transform it in any way, or
return something descriptive (a la "by name"),
or return something completely unrelated (your
birthday, "Hello world!").

> Maybe it should get it's own custom variable instead? Like
> dired-mode-line-display-hook or something similar?

Why?  Then you're essentially back to the idea
of having _only_ a function.

> 2nd option, one with number 

(That's the 3rd choice.)

> does what the proposed variable name suggests.

The name just suggests something in the mode-line
that's based on switches.

> Personally I ment to code just short (first switch)

(That's name/date.)

> and long (all switches), since probably the first
> one is the most important one.

Sorry, but I'm lost in your reference to first,
second, etc.

It sounds now like you're not interested in a
truncation choice (?).  I thought it was you who
requested that.

> I would also prefer nil to mean don't show switches at all, but it
> works with N chars set to 0 as well I guess.

A value of 0 shows nothing.  And so does a value
of (lambda (x) "").

> Observe also that if I turn off display by using 0 chars as suggested
> there will be a small gap between word "Dired" and closing parenthesis.
> It will look like: (Dired ) on modeline. Not a deal breaker, but kind
> of small artefact. Easily fixed though. I can rework it if you wish,
> but since it is yours, you might prefer to do it yourself.

Attached patch takes care of that, and adds ellipsis.