.emacs

A friend of mine, John Steele Scott, once wrote, ‘When you're a long way from home, the last thing you want to do is recreate your .emacs file.’ With that in mind, here's my .emacs file:

; turn column number mode on
(setq column-number-mode t)

(set-face-background 'default "white")
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )
(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 "white" :foreground "#000000" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 160 :width normal :family "adobe-courier")))))

;; php-mode
(autoload 'php-mode "php-mode" "Mode for editing PHP source files")
(add-to-list 'auto-mode-alist '("\\.\\(inc\\|php[s34]?\\)" . php-mode))

;; nxml-mode
(load "/usr/local/share/emacs/site-lisp/nxml-mode/rng-auto.el")
(setq auto-mode-alist
      (cons '("\\.\\(xml\\|xsl\\|rng\\|html\\|xhtml\\|jspx\\)\\'" . nxml-mode)
	    auto-mode-alist))
(custom-set-variables
 '(nxml-slash-auto-complete-flag t))

; ris.el
(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)))
;; ris mode
(autoload 'ris-mode "ris" "Major mode for RIS bibliography files." t)
(or (assoc "\\.ris$" auto-mode-alist)
    (setq auto-mode-alist (cons '("\\.ris$" . ris-mode)
                                auto-mode-alist)))


; unicode
;; xmlunicode.el uses caddr, but neither it nor Emacs(!) defines it.
(defun caddr (x)
(car (cdr (cdr x))))

(defun my-nxml-mode-hook ()
(setq ispell-skip-html t)
(set-language-environment "utf-8")
(load "~/unichars.el")
(load "~/xmlunicode.el")
(define-key nxml-mode-map "-" 'unicode-smart-hyphen)
(define-key nxml-mode-map "." 'unicode-smart-period)
(set-input-method 'xml))

(add-hook 'nxml-mode-hook 'my-nxml-mode-hook)

; CSS mode
(autoload 'css-mode "css-mode")
(setq auto-mode-alist
     (cons '("\\.css\\'" . css-mode) auto-mode-alist))
(setq cssm-indent-function #'cssm-c-style-indenter)

; lua-mode
(autoload 'lua-mode "lua-mode" "Mode for editing Lua source files")
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))

;; Taken from the comment section in inf-ruby.el
(setq ruby-program-name "/usr/local/bin/ruby")
(autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files")
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
(autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook '(lambda () (inf-ruby-keys)))

;; multi-mode for JSP
(require 'multi-mode)
(defun jsp-mode () (interactive)
  (multi-mode 1
	      'html-mode
	      '("<%--" indented-text-mode)
	      '("<%@" indented-text-mode)
	      '("<%=" html-mode)
	      '("<%" java-mode)
	      '("%>" html-mode)))

;; for nxml-mode
(defun surround-region-with-tag (tag-name beg end)
       (interactive "sTag name: \nr")
       (save-excursion
         (goto-char beg)
         (insert "<" tag-name ">")
         (goto-char (+ end 2 (length tag-name)))
         (insert "</" tag-name ">")))