Skip to content

Instantly share code, notes, and snippets.

@synic
Created October 15, 2015 00:12
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save synic/5c1a494eaad1406c5519 to your computer and use it in GitHub Desktop.
Save synic/5c1a494eaad1406c5519 to your computer and use it in GitHub Desktop.
Fixing dired in spacemacs

First, add dired+ to dotspacemacs-additional-packages, then...

Before user-config in .spacemacs:

(defvar ao/v-dired-omit t
  "If dired-omit-mode enabled by default. Don't setq me.")

(defun ao/dired-omit-switch ()
  "This function is a small enhancement for `dired-omit-mode', which will
   \"remember\" omit state across Dired buffers."
  (interactive)
  (if (eq ao/v-dired-omit t)
      (setq ao/v-dired-omit nil)
    (setq ao/v-dired-omit t))
  (ao/dired-omit-caller)
  (when (equal major-mode 'dired-mode)
    (revert-buffer)))

(defun ao/dired-omit-caller ()
  (if ao/v-dired-omit
      (setq dired-omit-mode t)
    (setq dired-omit-mode nil)))

(defun ao/dired-back-to-top()
  "Move to the first file."
  (interactive)
  (beginning-of-buffer)
  (dired-next-line 2))

(defun ao/dired-jump-to-bottom()
  "Move to last file."
  (interactive)
  (end-of-buffer)
  (dired-next-line -1))

Inside user-config in spacemacs:

  ;; Dired
  (require 'dired-x) ; Enable dired-x
  (require 'dired+)  ; Enable dired+
  (setq-default dired-omit-files-p t)  ; Don't show hidden files by default
  (setq dired-omit-files (concat dired-omit-files "\\|^\\..+$\\|\\.pyc$"))
  (add-hook 'dired-mode-hook 'ao/dired-omit-caller)
  (define-key evil-normal-state-map (kbd "_") 'projectile-dired)
  (define-key evil-normal-state-map (kbd "-") 'dired-jump)
  (setq diredp-hide-details-initially-flag nil)
  (advice-add 'spacemacs/find-dotfile :around 'ao/find-dotfile)
  ;; Make `gg' and `G' do the correct thing
  (eval-after-load "dired-mode"
    (evilify dired-mode dired-mode-map
             "f" 'helm-find-files
             "h" 'diredp-up-directory-reuse-dir-buffer
             "l" 'diredp-find-file-reuse-dir-buffer
             "I" 'ao/dired-omit-switch
             "gg" 'ao/dired-back-to-top
             "G" 'ao/dired-jump-to-bottom))
@chuwy
Copy link

chuwy commented Jul 22, 2016

evilify must be changed toevilified-state-evilify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment