forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-dired.el
50 lines (38 loc) · 1.51 KB
/
setup-dired.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(require 'dired)
;; Make dired less verbose
(require 'dired-details)
(setq-default dired-details-hidden-string "--- ")
(dired-details-install)
;; Reload dired after creating a directory
(defadvice dired-create-directory (after revert-buffer-after-create activate)
(revert-buffer))
;; Reload dired after quitting wdired
(defadvice wdired-abort-changes (after revert-buffer-after-abort activate)
(revert-buffer))
;; C-a is nicer in dired if it moves back to start of files
(defun dired-back-to-start-of-files ()
(interactive)
(backward-char (- (current-column) 2)))
(define-key dired-mode-map (kbd "C-a") 'dired-back-to-start-of-files)
;; M-up is nicer in dired if it moves to the third line - straight to the ".."
(defun dired-back-to-top ()
(interactive)
(beginning-of-buffer)
(next-line 2)
(dired-back-to-start-of-files))
(define-key dired-mode-map (kbd "M-<up>") 'dired-back-to-top)
;; M-down is nicer in dired if it moves to the last file
(defun dired-jump-to-bottom ()
(interactive)
(end-of-buffer)
(next-line -1)
(dired-back-to-start-of-files))
(define-key dired-mode-map (kbd "M-<down>") 'dired-jump-to-bottom)
;; Delete with C-x C-k to match file buffers and magit
(define-key dired-mode-map (kbd "C-x C-k") 'dired-do-delete)
(eval-after-load "wdired"
'(progn
(define-key wdired-mode-map (kbd "C-a") 'dired-back-to-start-of-files)
(define-key wdired-mode-map (kbd "M-<up>") 'dired-back-to-top)
(define-key wdired-mode-map (kbd "M-<down>") 'dired-jump-to-bottom)))
(provide 'setup-dired)