2017-06-08 11:47:56 +02:00
|
|
|
;;; tools/dired/config.el -*- lexical-binding: t; -*-
|
2017-02-19 18:53:38 -05:00
|
|
|
|
2018-01-27 20:49:46 -05:00
|
|
|
(def-package! dired
|
2018-06-01 13:46:52 +02:00
|
|
|
:commands dired-jump
|
2018-01-27 20:49:46 -05:00
|
|
|
:init
|
|
|
|
(setq ;; Always copy/delete recursively
|
|
|
|
dired-recursive-copies 'always
|
|
|
|
dired-recursive-deletes 'top
|
|
|
|
;; Auto refresh dired, but be quiet about it
|
2018-06-01 13:46:52 +02:00
|
|
|
dired-hide-details-hide-symlink-targets nil
|
2018-01-27 20:49:46 -05:00
|
|
|
;; files
|
|
|
|
image-dired-dir (concat doom-cache-dir "image-dired/")
|
2018-03-19 23:55:45 -04:00
|
|
|
image-dired-db-file (concat image-dired-dir "db.el")
|
2018-01-27 20:49:46 -05:00
|
|
|
image-dired-gallery-dir (concat image-dired-dir "gallery/")
|
|
|
|
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
|
2019-03-02 13:49:39 -05:00
|
|
|
(let ((args (list "-aBhl" "--group-directories-first")))
|
|
|
|
(when IS-BSD
|
|
|
|
;; Use GNU ls as `gls' from `coreutils' if available. Add `(setq
|
|
|
|
;; dired-use-ls-dired nil)' to your config to suppress the Dired warning
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
;; when not using GNU ls.
|
2019-03-02 13:49:39 -05:00
|
|
|
(if-let* ((gls (executable-find "gls")))
|
|
|
|
(setq insert-directory-program gls)
|
2019-05-14 18:45:38 -04:00
|
|
|
;; BSD ls doesn't support --group-directories-first
|
|
|
|
(setq args (delete "--group-directories-first" args))))
|
2019-03-02 13:49:39 -05:00
|
|
|
(setq dired-listing-switches (string-join args " ")))
|
2018-12-13 15:40:53 -05:00
|
|
|
|
2019-05-20 16:04:01 -04:00
|
|
|
(define-key! dired-mode-map
|
|
|
|
;; Kill buffer when quitting dired buffers
|
|
|
|
[remap quit-window] (λ! (quit-window t))
|
|
|
|
;; To be consistent with ivy/helm+wgrep integration
|
|
|
|
"C-c C-e" #'wdired-change-to-wdired-mode))
|
|
|
|
|
|
|
|
|
2019-05-20 17:40:16 -04:00
|
|
|
(def-package! dired-rsync
|
|
|
|
:general (dired-mode-map "C-c C-r" #'dired-rsync))
|
|
|
|
|
|
|
|
|
2019-05-20 16:04:01 -04:00
|
|
|
(def-package! diredfl
|
|
|
|
:hook (dired-mode . diredfl-mode))
|
2017-02-19 18:53:38 -05:00
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! dired-k
|
2018-07-21 01:29:38 +02:00
|
|
|
:hook (dired-initial-position . dired-k)
|
|
|
|
:hook (dired-after-readin . dired-k-no-revert)
|
2017-02-19 18:53:38 -05:00
|
|
|
:config
|
2019-05-20 16:04:01 -04:00
|
|
|
(setq dired-k-style 'git
|
|
|
|
dired-k-padding 1)
|
|
|
|
|
|
|
|
;; Don't highlight based on mtime, this interferes with diredfl and is more
|
|
|
|
;; confusing than helpful.
|
|
|
|
(advice-add #'dired-k--highlight-by-file-attribyte :override #'ignore)
|
|
|
|
|
2018-01-31 05:08:25 -05:00
|
|
|
(defun +dired*interrupt-process (orig-fn &rest args)
|
|
|
|
"Fixes dired-k killing git processes too abruptly, leaving behind disruptive
|
|
|
|
.git/index.lock files."
|
|
|
|
(cl-letf (((symbol-function #'kill-process)
|
|
|
|
(symbol-function #'interrupt-process)))
|
|
|
|
(apply orig-fn args)))
|
|
|
|
(advice-add #'dired-k--start-git-status :around #'+dired*interrupt-process)
|
|
|
|
|
2017-04-16 11:56:37 -04:00
|
|
|
(defun +dired*dired-k-highlight (orig-fn &rest args)
|
|
|
|
"Butt out if the requested directory is remote (i.e. through tramp)."
|
|
|
|
(unless (file-remote-p default-directory)
|
|
|
|
(apply orig-fn args)))
|
2018-01-27 20:49:46 -05:00
|
|
|
(advice-add #'dired-k--highlight :around #'+dired*dired-k-highlight))
|
2018-05-31 13:10:34 +02:00
|
|
|
|
|
|
|
|
2018-12-07 22:27:03 -08:00
|
|
|
(def-package! ranger
|
|
|
|
:when (featurep! +ranger)
|
2018-12-13 15:40:53 -05:00
|
|
|
:after dired
|
2018-12-07 22:27:03 -08:00
|
|
|
:init
|
|
|
|
;; set up image-dired to allow picture resize
|
2019-05-20 20:04:34 -04:00
|
|
|
(setq image-dired-dir (concat doom-cache-dir "image-dir")
|
|
|
|
ranger-override-dired t)
|
2018-12-13 15:40:53 -05:00
|
|
|
:config
|
2018-12-07 22:27:03 -08:00
|
|
|
(unless (file-directory-p image-dired-dir)
|
|
|
|
(make-directory image-dired-dir))
|
2018-12-13 15:40:53 -05:00
|
|
|
|
|
|
|
(set-popup-rule! "^\\*ranger" :ignore t)
|
|
|
|
|
2019-05-20 20:04:34 -04:00
|
|
|
(defun +dired*cleanup-header-line ()
|
|
|
|
"Ranger fails to clean up `header-line-format' when it is closed, so..."
|
|
|
|
(dolist (buffer (buffer-list))
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(when (equal header-line-format '(:eval (ranger-header-line)))
|
|
|
|
(setq header-line-format nil))))))
|
|
|
|
(advice-add #'ranger-revert :before #'+dired*cleanup-header-line)
|
|
|
|
|
|
|
|
(defun +dired*cleanup-mouse1-bind ()
|
|
|
|
"Ranger binds an anonymous function to mouse-1 after previewing a buffer
|
|
|
|
that prevents the user from escaping the window with the mouse. This command is
|
|
|
|
never cleaned up if the buffer already existed before ranger was initialized, so
|
|
|
|
we have to clean it up ourselves."
|
|
|
|
(when (window-live-p ranger-preview-window)
|
|
|
|
(with-current-buffer (window-buffer ranger-preview-window)
|
|
|
|
(local-unset-key [mouse-1]))))
|
|
|
|
(advice-add #'ranger-setup-preview :after #'+dired*cleanup-mouse1-bind)
|
|
|
|
|
|
|
|
(setq ranger-cleanup-on-disable t
|
2018-12-07 22:27:03 -08:00
|
|
|
ranger-excluded-extensions '("mkv" "iso" "mp4")
|
2019-05-20 20:04:34 -04:00
|
|
|
ranger-deer-show-details t
|
2018-12-13 15:40:53 -05:00
|
|
|
ranger-max-preview-size 10
|
2019-03-09 16:54:54 -05:00
|
|
|
ranger-show-literal nil
|
2019-05-20 20:04:34 -04:00
|
|
|
ranger-hide-cursor nil))
|
2018-12-07 22:27:03 -08:00
|
|
|
|
|
|
|
|
|
|
|
(def-package! all-the-icons-dired
|
|
|
|
:when (featurep! +icons)
|
2018-12-13 15:40:53 -05:00
|
|
|
:hook (dired-mode . all-the-icons-dired-mode))
|
2018-12-07 22:27:03 -08:00
|
|
|
|
|
|
|
|
|
|
|
(def-package! dired-x
|
2018-12-27 16:37:44 +13:00
|
|
|
:hook (dired-mode . dired-omit-mode)
|
|
|
|
:config
|
|
|
|
(setq dired-omit-verbose nil))
|