Getting better with Emacs Dired

I've used Dired, the Emacs directory editor, on occasion for a long time. Like anything with Emacs, there are the commands that get wired into your fingers, and those that you never quite remember. Here's a bit of getting better with dired.

Sometimes it's helpful to take a quick look at a file before deciding to rename or delete it:

o open in other window (below in frame). Reuses bottom window.
C-o Display file in other window, but do not select it.

`C-o` is especially helpful for a quick look, since the keyboard focus stays in the dired buffer.

I also found a helpful function on the Emacs Wiki page for Dired Find File Other Frame. It opens a file in a new frame, instead of just a new window. I added a slight variant to open the file read only (view mode) in a new frame as well.

  (defun dired-find-file-other-frame ()
    "In Dired, visit this file or directory in another frame."
    (interactive)
    (find-file-other-frame
     (dired-get-file-for-visit)))

  (defun wt/dired-find-file-read-only-other-frame ()
    "In Dired, visit this file or directory in another frame."
    (interactive)
    (find-file-read-only-other-frame
     (dired-get-file-for-visit)))

  (eval-after-load "dired"
    '(progn
       (define-key dired-mode-map "F"
                   'dired-find-file-other-frame)
       (define-key dired-mode-map "V"
                   'dired-find-file-read-only-other-frame)))

Finally, a little non-dired bonus hack, from the Emacs Wiki page on Killing Buffers:

  (substitute-key-definition 'kill-buffer
                             'kill-buffer-and-its-windows
                             global-map)

This changes C-x C-k to kill the windows, and frame if appropriate, that were showing a buffer when it is killed. I'm not sure it works best yet, but I'm giving it a try now.