__________________________________________

               HOW I USE EMACS/DIRED AS MY FILE MANAGER
              __________________________________________





Make the default view more usable
=================================

 1. Don't show hidden files by default and group directories first (you
    can change the switches on the fly by pressing "C-u s").

 2. Move files to the trash bin instead of deleting them right away.

 3. Use only one buffer when navigating the file tree.

 ,----
 | (setq dired-listing-switches "-Bhl --group-directories-first")
 |       delete-by-moving-to-trash t
 |       dired-kill-when-opening-new-dired-buffer t)
 `----



Open files with an external program
===================================

 Elisp-function to open a file with the appropriate program (linux)[1].

 ,----
 | (defun my/xdg-open ()
 |   "Open file on point with xdg-open."
 |   (interactive)
 |   (let ((process-connection-type nil))
 |     (start-process "" nil "xdg-open"
 |                    (car (dired-get-marked-files)))))
 `----

 Call the function by pressing "e" but only in dired-mode. Also
 truncate lines longer than the window width.

 ,----
 | (add-hook 'dired-mode-hook
 |       (lambda ()
 |         (define-key dired-mode-map (kbd "e") #'my/xdg-open)
 |         (toggle-truncate-lines 1)))
 `----


Shortcut to the home directory
==============================

 Just a keybinding to quickly open the home directory.

 ,----
 | (defun my/go-home ()
 |   "open dired buffer at home directory"
 |   (interactive)
 |   (dired "~/")
 |   (revert-buffer))
 | (global-set-key (kbd "C-c h") 'my/go-home)
 `----

 Pro tip: All keys prefixed with C-c ? (where ? is a single character in
 the range a..z) are reserved for user defined key bindings.

 Pro tip 2: You could just use bookmark. bookmark-jump is bound to
 C-x r b. Could be worse ;)

Footnotes
_________

[1] http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html