evil-collection/evil-collection-dired.el

192 lines
6.6 KiB
EmacsLisp
Raw Normal View History

2017-12-07 02:41:09 +01:00
;;; evil-collection-dired.el --- Evil bindings for Dired -*- lexical-binding: t -*-
2017-11-05 18:02:29 +01:00
;; Copyright (C) 2017 James Nguyen
;; Author: James Nguyen <james@jojojames.com>
;; Maintainer: James Nguyen <james@jojojames.com>
2018-08-27 10:41:51 +02:00
;; Pierre Neidhardt <mail@ambrevar.xyz>
2018-03-02 02:22:38 +01:00
;; URL: https://github.com/emacs-evil/evil-collection
2017-11-05 18:02:29 +01:00
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, dired, tools
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Evil bindings for Dired.
2017-11-05 18:02:29 +01:00
;;; Code:
(require 'dired)
(require 'evil-collection)
2017-11-05 18:02:29 +01:00
(defconst evil-collection-dired-maps '(dired-mode-map))
;;;###autoload
2017-12-07 02:41:09 +01:00
(defun evil-collection-dired-setup ()
"Set up `evil' bindings for `dired'."
(evil-collection-define-key 'normal 'dired-mode-map
2017-11-29 00:16:18 +01:00
"q" 'quit-window
"j" 'dired-next-line
"k" 'dired-previous-line
2017-11-05 18:02:29 +01:00
[mouse-2] 'dired-mouse-find-file-other-window
[follow-link] 'mouse-face
;; Commands to mark or flag certain categories of files
"#" 'dired-flag-auto-save-files
"." 'dired-clean-directory
"~" 'dired-flag-backup-files
;; Upper case keys (except !) for operating on the marked files
"A" 'dired-do-find-regexp
"C" 'dired-do-copy
"B" 'dired-do-byte-compile
"D" 'dired-do-delete
2017-11-28 19:54:21 +01:00
"gG" 'dired-do-chgrp ;; FIXME: This can probably live on a better binding.
2017-11-05 18:02:29 +01:00
"H" 'dired-do-hardlink
"L" 'dired-do-load
"M" 'dired-do-chmod
"O" 'dired-do-chown
"P" 'dired-do-print
"Q" 'dired-do-find-regexp-and-replace
"R" 'dired-do-rename
"S" 'dired-do-symlink
"T" 'dired-do-touch
"X" 'dired-do-shell-command
"Z" 'dired-do-compress
"c" 'dired-do-compress-to
"!" 'dired-do-shell-command
"&" 'dired-do-async-shell-command
;; Comparison commands
"=" 'dired-diff
;; Tree Dired commands
2017-11-23 14:27:28 +01:00
(kbd "M-C-?") 'dired-unmark-all-files
(kbd "M-C-d") 'dired-tree-down
(kbd "M-C-u") 'dired-tree-up
(kbd "M-C-n") 'dired-next-subdir
(kbd "M-C-p") 'dired-prev-subdir
2017-11-05 18:02:29 +01:00
;; move to marked files
2017-11-23 14:27:28 +01:00
(kbd "M-{") 'dired-prev-marked-file
(kbd "M-}") 'dired-next-marked-file
2017-11-05 18:02:29 +01:00
;; 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.
"%" nil
"%u" 'dired-upcase
"%l" 'dired-downcase
"%d" 'dired-flag-files-regexp
"%g" 'dired-mark-files-containing-regexp
"%m" 'dired-mark-files-regexp
"%r" 'dired-do-rename-regexp
"%C" 'dired-do-copy-regexp
"%H" 'dired-do-hardlink-regexp
"%R" 'dired-do-rename-regexp
"%S" 'dired-do-symlink-regexp
"%&" 'dired-flag-garbage-files
2017-11-23 14:27:28 +01:00
;; mark
2017-11-05 18:02:29 +01:00
"*" nil
"**" 'dired-mark-executables
"*/" 'dired-mark-directories
"*@" 'dired-mark-symlinks
"*%" 'dired-mark-files-regexp
2018-04-15 18:10:46 +02:00
"*(" 'dired-mark-sexp
"*." 'dired-mark-extension
"*O" 'dired-mark-omitted
2017-11-05 18:02:29 +01:00
"*c" 'dired-change-marks
"*s" 'dired-mark-subdir-files
"*m" 'dired-mark
"*u" 'dired-unmark
"*?" 'dired-unmark-all-files
"*!" 'dired-unmark-all-marks
"U" 'dired-unmark-all-marks
2017-11-23 14:27:28 +01:00
(kbd "* <delete>") 'dired-unmark-backward
(kbd "* C-n") 'dired-next-marked-file
(kbd "* C-p") 'dired-prev-marked-file
2017-11-05 18:02:29 +01:00
"*t" 'dired-toggle-marks
;; Lower keys for commands not operating on all the marked files
"a" 'dired-find-alternate-file
"d" 'dired-flag-file-deletion
2017-11-28 19:54:21 +01:00
"gf" 'dired-find-file
2017-11-23 14:27:28 +01:00
(kbd "C-m") 'dired-find-file
2017-11-05 18:02:29 +01:00
"gr" 'revert-buffer
2018-03-31 04:11:19 +02:00
"i" 'dired-toggle-read-only
"I" 'dired-maybe-insert-subdir
2017-11-05 18:02:29 +01:00
"J" 'dired-goto-file
"K" 'dired-do-kill-lines
"r" 'dired-do-redisplay
"m" 'dired-mark
"t" 'dired-toggle-marks
2018-02-02 02:12:44 +01:00
"u" 'dired-unmark ; also "*u"
2017-11-05 18:02:29 +01:00
"W" 'browse-url-of-dired-file
"x" 'dired-do-flagged-delete
2017-11-28 19:54:21 +01:00
"gy" 'dired-show-file-type ;; FIXME: This could probably go on a better key.
"Y" 'dired-copy-filename-as-kill
2017-11-05 18:02:29 +01:00
"+" 'dired-create-directory
;; open
2017-11-28 19:54:21 +01:00
(kbd "<return>") 'dired-find-file
(kbd "S-<return>") 'dired-find-file-other-window
(kbd "M-<return>") 'dired-display-file
2018-01-06 18:38:11 +01:00
"gO" 'dired-find-file-other-window
"go" 'dired-view-file
2017-11-23 14:27:28 +01:00
;; sort
"o" 'dired-sort-toggle-or-edit
2017-11-05 18:02:29 +01:00
;; moving
2018-02-02 02:12:44 +01:00
"gj" 'dired-next-dirline
"gk" 'dired-prev-dirline
2019-03-16 18:54:12 +01:00
"[[" 'dired-prev-dirline
"]]" 'dired-next-dirline
2017-11-05 18:02:29 +01:00
"<" 'dired-prev-dirline
">" 'dired-next-dirline
"^" 'dired-up-directory
" " 'dired-next-line
[?\S-\ ] 'dired-previous-line
[remap next-line] 'dired-next-line
[remap previous-line] 'dired-previous-line
;; hiding
2017-11-28 19:54:21 +01:00
"g$" 'dired-hide-subdir ;; FIXME: This can probably live on a better binding.
2017-11-23 14:27:28 +01:00
(kbd "M-$") 'dired-hide-all
2017-11-05 18:02:29 +01:00
"(" 'dired-hide-details-mode
;; isearch
(kbd "M-s a C-s") 'dired-do-isearch
(kbd "M-s a M-C-s") 'dired-do-isearch-regexp
(kbd "M-s f C-s") 'dired-isearch-filenames
(kbd "M-s f M-C-s") 'dired-isearch-filenames-regexp
;; misc
[remap read-only-mode] 'dired-toggle-read-only
;; `toggle-read-only' is an obsolete alias for `read-only-mode'
[remap toggle-read-only] 'dired-toggle-read-only
2017-11-23 14:27:46 +01:00
"g?" 'dired-summary
2017-11-23 14:27:28 +01:00
(kbd "<delete>") 'dired-unmark-backward
2017-11-05 18:02:29 +01:00
[remap undo] 'dired-undo
[remap advertised-undo] 'dired-undo
;; thumbnail manipulation (image-dired)
2017-11-23 14:27:28 +01:00
(kbd "C-t d") 'image-dired-display-thumbs
(kbd "C-t t") 'image-dired-tag-files
(kbd "C-t r") 'image-dired-delete-tag
(kbd "C-t j") 'image-dired-jump-thumbnail-buffer
(kbd "C-t i") 'image-dired-dired-display-image
(kbd "C-t x") 'image-dired-dired-display-external
(kbd "C-t a") 'image-dired-display-thumbs-append
(kbd "C-t .") 'image-dired-display-thumb
(kbd "C-t c") 'image-dired-dired-comment-files
(kbd "C-t f") 'image-dired-mark-tagged-files
(kbd "C-t C-t") 'image-dired-dired-toggle-marked-thumbs
(kbd "C-t e") 'image-dired-dired-edit-comment-and-tags
2017-11-05 18:02:29 +01:00
;; encryption and decryption (epa-dired)
";d" 'epa-dired-do-decrypt
";v" 'epa-dired-do-verify
";s" 'epa-dired-do-sign
";e" 'epa-dired-do-encrypt))
2017-12-07 02:41:09 +01:00
(provide 'evil-collection-dired)
;;; evil-collection-dired.el ends here