1

I'm using the excelent dired-fixups.el by Dino Chiesa for sorting in Dired by size and extension (see here).

The only gotcha is that I'd like to combine it with a fuller date/time description. Also, I'd like to keep directories on top of any Dired buffer, so they don't mix with files. That is, I'd like to combine dired-fixups.el with something like this:

(setq ls-lisp-format-time-list  '("%d.%m.%Y %H:%M:%S" "%d.%m.%Y %H:%M:%S")
      ls-lisp-use-localized-time-format t)

(defun ls-lisp-format-time (file-attr time-index now)
    "%d.%m.%Y %H:%M:%S" "%d.%m.%Y %H:%M:%S")

  (if (eq system-type 'gnu/linux)
      (setq dired-listing-switches "-alDh --group-directories-first --time-style \"+%d-%m-%Y %H:%M:%S\""))

  (defun ensure-buffer-name-ends-in-slash ()
    "change buffer name to end with slash"
    (let ((name (buffer-name)))
      (if (not (string-match "/$" name))
          (rename-buffer (concat name "/") t))))

  (add-hook 'dired-mode-hook 'ensure-buffer-name-ends-in-slash)

  (add-hook 'dired-mode-hook
            (lambda()
              (setq truncate-lines 1)))

However, I'm not a programmer. I've been tweaking with the code in dired-fixups.el to no avail. Probably it is not too difficult... Does anybody know how to get an outcome like the following snapshot, but where I can use all the sorting options in dired-fixups.el?

  /home/dgm/.emacs.d/src:
  total used in directory 364K available 15413252
  drwxr-xr-x 21 dgm dgm  12K 29-03-2020 23:27:42 ..
  drwxr-xr-x 14 dgm dgm 4.0K 29-03-2020 09:05:19 .
  drwxr-xr-x  2 dgm dgm 4.0K 05-09-2019 23:58:20 org-recipes
  drwxr-xr-x  2 dgm dgm 4.0K 09-08-2019 12:52:48 ambrevar
  drwxr-xr-x  8 dgm dgm 4.0K 21-04-2019 16:10:22 ado-mode-1.15.1.4
  drwxr-xr-x  2 dgm dgm 4.0K 07-12-2018 15:57:55 ob-stata
  drwxr-xr-x  7 dgm dgm 4.0K 06-12-2018 11:26:01 dvc
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 minimal
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 org-bullets
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 smooth-scrolling
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 stripe-buffer
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 wc
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 word-count
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 bookmarkplus
  -rw-r--r--  1 dgm dgm 4.9K 29-03-2020 09:05:19 dired-fixups.el
  -rw-r--r--  1 dgm dgm  36K 28-03-2020 22:12:11 dired-sort-menu.el
  -rw-r--r--  1 dgm dgm  17K 28-03-2020 22:10:05 dired-sort-menu+.el
  -rw-r--r--  1 dgm dgm 4.6K 27-01-2020 19:47:40 org-graph-view.el
  -rw-r--r--  1 dgm dgm  38K 27-01-2020 19:47:23 graph.el
  -rw-r--r--  1 dgm dgm 6.0K 02-01-2020 16:08:56 window-highlight.el
0

Library Dired Sort Menu (dired-sort-menu.el) lets you do what you ask.

From the menu, choose Dirs First, and choose any of these menu items at the same time (Dirs First is a toggle option):

  • Name
  • Time Modified
  • Size
  • Extension
  • Unsorted
  • Time Created

See the screenshot at Dired Sort Menu.

(If you don't want to use a menu you can use its code to create commands you can bind to keyboard keys.)

| improve this answer | |
  • Thank you for your answer. Yes, I'm aware of this other .el file... Somehow though I prefer Dino's .el. Can't remember exactly why now. Anyway, I'd like to know how can I tinker with Dino's file so that I can get what he gets but with the added benefit of a full date/time stamp on all entries and with directories listed first. – Daniel Mar 30 at 8:42
  • 1
    For the record: I now think it is not worthwhile spending time customizing Dired in the way I meant earlier. Dired already caters for all sorting needs. C-u s prompts for switches to sort the contents of the Dired buffer by: -t for time, newest 1st; -S for file size, largest 1st; -X for extension; -r for reversing; -U for directory order. Long live Emacs and its manual! – Daniel Apr 20 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.