While Emacs being a platform of everything, needless to see it can do file management well. Among them dired is the standard package.
Here are some useful settings
;; Setup dired to let you nicely copy stuff inbetween two dired
;; windows.
(setq dired-dwim-target t)
;; delete un-empty directories recursivly without warning
(setq dired-recursive-deletes ‘always)
;; recursive copy without prompt
(setq dired-recursive-copies ‘always)
and some extra settings from the standard package:
(require ‘dired-aux)
;; dired-x
(require ‘dired-x)
This defines what happens when I press X on a file in the dired buffer
(list
‘("\\.jpg$" "xv")
‘("\\.JPG$" "xv")
‘("\\.jpeg$" "xv")
‘("\\.JPEG$" "xv")
‘("\\.p[bgpn]m$" "xv")
‘("\\.gif$" "xv")
‘("\\.tif$" "xv")
))
By default, when you press X, the Emacs opens a garbage buffer and wait for the external program to exit. I don’t like it.
(defun my-start-process-shell-command (cmd)
"Don’t create a separate output buffer."
(start-process-shell-command cmd nil cmd))
;; redefine this function to disable output buffer.
(defun dired-run-shell-command (command)
(let ((handler
(find-file-name-handler (directory-file-name default-directory)
’shell-command)))
(if handler (apply handler ’shell-command (list command))
(my-start-process-shell-command command)))
;; Return nil for sake of nconc in dired-bunch-files.
nil)
And this defines how the dired buffer is displayed:
(setq ls-lisp-use-insert-directory-program nil)
;; sort the dired buffer to place the directories on top (t)
(setq ls-lisp-dirs-first t)
;; sort without regard to case (t)
(setq ls-lisp-ignore-case t)
;; for windows?
;; (setq ls-lisp-use-insert-directory-program t)
;; I like the GNU way of dir display (links uid gid)
(setq ls-lisp-verbosity ‘(links uid gid))
wdired, also in the official package, allow us to change file name in the dired buffer as in an ordinary buffer
(define-key dired-mode-map "r" ‘wdired-change-to-wdired-mode)
very useful with gse-number-rect.el when renaming many files like mp3.
(autoload ‘gse-number-rectangle "gse-number-rect"
"inserts incremental numbers in the rectangle." t)
(global-set-key "\C-xru" ‘gse-number-rectangle)
And I don’t like many dired buffer spread around:
(require ‘dired-single)
(defun my-dired-init ()
"Bunch of stuff to run for dired, either immediately or when it’s
loaded."
;; <add other stuff here>
(define-key dired-mode-map [return] ‘joc-dired-single-buffer)
(define-key dired-mode-map [mouse-1] ‘joc-dired-single-buffer-mouse)
(define-key dired-mode-map "^"
(function
(lambda nil (interactive) (joc-dired-single-buffer "..")))))
;; if dired’s already loaded, then the keymap will be bound
(if (boundp ‘dired-mode-map)
;; we’re good to go; just add our bindings
(my-dired-init)
;; it’s not loaded yet, so add our bindings to the load-hook
(add-hook ‘dired-load-hook ‘my-dired-init))
Also I like dired-sort-map.el very much, with it you can sort the dired buffer by name, time, size, and extension. And someone might like dired-details.el.
Comments 2
Thx!, nice article. I have found dired-sort-map at http://www.emacswiki.org/cgi-bin/wiki/dired-sort-map.el - simple, but usefull, thx again.
Posted 24 Jan 2008 at 9:47 pm ¶Thanks for the link! I’ve updated the blog accordingly. Thanks!
Posted 30 Jan 2008 at 5:29 pm ¶Post a Comment
You could use <code type="name"> to get your code colorized