Dired history in Emacs

Emacs is reasonably consistent across its major-modes in its common usage patterns and keybindings. For example, C-M-a and C-M-e consistently move you to the beginnings and ends of functions in various language modes, and C-c C-z moves the focus to REPLs and back. In read-only modes n and p move the cursor up and down, and w generally copies the path, address or URL of the buffer to the kill ring.

One of these consistent (but less well known) keybindings is for going back and forward across nodes in a tree, arranged into a list: l and r traverse your history and “forward” history of visited help pages in help-mode, info nodes in Info-mode Info mode takes this further. L gives you an index of your visited nodes, which is itself placed into history! , web pages in eww, locations in pdf-tools and probably others. I think of this as moving [l]eft or [r]ight across a traversal path.

But there are some omissions. I frequently find myself using l and r in dired buffers to navigate my history of visited dired buffers, where it annoyingly does nothing. I assumed this feature would be part of one of the many, many Emacs packages that extend dired, but while there are big total makeovers (like ranger.el) for dired that include it, there wasn’t anything simple.

So I wrote a helper: dired-hist. It’s very basic (< 50 LOC) and will remain so, although I might add some customization options in time.