;; .emacs - Emacs Configuration File ;; Author: Sean B. Palmer, inamidst.com ;; Backup and Auto Save (if (not (file-exists-p "~/.emacs.d/backups")) (make-directory "~/.emacs.d/backups" t)) (setq backup-directory-alist '(("." . "~/.emacs.d/backups"))) (setq backup-by-copying t) (setq auto-save-default nil) ;; Options (global-font-lock-mode 0) (setq inhibit-startup-message t) (setq require-final-newline 'ask) (setq blink-matching-paren nil) (setq default-major-mode 'text-mode) (setq default-fill-column 79) (add-hook 'text-mode-hook 'turn-on-auto-fill) (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) ;; Font Styles (set-face-attribute 'isearch nil :foreground "White" :background "Black" :underline t) (set-face-attribute 'isearch-lazy-highlight-face nil :foreground "White" :background "Black" :underline t) (set-face-attribute 'minibuffer-prompt nil :foreground "White" :background "Black") ;; Key Bindings (defun my-kill-whole-line () "Kill an entire line, including trailing newline" (interactive) (beginning-of-line) (kill-line 1)) (defun my-move-line-up () "Move the current line up one." (interactive) (if (> (count-lines 1 (point)) 0) (let ((my-prev-column (current-column))) (progn (transpose-lines 1) (forward-line -2) (move-to-column my-prev-column))))) (defun my-move-line-down () "Move the current line down one." (interactive) (if (< (count-lines 1 (point)) (1- (count-lines 1 (point-max)))) (let ((my-prev-column (current-column))) (progn (forward-line) (transpose-lines 1) (forward-line -1) (move-to-column my-prev-column))))) (global-set-key "\C-k" 'my-kill-whole-line) (global-set-key "\C-h" 'my-move-line-up) (global-set-key "\C-n" 'my-move-line-down) (global-set-key "\C-cl" 'goto-line) (global-set-key "\C-v" 'yank) (global-set-key "\C-z" 'undo) ;; Mode Line (defun my-fixed (filename n) "Return a possibly pre-truncated buffer filename." (if (> (length filename) n) (concat "..." (substring filename (- 0 (- n 3)))) filename)) (defun my-mode-line-padding (n) (- (frame-width) (length (format-mode-line "Line %l, Pos %c (%m)")) n)) (setq default-mode-line-format (list " GNU Emacs " '(:eval (if (buffer-modified-p) "-" "=")) "> " '(32 (:eval (my-fixed (abbreviate-file-name (buffer-file-name)) 32))) '(:eval (make-string (my-mode-line-padding 48) ?\ )) " Line %l, Pos %c (%m) ")) ;; Save Message (defun my-save-message () (message (concat "Saved " (number-to-string (buffer-size)) " bytes to " (abbreviate-file-name (buffer-file-name)) "..."))) (add-hook 'after-save-hook 'my-save-message)