Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (60 sloc) 2.4 KB
;; I want this for dired-jump
(require 'dired-x)
;; I usually want to see just the file names
(require 'dired-details)
;; Nice listing
(setq find-ls-option '("-print0 | xargs -0 ls -alhd" . ""))
;; Always copy/delete recursively
(setq dired-recursive-copies (quote always))
(setq dired-recursive-deletes (quote top))
;; Auto refresh dired, but be quiet about it
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose nil)
;; Hide some files
;;(setq dired-omit-files "^\\..*$\\|^\\.\\.$")
(setq dired-omit-files "^\\.pdf$\\|\\.git$\\|\\.DS_Store$")
(add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1)))
;; List directories first
(defun sof/dired-sort ()
"Dired sort hook to list directories first."
(let (buffer-read-only)
(forward-line 2) ;; beyond dir. header
(sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max))))
(and (featurep 'xemacs)
(fboundp 'dired-insert-set-properties)
(dired-insert-set-properties (point-min) (point-max)))
(set-buffer-modified-p nil))
(add-hook 'dired-after-readin-hook 'sof/dired-sort)
;; Automatically create missing directories when creating new files
(defun my-create-non-existent-directory ()
(let ((parent-directory (file-name-directory buffer-file-name)))
(when (and (not (file-exists-p parent-directory))
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
(make-directory parent-directory t))))
(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory)
;; Use ls from emacs
(when (eq system-type 'darwin)
(require 'ls-lisp)
(setq ls-lisp-use-insert-directory-program nil))
;; Changing the way M-< and M-> work in dired
;; Instead of taking me to the very beginning or very end, they now take me to the first or last file.
(defun dired-back-to-top ()
(next-line 2))
(define-key dired-mode-map
(vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
(defun dired-jump-to-bottom ()
(next-line -1))
(define-key dired-mode-map
(vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)
;; C-a is nicer in dired if it moves back to start of files
(defun dired-back-to-start-of-files ()
(backward-char (- (current-column) 2)))
(define-key dired-mode-map (kbd "C-a") 'dired-back-to-start-of-files)
(provide 'my-dired)