Function: dired-sort-set-mode-line

dired-sort-set-mode-line is a byte-compiled function defined in dired.el.gz.

Signature

(dired-sort-set-mode-line)

Documentation

Set mode-line according to option dired-switches-in-mode-line.

Aliases

dired-sort-set-modeline (obsolete since 24.3)

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired-sort-set-mode-line ()
  "Set mode-line according to option `dired-switches-in-mode-line'."
  (when (eq major-mode 'dired-mode)
    (setq mode-name
	  (let ((case-fold-search  nil))
            (if dired-switches-in-mode-line
                (concat
                 "Dired"
                 (cond ((integerp dired-switches-in-mode-line)
                        (let* ((l1 (length dired-actual-switches))
                               (xs (substring
                                    dired-actual-switches
                                    0 (min l1 dired-switches-in-mode-line)))
                               (l2 (length xs)))
                          (if (zerop l2)
                              xs
                            (concat " " xs (and (< l2  l1) "…")))))
                       ((functionp dired-switches-in-mode-line)
                        (format " %s" (funcall
                                       dired-switches-in-mode-line
                                       dired-actual-switches)))
                       (t (concat " " dired-actual-switches))))
              (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")
                    (t (concat "Dired " dired-actual-switches))))))
    (force-mode-line-update)))