all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Dired - ls-switches on Modeline
@ 2020-05-13  9:10 Arthur Miller
  2020-05-13 15:27 ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Arthur Miller @ 2020-05-13  9:10 UTC (permalink / raw)
  To: emacs-devel

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 :-).



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

end of thread, other threads:[~2020-05-14 15:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-13  9:10 Dired - ls-switches on Modeline Arthur Miller
2020-05-13 15:27 ` Drew Adams
2020-05-13 16:01   ` arthur miller
2020-05-14  1:31   ` Arthur Miller
2020-05-14 15:29     ` Drew Adams

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.