emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dired, toggle ls flags? [elisp]


From: Emanuel Berg
Subject: Re: dired, toggle ls flags? [elisp]
Date: Mon, 29 Apr 2024 01:25:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Heerdegen wrote:

>> How can I hit a key, say h, to toggle the -h flag for ls
>> in dired?
>>
>> Answer, like this!
>>
>> But question, is there already a better way to do it?
>
> IIUC, the intended way of changing any flags is C-u s.
> Is this good enough?

It is the general case, which one should always have.
The specific case, which you do often, you want faster than
that, often.

However this is actually a nontrivial thing to do for the
arbitrary specific case, since, well, take a look at my
initial configuration

(setq dired-listing-switches
  "-A -G -h -l -X --group-directories-first --time-style=long-iso -I \"*.meta\" 
-I \"#*#\" -I \"*.elc\"")

And it can actually get even worse, as those initial options
can be expressed -AGhlX as well!

So to toggle in general some arbitrary option or option
argument, one would have to parse all those cases: short
options with and without arguments, and the same for long
options, and then grouped short options as well.

So it is a lot of work for a small gain, agreed.

> We don't have a toggle for all flags.

We don't have toggle at all, right? But you can set it
explicitely to whatever you want using what is already there,
which should be fast enough.

If one wants to toggle, well, I'll use my poor man's solution
for the time being at least all tho it would be interesting to
do this so it would work for the entire ls(1) option and
argument syntax and also in an elegant lispy way. Because not
only ls use that syntax as you know, but a lot of other GNU
tools - maybe one can convince oneself it
isn't overengineering?

Also, maybe some other part of Emacs maybe has this kind of
GNU CLI parser already?

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]