Сушеная настройка

Я просто столкнулся с этим сушеным экраном режима в Википедии. Я изучаю те настройки.

Относительно цветов я предполагаю просто определение, что корректные поверхности сделают, но как я становлюсь сушеным для показа файла, измеренного в кбайтах по умолчанию? И свободное место в MBS (верхняя строка)?

15
задан Cœur 17 June 2017 в 15:54
поделиться

3 ответа

Чтобы получить размеры файлов в килобайтах, вы можете настроить переменную dired-листинг-переключатели , чтобы использовать параметр -k :

(setq dired-listing-switches "-alk")

Вам нужно проделать немного больше работы, чтобы получить общие / доступные числа в МБ. Это работало в моей системе Linux, но доступная часть не работала в моем компьютере с Windows:

(setq directory-free-space-args "-Pm")
(defadvice insert-directory (after insert-directory-adjust-total-by-1024 activate)
  "modify the total number by dividing it by 1024"
  (save-excursion
(save-match-data
  (goto-char (point-min))
  (when (re-search-forward "^ *total used in directory \\([0-9]+\\) ")
    (replace-match (number-to-string (/ (string-to-number (match-string 1)) 1024)) nil nil nil 1)))))
14
ответ дан 1 December 2019 в 00:33
поделиться

Кроме того, отображение в dired позволяет только 9 пробелов, поэтому для очень больших файлов отображение в dired будет искажено. И снова это потребовало переопределения fn. В данном случае один из ls-lisp.el:

;; redefine this function, to fix the formatting of file sizes in dired mode
(defun ls-lisp-format-file-size (file-size human-readable)
  (if (or (not human-readable)
          (< file-size 1024))
      (format (if (floatp file-size) " %11.0f" " %11d") file-size)
    (do ((file-size (/ file-size 1024.0) (/ file-size 1024.0))
         ;; kilo, mega, giga, tera, peta, exa
         (post-fixes (list "k" "M" "G" "T" "P" "E") (cdr post-fixes)))
        ((< file-size 1024) (format " %10.0f%s"  file-size (car post-fixes))))))

(он просто заменяет 9.0 на 11.0 и 8.0 на 10.0 в строках формата)

1
ответ дан 1 December 2019 в 00:33
поделиться

Вы не спрашивали, но я решил добавить ....

Я хотел иметь возможность легко сортировать вывод dired по размеру и расширению, а также по имени и время. Я знаю, что могу сделать это с помощью M-x universal-argument dired-sort-toggle-or-edit , но я хотел, чтобы это было доступно на клавише s , чтобы сделать это быстро.

;; Redefine the sorting in dired to flip between sorting on name, size,
;; time, and extension,  rather than simply on name and time.

(defun dired-sort-toggle ()
  ;; Toggle between sort by date/name.  Reverts the buffer.
  (setq dired-actual-switches
        (let (case-fold-search)

          (cond

           ((string-match " " dired-actual-switches) ;; contains a space
            ;; New toggle scheme: add/remove a trailing " -t" " -S",
            ;; or " -U"

            (cond

             ((string-match " -t\\'" dired-actual-switches)
              (concat
               (substring dired-actual-switches 0 (match-beginning 0))
               " -X"))

             ((string-match " -X\\'" dired-actual-switches)
              (concat
               (substring dired-actual-switches 0 (match-beginning 0))
               " -S"))

             ((string-match " -S\\'" dired-actual-switches)
              (substring dired-actual-switches 0 (match-beginning 0)))

             (t
              (concat dired-actual-switches " -t"))))

           (t
            ;; old toggle scheme: look for a sorting switch, one of [tUXS]
            ;; and switch between them. Assume there is only ONE present.
            (let* ((old-sorting-switch
                    (if (string-match (concat "[t" dired-ls-sorting-switches "]")
                                      dired-actual-switches)
                        (substring dired-actual-switches (match-beginning 0)
                                   (match-end 0))
                      ""))

                       (new-sorting-switch
                        (cond
                         ((string= old-sorting-switch "t")
                          "X")
                         ((string= old-sorting-switch "X")
                          "S")
                         ((string= old-sorting-switch "S")
                          "")
                         (t
                          "t"))))
                  (concat
                   "-l"
                   ;; strip -l and any sorting switches
                   (dired-replace-in-string (concat "[-lt"
                                                    dired-ls-sorting-switches "]")
                                            ""
                                            dired-actual-switches)
                   new-sorting-switch))))))

  (dired-sort-set-modeline)
  (revert-buffer))
4
ответ дан 1 December 2019 в 00:33
поделиться
Другие вопросы по тегам:

Похожие вопросы: