-;; Time-stamp: <2015-06-04 11:16:15 kmodi>
+;; Time-stamp: <2016-02-25 11:32:34 kmodi>
 
-;; dired, dired-x, dired+, dired-single
+;; Dired
+
 ;; http://www.emacswiki.org/emacs-en/dired-single.el
-;; http://truongtx.me/2013/04/24/dired-as-default-file-manager-1-introduction
+(use-package dired-single
+  :bind (:map modi-mode-map
+         ;; Change the default `C-x C-d` key binding from `ido-list-directory'
+         ("C-x C-d" . dired-single-magic-buffer-current-dir)
+         ;; Change the default `C-x C-j` key binding from `dired-jump'
+         ;; Opens dired-single-magic-buffer but asks which directory to open that
+         ;; dired buffer for.
+         ("C-x C-j" . dired-single-magic-buffer))
+  :config
+  (progn
+    (defun dired-single-magic-buffer-current-dir ()
+      "Open a single magic dired buffer for the current buffer directory."
+      (interactive)
+      (dired-single-magic-buffer default-directory))
 
-(use-package dired-single
-  :commands (dired dired-single-magic-buffer-current-dir dired-single-magic-buffer)
-  :init
-  (progn
+    (defun dired-single-up-directory ()
+      (interactive)
+      (dired-single-buffer ".."))
+
     (bind-keys
-     :map modi-mode-map
-      ;; Change the default `C-x C-d` key binding from `ido-list-directory'
-      ("C-x C-d" . dired-single-magic-buffer-current-dir)
-      ;; Change the default `C-x C-j` key binding from `dired-jump'
-      ;; Opens dired-single-magic-buffer but asks which directory to open that
-      ;; dired buffer for.
-      ("C-x C-j" . dired-single-magic-buffer)))
+     :map dired-mode-map
+      ("<return>"         . dired-single-buffer)
+      ("<double-mouse-1>" . dired-single-buffer-mouse)
+      ("^"                . dired-single-up-directory))))
+
+(use-package dired
+  :commands (dired dired-toggle-read-only
+                   dired-get-filename) ; called by `dired-single'
   :config
   (progn
     (setq dired-recursive-deletes 'always)

    ;; in the prompt for file copy, rename etc.
    (setq dired-dwim-target t)

    (use-package dired+
      :config
      (progn
        ;; detail toggling is bound to `(' in dired-mode by default
        (setq diredp-hide-details-initially-flag nil)
        (setq diredp-hide-details-last-state     nil)

        ;; Privilege indicator faces
        (defun modi/dired-update-priv-faces ()
          (set-face-attribute 'diredp-dir-priv nil
                              :foreground "#7474FFFFFFFF"
                              :background (face-background 'default))

                              :background (face-background 'default))
          (set-face-attribute 'diredp-link-priv nil
                              :foreground "#00007373FFFF"))
        (add-hook 'dired-mode-hook #'modi/dired-update-privilege-faces)))))


(provide 'setup-dired)
