Emacs Dot File

Emacs Init File

Here's a copy of my minimal dot.emacs file.

;
; Patrick's .emacs init file
; 2009-12-18
;

; Tell Emacs where elisp .el files reside then load-path
; (add-to-list 'load-path "~/.elisp")
; (add-to-list 'load-path "~/pager.el")

; Get rid of startup message
(setq inhibit-startup-message t)

; Scrap initial scratch message
; (setq initial-scratch-message nil)

(when window-system
(mwheel-install) ; Enable mousewheel support
(tool-bar-mode nil) ; Get rid of the toolbar
(menu-bar-mode nil) ; Get rid of the menu bar
(scroll-bar-mode nil)) ; Get rid of the scroll bar
; (set-scroll-bar-mode 'right) ; Set scroll bar on right
; Set initial window size
(setq initial-frame-plist '(top 0 left 0 width 300 height 300))

; Enable line number in mode line
(line-number-mode 1)

; Show column number on mode line
(column-number-mode t)

; Display time on mode line
(display-time)

; Display 24-hour format
(setq display-time-24hr-format t)

; Disable blinking cursor
(blink-cursor-mode nil)

; Color settings to make Emacs look pretty
(set-background-color "white")
(set-foreground-color "black")
;(set-background-color "#dfdfdf")
(set-face-background 'modeline "#4377B6")
(set-face-foreground 'modeline "#FFFFFF")
(set-face-background 'region "orangered")
(set-face-background 'highlight "white")
(set-cursor-color "blue")

; Set default font to Consolas
(set-default-font
"-outline-Consolas-normal-r-normal-normal-13-99-96-96-c-*-iso8859-1")

; Disable beep. Flash on error
(setq visible-bell t)

; Highlight incremental search
(setq search-highlight t)

; Highlight fonts - M-x describe-mode font-lock-mode for info
(global-font-lock-mode t)

; Highlight Parenthesis
(show-paren-mode t)
;(setq blink-matching-paren t)

; Typed text replace highlighted
(delete-selection-mode t)

; Color selected region
(setq-default transient-mark-mode t)

; Highlight during query
(setq query-replace-highlight t)

; Scroll faster
(setq lazy-lock-defer-on-scrolling t)

; Disable scroll jump
(setq scroll-step 1)

; Make y and yes both work
(fset 'yes-or-no-p 'y-or-n-p)

; End file with a newline
(setq require-final-newline t)

; Use spaces instead of tabs
(setq-default indent-tabs-mode nil)

; Spaces instead tabs
(setq default-tab-width 4);

; M-g runs the goto-line function.
(global-set-key "\M-g" 'goto-line)

; Delete auto-save files
; (setq delete-auto-save-files t)

; Disable file backup
(setq make-backup-files nil)

; Disable file saves
;(setq auto-save-list-file-name nil)

; Ctrl-h to delete left instead of help
(keyboard-translate ?\C-h ?\C-?)


; *********************************************
; Following from Steve Yegge's blog on Emacs
; Used some ideas and suggestions
; *********************************************

; Invoke M-x without Alt Key
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)

; Ctrl-w replace <-Backspace for backward delete
; C-w normally deletes whole region now reset to C-x C-k
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)

; Alt-n & Alt-p for page scrolling
(global-set-key "\C-[p" 'down-one)
(global-set-key "\C-[n" 'up-one)

; Re-Map M-<>
(global-set-key (kbd "C-x t") 'beginning-of-buffer)

; Re-Map M-> to Ctrl-x e
(global-set-key (kbd "C-x e") 'end-of-buffer)

; Steve Yegge entries end *********************


; *********************************************
; Word Count Function ; 'count-words-buffer
; Source: Programming in Emacs Lisp tutorial
; http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/recursive_count_words.html#recursive_count_words
; Source: Tutorial Contents Page
; http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/

; Final version: while
(defun count-words-region (beginning end)
"Print number of words in the region."
(interactive "r")
(message "Counting words in region ... ")

; 1. Set up appropriate conditions.
(save-excursion
(let ((count 0))
(goto-char beginning)

; 2. Run the while loop.
(while (and (< (point) end)
(re-search-forward "\\w+\\W*" end t))
(setq count (1+ count)))

; 3. Send a message to the user.
(cond ((zerop count)
(message
"The region does NOT have any words."))
((= 1 count)
(message
"The region has 1 word."))
(t
(message
"The region has %d words." count))))))

; Count the words in the entire document
(defun count-words-buffer ()
"Count all the words in the buffer"
(interactive)
(count-words-region (point-min) (point-max) )
)

; Bind count-words-buffer to Ctrl-c Ctrl-c
(global-set-key "\C-c\C-c" 'count-words-buffer)

; End of Word Count function
; *********************************************

; End of file.