From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: dired, toggle ls flags? [elisp]
Date: Sun, 28 Apr 2024 06:06:48 +0200 [thread overview]
Message-ID: <87cyqab06f.fsf@dataswamp.org> (raw)
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?
Or, if you can improve what I wrote?
If there isn't such a way in core Emacs, I think such
a feature should be added to Emacs since it is really handy.
(defun dired-ls-toggle (opt)
(let ((opt-re (format "\\(^\\|[[:blank:]]\\)%s\\([[:blank:]]\\|\\b\\)" opt)))
(if (string-match-p opt-re dired-listing-switches)
(setq dired-listing-switches
(replace-regexp-in-string opt-re " " dired-listing-switches) )
(setq dired-listing-switches (format "%s %s" dired-listing-switches opt)))
(setq dired-listing-switches (string-clean-whitespace dired-listing-switches))
(dired-sort-other dired-listing-switches) ))
(defun dired-toggle-human ()
(interactive)
(dired-ls-toggle "-h") )
(defun dired-toggle-modification-sort ()
(interactive)
(dired-ls-toggle "-t") )
--
underground experts united
https://dataswamp.org/~incal
next reply other threads:[~2024-04-28 4:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 4:06 Emanuel Berg [this message]
2024-04-28 7:05 ` dired, toggle ls flags? [elisp] Emanuel Berg
2024-04-28 9:16 ` Michael Heerdegen via Emacs development discussions.
2024-04-28 23:25 ` Emanuel Berg
2024-04-29 6:17 ` Yuri Khan
2024-04-29 11:27 ` Emanuel Berg
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=87cyqab06f.fsf@dataswamp.org \
--to=incal@dataswamp.org \
--cc=emacs-devel@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.