Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

76 lines (59 sloc) 2.365 kb
;; I want this for dired-jump
(require 'dired-x)
;; I usually want to see just the file names
(require 'dired-details)
(dired-details-install)
;; 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-mode t)
;; List directories first
(defun sof/dired-sort ()
"Dired sort hook to list directories first."
(save-excursion
(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 ()
(interactive)
(beginning-of-buffer)
(next-line 2))
(define-key dired-mode-map
(vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
(defun dired-jump-to-bottom ()
(interactive)
(end-of-buffer)
(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 ()
(interactive)
(backward-char (- (current-column) 2)))
(define-key dired-mode-map (kbd "C-a") 'dired-back-to-start-of-files)
(provide 'my-dired)
Jump to Line
Something went wrong with that request. Please try again.