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
|
|
|
|
(setq image-dired-dir (concat doom-cache-dir "image-dir"))
|
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)
|
|
|
|
|
|
|
|
(setq ranger-override-dired t
|
|
|
|
ranger-cleanup-on-disable t
|
|
|
|
ranger-omit-regexp "^\.DS_Store$"
|
2018-12-07 22:27:03 -08:00
|
|
|
ranger-excluded-extensions '("mkv" "iso" "mp4")
|
|
|
|
ranger-deer-show-details nil
|
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
|
2018-12-13 15:40:53 -05:00
|
|
|
dired-omit-verbose 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))
|
2018-12-07 22:27:03 -08:00
|
|
|
|
2018-12-13 15:40:53 -05:00
|
|
|
|
2018-05-31 13:10:34 +02:00
|
|
|
;;
|
2019-05-14 18:45:38 -04:00
|
|
|
;;; Evil integration
|
2018-05-31 13:10:34 +02:00
|
|
|
|
2019-04-21 19:59:44 -04:00
|
|
|
(map! :when (featurep! :editor evil +everywhere)
|
2018-05-31 13:10:34 +02:00
|
|
|
:after dired
|
|
|
|
:map dired-mode-map
|
|
|
|
:n "q" #'quit-window
|
|
|
|
:m "j" #'dired-next-line
|
|
|
|
:m "k" #'dired-previous-line
|
2018-12-13 15:40:53 -05:00
|
|
|
:n [mouse-2] #'dired-mouse-find-file-other-window
|
|
|
|
:n [follow-link] #'mouse-face
|
2018-05-31 13:10:34 +02:00
|
|
|
;; Commands to mark or flag certain categories of files
|
|
|
|
:n "#" #'dired-flag-auto-save-files
|
|
|
|
:n "." #'dired-clean-directory
|
|
|
|
:n "~" #'dired-flag-backup-files
|
|
|
|
;; Upper case keys (except !) for operating on the marked files
|
|
|
|
:n "A" #'dired-do-find-regexp
|
|
|
|
:n "C" #'dired-do-copy
|
|
|
|
:n "B" #'dired-do-byte-compile
|
|
|
|
:n "D" #'dired-do-delete
|
|
|
|
:n "gG" #'dired-do-chgrp ;; FIXME: This can probably live on a better binding.
|
|
|
|
:n "H" #'dired-do-hardlink
|
|
|
|
:n "L" #'dired-do-load
|
|
|
|
:n "M" #'dired-do-chmod
|
|
|
|
:n "O" #'dired-do-chown
|
|
|
|
:n "P" #'dired-do-print
|
|
|
|
:n "Q" #'dired-do-find-regexp-and-replace
|
|
|
|
:n "R" #'dired-do-rename
|
|
|
|
:n "S" #'dired-do-symlink
|
|
|
|
:n "T" #'dired-do-touch
|
|
|
|
:n "X" #'dired-do-shell-command
|
|
|
|
:n "Z" #'dired-do-compress
|
|
|
|
:n "c" #'dired-do-compress-to
|
|
|
|
:n "!" #'dired-do-shell-command
|
|
|
|
:n "&" #'dired-do-async-shell-command
|
|
|
|
;; Comparison commands
|
|
|
|
:n "=" #'dired-diff
|
|
|
|
;; Tree Dired commands
|
|
|
|
:n "M-C-?" #'dired-unmark-all-files
|
|
|
|
:n "M-C-d" #'dired-tree-down
|
|
|
|
:n "M-C-u" #'dired-tree-up
|
|
|
|
:n "M-C-n" #'dired-next-subdir
|
|
|
|
:n "M-C-p" #'dired-prev-subdir
|
|
|
|
;; move to marked files
|
|
|
|
:n "M-{" #'dired-prev-marked-file
|
|
|
|
:n "M-}" #'dired-next-marked-file
|
|
|
|
;; Make all regexp commands share a `%' prefix:
|
|
|
|
;; We used to get to the submap via a symbol dired-regexp-prefix, but that
|
|
|
|
;; seems to serve little purpose, and copy-keymap does a better job
|
|
|
|
;; without it.
|
|
|
|
:n "%" nil
|
|
|
|
:n "%u" #'dired-upcase
|
|
|
|
:n "%l" #'dired-downcase
|
|
|
|
:n "%d" #'dired-flag-files-regexp
|
|
|
|
:n "%g" #'dired-mark-files-containing-regexp
|
|
|
|
:n "%m" #'dired-mark-files-regexp
|
|
|
|
:n "%r" #'dired-do-rename-regexp
|
|
|
|
:n "%C" #'dired-do-copy-regexp
|
|
|
|
:n "%H" #'dired-do-hardlink-regexp
|
|
|
|
:n "%R" #'dired-do-rename-regexp
|
|
|
|
:n "%S" #'dired-do-symlink-regexp
|
|
|
|
:n "%&" #'dired-flag-garbage-files
|
|
|
|
;; mark
|
|
|
|
:n "*" nil
|
|
|
|
:n "**" #'dired-mark-executables
|
|
|
|
:n "*/" #'dired-mark-directories
|
|
|
|
:n "*@" #'dired-mark-symlinks
|
|
|
|
:n "*%" #'dired-mark-files-regexp
|
|
|
|
:n "*(" #'dired-mark-sexp
|
|
|
|
:n "*." #'dired-mark-extension
|
|
|
|
:n "*O" #'dired-mark-omitted
|
|
|
|
:n "*c" #'dired-change-marks
|
|
|
|
:n "*s" #'dired-mark-subdir-files
|
|
|
|
:n "*m" #'dired-mark
|
|
|
|
:n "*u" #'dired-unmark
|
|
|
|
:n "*?" #'dired-unmark-all-files
|
|
|
|
:n "*!" #'dired-unmark-all-marks
|
|
|
|
:n "U" #'dired-unmark-all-marks
|
|
|
|
:n "* <delete>" #'dired-unmark-backward
|
|
|
|
:n "* C-n" #'dired-next-marked-file
|
|
|
|
:n "* C-p" #'dired-prev-marked-file
|
|
|
|
:n "*t" #'dired-toggle-marks
|
|
|
|
;; Lower keys for commands not operating on all the marked files
|
|
|
|
:n "a" #'dired-find-alternate-file
|
|
|
|
:n "d" #'dired-flag-file-deletion
|
|
|
|
:n "gf" #'dired-find-file
|
|
|
|
:n "C-m" #'dired-find-file
|
|
|
|
:n "gr" #'revert-buffer
|
|
|
|
:n "i" #'dired-toggle-read-only
|
|
|
|
:n "I" #'dired-maybe-insert-subdir
|
|
|
|
:n "J" #'dired-goto-file
|
|
|
|
:n "K" #'dired-do-kill-lines
|
|
|
|
:n "r" #'dired-do-redisplay
|
|
|
|
:n "m" #'dired-mark
|
|
|
|
:n "t" #'dired-toggle-marks
|
2018-12-07 22:27:03 -08:00
|
|
|
:n "u" #'dired-unmark ; also "*u"
|
2018-05-31 13:10:34 +02:00
|
|
|
:n "W" #'browse-url-of-dired-file
|
|
|
|
:n "x" #'dired-do-flagged-delete
|
|
|
|
:n "gy" #'dired-show-file-type ;; FIXME: This could probably go on a better key.
|
|
|
|
:n "Y" #'dired-copy-filename-as-kill
|
|
|
|
:n "+" #'dired-create-directory
|
|
|
|
;; open
|
|
|
|
:n "<return>" #'dired-find-file
|
|
|
|
:n "S-<return>" #'dired-find-file-other-window
|
|
|
|
:n "M-<return>" #'dired-display-file
|
|
|
|
:n "gO" #'dired-find-file-other-window
|
|
|
|
:n "go" #'dired-view-file
|
|
|
|
;; sort
|
|
|
|
:n "o" #'dired-sort-toggle-or-edit
|
|
|
|
;; moving
|
|
|
|
:m "gj" #'dired-next-dirline
|
|
|
|
:m "gk" #'dired-prev-dirline
|
|
|
|
:n "[" #'dired-prev-dirline
|
|
|
|
:n "]" #'dired-next-dirline
|
|
|
|
:n "<" #'dired-prev-dirline
|
|
|
|
:n ">" #'dired-next-dirline
|
|
|
|
:n "^" #'dired-up-directory
|
2018-12-13 15:40:53 -05:00
|
|
|
:n [?\S-\ ] #'dired-previous-line
|
|
|
|
:n [remap next-line] #'dired-next-line
|
|
|
|
:n [remap previous-line] #'dired-previous-line
|
2018-05-31 13:10:34 +02:00
|
|
|
;; 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
|
2018-12-13 15:40:53 -05:00
|
|
|
:n "M-s a C-s" #'dired-do-isearch
|
2018-05-31 13:10:34 +02:00
|
|
|
:n "M-s a M-C-s" #'dired-do-isearch-regexp
|
2018-12-13 15:40:53 -05:00
|
|
|
:n "M-s f C-s" #'dired-isearch-filenames
|
2018-05-31 13:10:34 +02:00
|
|
|
:n "M-s f M-C-s" #'dired-isearch-filenames-regexp
|
|
|
|
;; misc
|
2018-12-13 15:40:53 -05:00
|
|
|
:n [remap read-only-mode] #'dired-toggle-read-only
|
2018-05-31 13:10:34 +02:00
|
|
|
;; `toggle-read-only' is an obsolete alias for `read-only-mode'
|
2018-12-13 15:40:53 -05:00
|
|
|
:n [remap toggle-read-only] #'dired-toggle-read-only
|
2018-05-31 13:10:34 +02:00
|
|
|
:n "g?" #'dired-summary
|
|
|
|
:n "<delete>" #'dired-unmark-backward
|
2018-12-13 15:40:53 -05:00
|
|
|
:n [remap undo] #'dired-undo
|
|
|
|
:n [remap advertised-undo] #'dired-undo
|
2018-05-31 13:10:34 +02:00
|
|
|
;; thumbnail manipulation (image-dired)
|
|
|
|
:n "C-t d" #'image-dired-display-thumbs
|
|
|
|
:n "C-t t" #'image-dired-tag-files
|
|
|
|
:n "C-t r" #'image-dired-delete-tag
|
|
|
|
:n "C-t j" #'image-dired-jump-thumbnail-buffer
|
|
|
|
:n "C-t i" #'image-dired-dired-display-image
|
|
|
|
:n "C-t x" #'image-dired-dired-display-external
|
|
|
|
:n "C-t a" #'image-dired-display-thumbs-append
|
|
|
|
:n "C-t ." #'image-dired-display-thumb
|
|
|
|
:n "C-t c" #'image-dired-dired-comment-files
|
|
|
|
:n "C-t f" #'image-dired-mark-tagged-files
|
|
|
|
:n "C-t C-t" #'image-dired-dired-toggle-marked-thumbs
|
|
|
|
:n "C-t e" #'image-dired-dired-edit-comment-and-tags
|
|
|
|
;; encryption and decryption (epa-dired)
|
|
|
|
:n ";d" #'epa-dired-do-decrypt
|
|
|
|
:n ";v" #'epa-dired-do-verify
|
|
|
|
:n ";s" #'epa-dired-do-sign
|
|
|
|
:n ";e" #'epa-dired-do-encrypt)
|