;;;; Emacs initilization file for CS students at Suffield Academy ;;;; Crufted up by Jason Healy (jhealy) ;;;; $Id$ ;;; Global Variables ;; Set the debug option to enable a backtrace when a ;; problem occurs. (use for debugging .emacs and others) ;(setq debug-on-error t) ;; Get rid of the splash screen (setq inhibit-startup-message t) ;; Set the load path to include any locally installed lisp files ;(setq load-path (cons "~/.emacs.d/elisp/" load-path)) ;; Use UTF-8 by default for encoding (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8) ;;; Emacs Appearance Customization ;; Custom Variables (custom-set-variables) ;; Custom syntax coloring (M-x list-colors-display for possible choices) ;; We use terminal-compatible colors for maximum flexibility ;; Default Colors (set-foreground-color "white") (set-background-color "black") (set-face-foreground 'modeline "white") (set-face-background 'modeline "blue") (set-cursor-color "red") (custom-set-faces ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(default ((t (:stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 1 :width normal :family "default")))) '(bold-italic ((t (:underline t :slant italic :weight bold)))) '(font-lock-builtin-face ((((type tty) (class color)) (:foreground "blue" :weight bold)))) '(font-lock-constant-face ((((type tty) (class color)) (:foreground "green" :underline t)))) '(font-lock-doc-face ((t (:inherit font-lock-comment-face)))) '(font-lock-function-name-face ((((type tty) (class color)) (:foreground "yellow" :underline t)))) '(font-lock-keyword-face ((((type tty) (class color)) (:foreground "cyan")))) '(font-lock-string-face ((((type tty) (class color)) (:foreground "magenta")))) '(font-lock-type-face ((((type tty) (class color)) (:foreground "green")))) '(font-lock-warning-face ((((type tty) (class color)) (:foreground "red" :weight bold)))) '(highlight ((((type tty) (class color)) (:foreground "black" :background "green")))) '(italic ((t (:underline t :slant italic)))) '(menu ((((type tty)) (:background "black" :foreground "red" :weight bold)))) '(mode-line ((t (:background "blue" :foreground "white")))) '(nxml-comment-content-face ((t (:inherit font-lock-comment-face)))) '(nxml-comment-delimiter-face ((t (:inherit font-lock-comment-face)))) '(nxml-delimited-data-face ((((class color) (background dark)) (:inherit font-lock-keyword-face)))) '(nxml-delimiter-face ((((class color) (background dark)) (:inherit font-lock-variable-name-face)))) '(nxml-name-face ((((class color) (background dark)) (:inherit font-lock-type-face)))) '(nxml-processing-instruction-delimiter-face ((t (:foreground "magenta")))) '(nxml-processing-instruction-target-face ((t (:inherit nxml-processing-instruction-delimiter-face)))) '(nxml-ref-face ((((class color) (background dark)) (:inherit font-lock-builtin-face)))) '(region ((((type tty) (class color)) (:background "blue" :foreground "black")))) '(secondary-selection ((((type tty) (class color)) (:background "cyan" :foreground "black")))) '(show-paren-match-face ((((class color)) (:background "blue" :foreground "yellow")))) '(show-paren-mismatch-face ((((class color)) (:background "blue" :foreground "red")))) '(vhdl-font-lock-translate-off-face ((((class color) (background dark)) (:background "magenta" :foreground "white"))))) ;; Frame title ; Set the frame's title. %b is the name of the buffer. %+ indicates ; the state of the buffer: * if modified, % if read only, or - ; otherwise. Two of them to emulate the mode line. %f for the file name (setq frame-title-format "Emacs: %b %f") ;; Highlight transients (setq-default transient-mark-mode t) ; (setq-default mark-even-if-inactive nil) ;; Allow user to overwrite selected text (rather than clearing selection ;; and writing at the current point). More like mac/windows editing. (delete-selection-mode t) ;; Show line and column numbers (line-number-mode t) (column-number-mode t) ;; Set font decoration in major modes (cond ((fboundp 'global-font-lock-mode) ;; Turn on font-lock in all modes that support it (global-font-lock-mode t) ;; Maximum colors (setq font-lock-maximum-decoration t))) ;;; Behavior ;; Do not make backups of Version Controlled files (setq vc-make-backup-files nil) ;; Turn off empty lines at EOF (setq next-line-add-newlines nil) ;; auto-word-wrap long lines in certain modes: (add-hook 'text-mode-hook 'turn-on-auto-fill) (add-hook 'latex-mode-hook 'turn-on-auto-fill) (add-hook 'html-mode-hook 'turn-on-auto-fill) ;; Set text mode as the default (setq default-major-mode 'text-mode) ;; Make minibuffer larger if there is more to see (resize-minibuffer-mode 1) ;; provide a list of buffers that shrinks as you type the name (iswitchb-default-keybindings) ;; Tab code thanks to JWZ: http://www.jwz.org/doc/tabs-vs-spaces.html ;; Auto expand tabs to spaces, at modulo 4 (setq tab-width 4) (setq indent-tabs-mode nil) ; Set CPerl as the default Perl editing mode (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode)) ;; Automatically decompress binary plist files on Mac OS X (setq auto-mode-alist (cons '("\\.\\(plist\\)\\'" . simple-plist-hack) auto-mode-alist)) ;; plutil -convert binary1 xxx.plist to go back, not sure how (defun simple-plist-hack () (when (string-match "`bplist" (buffer-string)) (shell-command-on-region (point-min) (point-max) (format "/usr/bin/plutil -convert xml1 -o /dev/stdout %s" (shell-quote-argument (buffer-file-name))) t t)) (set-buffer-modified-p nil) (nxml-mode)) ;; replace this if you have xml-mode installed ;; Make Emacs understand Jakarta-Ant output (require 'compile) (setq compilation-error-regexp-alist (append (list '("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):" 1 2)) compilation-error-regexp-alist)) ;; On file write, expand all tabs to spaces (defun text-mode-untabify () (save-excursion (goto-char (point-min)) (while (re-search-forward "[ \t]+$" nil t) (delete-region (match-beginning 0) (match-end 0))) (goto-char (point-min)) (if (search-forward "\t" nil t) (untabify (1- (point)) (point-max)))) nil) (add-hook 'java-mode-hook '(lambda () (make-local-variable 'write-contents-hooks) (add-hook 'write-contents-hooks 'text-mode-untabify))) ;; Function to indent whole buffer (defun indent-whole-buffer() "Indent whole buffer (using indent-region)." (interactive) (normal-mode) (save-excursion (mark-whole-buffer) (call-interactively 'indent-region)) (message "%s" "Indented whole buffer.")) ;;; Code Prototypes ;; Insert a Java method (defun insert-java-method (java-method-name) "Inserts a java method" (interactive "sPlease enter a name for the new method: ") (let ((insert-begin (point))) (insert "\n" "\t/**\n" "\t *
\n" "\t * Description\n" "\t *
\n" "\t *\n" "\t * @param name\n" "\t * @param name\n" "\t * @param name\n" "\t *\n" "\t * @return type\n" "\t *\n" "\t * @throws type\n" "\t */\n" "\tprotected abstract void " java-method-name "() {\n" "\n" "\t\t// Method " java-method-name " goes here\n" "\n" "\t}\n" "\n") (indent-region insert-begin (point) nil)) (message "Inserted java method %s" java-method-name)) ;; Insert a Perl subroutine (defun insert-perl-sub (perl-subroutine-name) "Inserts a perl subroutine skeleton" (interactive "sPlease enter a name for the new subroutine: ") (let ((insert-begin (point))) (insert "\n" "=head2 " perl-subroutine-name "() [returns I