;; Chuan's emacs customization file for Ubuntu
;; Last modified: 2011


;; The following modes are installed using Ubuntu package manager:
;;
;;   slime
;;

;; The following modes are installed by 'emacs-goodies-el' package
;;
;;   htmlize
;;   xrdb-mode
;;   browse-kill-ring
;;   matlab
;;   

;; Some other modes maintained on my own:
;;
;;


;;; add load-path
;;; several single file modes put direct under the path
(setq load-path (cons "~/.emacs.d/site-lisp" load-path))

;;; set default encoding and language enviroment to utf-8
(prefer-coding-system 'utf-8)
(set-language-environment 'utf-8)

;; show line and column number
(line-number-mode t)
(column-number-mode t)

;;; set short key for undo
(global-set-key [(ctrl backspace)] 'undo)

;;; ido mode for buffer switch and find file
(require 'ido)
(ido-mode t)

;;; anything.el: QuickSilver for Emacs
(require 'linkd)
(require 'anything)

;;; brower kill ring
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)

;;; spell checking on fly
(require 'flyspell)
(add-to-list 'auto-mode-alist '("\\.txt$" . flyspell-mode))
(add-hook 'LaTeX-mode-hook 'flyspell-mode)

;;; cperl-mode is preferred to perl-mode
(mapc
 (lambda (pair)
   (if (eq (cdr pair) 'perl-mode)
       (setcdr pair 'cperl-mode)))
 (append auto-mode-alist interpreter-mode-alist))

;;; cc-mode
(require 'cc-mode)

;;; slime
(require 'slime)
(slime-setup)


;;; org-mode
(setq load-path (cons "~/.emacs.d/site-lisp/org-mode/lisp" load-path))
(setq load-path (cons "~/.emacs.d/site-lisp/org-mode/contrib/lisp" load-path))
(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(org-remember-insinuate)
(setq org-directory "~/notes")
(setq org-default-notes-file (concat org-directory "/default.org"))
(define-key global-map "\C-cr" 'org-remember)
(setq org-export-with-LaTeX-fragments t)
(setq org-remember-templates '((?b "* TODO READ: %?%a\n")))
(setq org-agenda-exporter-settings
      '((ps-number-of-columns 2)
        (ps-landscape-mode t)
        (htmlize-output-type 'css)))


;;; other misc. variables in  Emacs
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(c-basic-offset 2)
 '(default-input-method "chinese-tonepy-punct")
 '(flyspell-sort-corrections t)
 '(indent-tabs-mode nil)
 '(inferior-lisp-program "/usr/bin/sbcl")
 '(make-backup-files nil)
 '(nil nil t)
 '(tab-width 2)
 '(truncate-lines t)
 '(truncate-partial-width-windows t)
 '(warning-suppress-types (quote ((\(undo\ discard-info\))))))


(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )