Borrowing from Jasspa MicroEmacs : Dired Sort Keybindings
I've been exploring Jasspa MicroEmacs lately - a lightweight Emacs like editor with a surprisingly thoughtful set of defaults, its footprint is surprisingly small, 1-2MB on your disk, useful for a portable Emacs or in my case allows me to run up an Emacs like editor on my work laptop (as it blocks GNU Emacs). No installation, just a single very small executable and it comes in many different varieties, windows, linux and GUI or terminal based.
For those unfamiliar with the lineage, MicroEmacs originally dates back to 1985 when Dave Conroy built a tiny, portable Emacs clone, later maintained for decades by Daniel M. Lawrence (and famously still used by Linus Torvalds today!). Around 1988, Jon Green and Steven Phillips forked MicroEmacs 3.8 to build Jasspa, it uses a subset of full emacs command set and it can emulate the keybindings from Microemacs, GNU Emacs, and even Windows CUA keybindings. It's a much enhanced version of the Daniel Lawrence's original MicroEmacs 3.8 of 1988 and they have grown it into a remarkably feature-packed environment with syntax highlighting, windowing, and a macro language and its still regularly updated!
One thing that immediately caught my eye in Jasspa was its file manager (a dired equivalent that, while not a direct clone of GNU Dired is surprisingly functional). Specifically: single numeric keystrokes to instantly re-sort directory listings by size, time, name, or extension.
Back in GNU Emacs, I usually reach for s in Dired to cycle the sort, or C-u s to manually type ls switches. It works, but it's the kind of subtle friction you don't notice until you've tried a direct alternative. Once I'd spent an afternoon in Jasspa, the muscle memory was already forming:
3for size when cleaning up disk-hungry directories4for date when looking for recent modifications5to reset back to alphabetical6to group by extension
Bringing this to GNU Emacs took less than thirty lines of Elisp - four small wrapper functions around dired-sort-other and a few keybindings:
(defun my/dired-sort-by-size ()
"Sort Dired buffer by file size."
(interactive)
(dired-sort-other "-alGghS"))
(defun my/dired-sort-by-date ()
"Sort Dired buffer by last modification date."
(interactive)
(dired-sort-other "-alGght"))
(defun my/dired-sort-by-name ()
"Sort Dired buffer alphabetically by name."
(interactive)
(dired-sort-other "-alGgh"))
(defun my/dired-sort-by-extension ()
"Sort Dired buffer by file extension."
(interactive)
(dired-sort-other "-alGghX"))
(with-eval-after-load 'dired
(define-key dired-mode-map (kbd "3") #'my/dired-sort-by-size)
(define-key dired-mode-map (kbd "4") #'my/dired-sort-by-date)
(define-key dired-mode-map (kbd "5") #'my/dired-sort-by-name)
(define-key dired-mode-map (kbd "6") #'my/dired-sort-by-extension))
More posts to come I think on Jasspa!