emacs/dired: refactor #1038

+ Removed ranger/dired-setup hook and performed its config globally
+ Lazy-loaded ranger
+ Removed unnecessary `:defer t`s (redundant with :commands and :hook)
  and `:commands` (redundant with :hook)
+ Set image-dired-dir before trying to create it, to give users an
  opportunity to modify it before it is created
+ Use sharp quotes consistently for keybind commands
This commit is contained in:
Henrik Lissner 2018-12-13 15:40:53 -05:00
parent 5e7a2d8703
commit ce38a80cf8
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -17,17 +17,18 @@
image-dired-temp-image-file (concat image-dired-dir "temp-image")
image-dired-temp-rotate-image-file (concat image-dired-dir "temp-rotate-image"))
:config
;; Use GNU ls as `gls' from `coreutils' if available. Add `(setq
;; dired-use-ls-dired nil)' to your config to suppress the Dired warning when
;; not using GNU ls. We must look for `gls' after `exec-path-from-shell' was
;; initialized to make sure that `gls' is in `exec-path'
(when IS-MAC
(let ((gls (executable-find "gls")))
(if gls
(setq insert-directory-program gls)
(message "Please install `gls` using `brew instal coreutils`..."))))
(setq dired-listing-switches "-aBhl --group-directories-first")
(when IS-MAC
;; Use GNU ls as `gls' from `coreutils' if available. Add `(setq
;; dired-use-ls-dired nil)' to your config to suppress the Dired warning
;; when not using GNU ls. We must look for `gls' after
;; `exec-path-from-shell' was initialized to make sure that `gls' is in
;; `exec-path'
(if-let* ((gls (executable-find "gls")))
(setq insert-directory-program gls)
(message "Cannot find `gls`. Install it using `brew install coreutils`")))
(defun +dired|sort-directories-first ()
"List directories first in dired buffers."
(save-excursion
@ -74,39 +75,34 @@
(def-package! ranger
:when (featurep! +ranger)
:after dired
:init
(defun ranger/dired-setup ()
(setq dired-omit-verbose nil)
(make-local-variable 'dired-hide-details-hide-symlink-targets)
(setq dired-hide-details-hide-symlink-targets nil)
;; hide details by default
(dired-hide-details-mode t))
(add-hook 'dired-mode-hook #'ranger/dired-setup)
(setq ranger-override-dired t)
;; set up image-dired to allow picture resize
(setq image-dired-dir (concat doom-cache-dir "image-dir"))
:config
(unless (file-directory-p image-dired-dir)
(make-directory image-dired-dir))
:config
(setq ranger-omit-regexp "^\.DS_Store$"
(set-popup-rule! "^\\*ranger" :ignore t)
(setq ranger-override-dired t
ranger-cleanup-on-disable t
ranger-omit-regexp "^\.DS_Store$"
ranger-excluded-extensions '("mkv" "iso" "mp4")
ranger-deer-show-details nil
ranger-max-preview-size 10))
ranger-max-preview-size 10
dired-omit-verbose nil))
(def-package! all-the-icons-dired
:when (featurep! +icons)
:defer t
:init
(add-hook! 'dired-mode-hook #'all-the-icons-dired-mode))
:hook (dired-mode . all-the-icons-dired-mode))
(def-package! dired-x
:defer t
:commands dired-omit-mode
:hook (dired-mode . dired-omit-mode))
;;
;; Evil integration
@ -116,8 +112,8 @@
:n "q" #'quit-window
:m "j" #'dired-next-line
:m "k" #'dired-previous-line
:n [mouse-2] 'dired-mouse-find-file-other-window
:n [follow-link] 'mouse-face
:n [mouse-2] #'dired-mouse-find-file-other-window
:n [follow-link] #'mouse-face
;; Commands to mark or flag certain categories of files
:n "#" #'dired-flag-auto-save-files
:n "." #'dired-clean-directory
@ -224,26 +220,26 @@
:n "<" #'dired-prev-dirline
:n ">" #'dired-next-dirline
:n "^" #'dired-up-directory
:n [?\S-\ ] 'dired-previous-line
:n [remap next-line] 'dired-next-line
:n [remap previous-line] 'dired-previous-line
:n [?\S-\ ] #'dired-previous-line
:n [remap next-line] #'dired-next-line
:n [remap previous-line] #'dired-previous-line
;; hiding
:n "g$" #'dired-hide-subdir ;; FIXME: This can probably live on a better binding.
:n "M-$" #'dired-hide-all
:n "(" #'dired-hide-details-mode
;; isearch
:n "M-s a C-s" 'dired-do-isearch
:n "M-s a C-s" #'dired-do-isearch
:n "M-s a M-C-s" #'dired-do-isearch-regexp
:n "M-s f C-s" 'dired-isearch-filenames
:n "M-s f C-s" #'dired-isearch-filenames
:n "M-s f M-C-s" #'dired-isearch-filenames-regexp
;; misc
:n [remap read-only-mode] 'dired-toggle-read-only
:n [remap read-only-mode] #'dired-toggle-read-only
;; `toggle-read-only' is an obsolete alias for `read-only-mode'
:n [remap toggle-read-only] 'dired-toggle-read-only
:n [remap toggle-read-only] #'dired-toggle-read-only
:n "g?" #'dired-summary
:n "<delete>" #'dired-unmark-backward
:n [remap undo] 'dired-undo
:n [remap advertised-undo] 'dired-undo
:n [remap undo] #'dired-undo
:n [remap advertised-undo] #'dired-undo
;; thumbnail manipulation (image-dired)
:n "C-t d" #'image-dired-display-thumbs
:n "C-t t" #'image-dired-tag-files