[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Dired - ls-switches on Modeline
From: |
Arthur Miller |
Subject: |
Dired - ls-switches on Modeline |
Date: |
Wed, 13 May 2020 11:10:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
I use dired a lot, and I like to have two vertical windows to work with.
I try keep all my files 80 character wide lines. What I found a little
annoying is that dired automatically displays ls-switches on modeline.
If one has long switches line, like this one:
"-lA --si --time-style long-iso --group-directories-first"
then everything on modeline gets pushed far to the right. I haven't
found any way to turn this behavour off. The code responsible for this
is in dired.el, a function named "dired-sort-set-mode-line". There is a
condition always set to execute (t ...). Since it always call
"force-mode-line-update" after it adds ls-switches to dired, I don't
think it is even possible to advice it. The ony way for me was to hack
said function, and re-define it in my init file (I just added a variable
and change condition to check for it):
;; Prevent dired to write to modeline - it displays all the switches and pushes
;; everything far to the right.
(defvar dired-display-ls-switches nil
"Non-nil meands the Dired will display current ls-switches on modeline.")
(defun dired-sort-set-mode-line ()
;; Set mode line display according to dired-actual-switches.
;; Mode line display of "by name" or "by date" guarantees the user a
;; match with the corresponding regexps. Non-matching switches are
;; shown literally.
(when (eq major-mode 'dired-mode)
(setq mode-name
(let (case-fold-search)
(cond ((string-match-p
dired-sort-by-name-regexp dired-actual-switches)
"Dired by name")
((string-match-p
dired-sort-by-date-regexp dired-actual-switches)
"Dired by date")
((eq dired-display-ls-switches t)
(concat "Dired " dired-actual-switches)))))
(force-mode-line-update)))
I suggest as a usability improvement to add a user option to
enable/disable display of ls-switches on modeline, but if there is such
an option already, which I haven't discovered, then just ignore this :-).
- Dired - ls-switches on Modeline,
Arthur Miller <=