20080306

Hidden backup files with emacs

Ever since I started using emacs the directories full of `whatever~' files have annoyed me. No more! I put this into my .emacs ( along with a (require 'cl) ) and voila, backups for `whatever' end up in `.whatever~' in the same directory. .emacs? `..emacs~'. Thus when I run ls my directory listing is clean.

;; hidden backup files - i hate seeing them in listings ...                                                                                                                                                       
;; prefix with a dot as well as postfix with a tilde
(defun custom-make-backup-file-name ( file )
(let ((d (file-name-directory file))
(f (file-name-nondirectory file)))
(concat d "." f "~")))
(setq make-backup-file-name-function 'custom-make-backup-file-name)

(defun backup-file-name-p ( file )
(let ((letters (string-to-list (file-name-nondirectory file))))
(and (> 2 (length letters))
(equal "." (first letters))
(equal "~" (last letters)))))

(defun file-name-sans-versions ( file )
(if (not (backup-file-name-p file))
file
(let ((d (file-name-directory file))
(f (file-name-nondirectory file)))
(let ((letters (string-to-list f)))
(concat d (subseq letters 1 (- (length f) 1)))))))


While I'm busy dumping from my .emacs file, I like the truncated lines when I use ( C-x 3 ) to divide the display vertically except when I'm running a shell. Then I want to see everything.

;; do not truncate lines in shell
(add-hook 'shell-mode-hook (lambda () (progn
(make-local-variable 'truncate-partial-width-windows)
(setq truncate-partial-width-windows nil))))

1 comment:

Anonymous said...

I was looking for this. Awesome. Thanks.

About Me

(2) the subculture of the compulsive programmer, whose ethics prescribe that one silly idea and a month of frantic coding should suffice to make him a life-long millionaire. --ewd1036