;; .emacs ;; ;; Adapted from John Glynn ;; ;; Chuan Zhou ;; ;; General Emacs Options ;; ===================== ;; (setq truncate-partial-width-windows nil) (setq indent-tabs-mode nil) (setq enable-recursive-minibuffers t) (setq line-number-mode t) (setq column-number-mode t) (setq find-file-visit-truename t) (setq search-highlight t) (setq query-replace-highlight t) (auto-compression-mode 1) (auto-show-mode 1) (require 'paren) (setq auto-save-list-file-name nil) (setq cast-fold-search t) (setq byte-compile-verbose t) (server-start) (mouse-wheel-mode) (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. '(auto-compression-mode t nil (jka-compr)) '(case-fold-search t) '(current-language-environment "English") '(default-input-method "latin-1-prefix") '(global-font-lock-mode t nil (font-lock)) ;; turn on clorization '(indent-tabs-mode nil) '(save-place t nil (saveplace)) '(show-paren-mode t nil (paren)) '(uniquify-buffer-name-style (quote forward) nil (uniquify))) ;; show matching parenthesis (setq blink-matching-paren t) ;; define function to match a parenthesis otherwise insert a '~' (defun goto-match-paren (arg) "Go to the matching parenthesis if on parenthesis otherwise insert '~'." (interactive "p") (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) ((looking-at "\\s\)") (forward-char 1) (backward-list 1)) (t (self-insert-command (or arg 1))))) (global-set-key (kbd "~") 'goto-match-paren) ;; Fonts ;; ============ ;; (setq font-lock-maximum-decoration t) (add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock) (add-hook 'cc-mode-hook 'turn-on-font-lock) (add-hook 'c-mode-hook 'turn-on-font-lock) (add-hook 'c++-mode-hook 'turn-on-font-lock) (add-hook 'java-mode-hook 'turn-on-font-lock) (add-hook 'sh-mode-hook 'turn-on-font-lock) (add-hook 'shell-script-mode-hook 'turn-on-font-lock) (add-hook 'makefile-mode-hook 'turn-on-font-lock) (add-hook 'perl-mode-hook 'turn-on-font-lock) (add-hook 'xrdb-mode-hook 'turn-on-font-lock) (add-hook 'ps-mode-hook '(lambda () (make-local-variable 'font-lock-support-mode) (make-local-variable 'lazy-lock-defer-on-scrolling) (setq font-lock-support-mode 'lazy-lock-mode lazy-lock-defer-on-scrolling t) (turn-on-font-lock))) (add-hook 'ps-run-mode-hook '(lambda () (turn-on-font-lock))) ;(if window-system (require 'font-latex)) ;(setq tex-dvi-view-command "xdvi") ;(setq tex-dvi-print-command "dvips -f * | lpr") (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (setq reftex-plug-into-AUCTex t) (add-hook 'reftex-load-hook (lambda () (setq reftex-section-levels (cons '("poemtitle" . -3) reftex-section-levels)))) (setq reftex-label-alist '(("\\poemtitle" ?P "poem:" "\\ref{%s}" nil ("poem" "poemtitle")))) ;; Printing Options ;; ================ ;; (defun print-header-func () (concat (ps-time-stamp-locale-default) " : " (ps-header-dirpart))) (setq lpr-command "kprint" lpr-switches nil) (require 'ps-print) (setq ps-print-color-p nil) (setq ps-bold-faces '( font-lock-keyword-face font-lock-function-name-face)) (setq ps-italic-faces '( font-lock-comment-face font-lock-string-face)) (setq ps-spool-duplex t ps-switch-header nil ps-print-header t ps-print-footer nil ps-print-header-frame nil ps-header-offset 5.58001116 ps-header-title-font-size '(10 . 12) ps-header-font-size '(7 . 8.5) ps-header-lines 1 ps-left-header (list 'print-header-func)) (ps-extend-face '(default "black" nil nil) 'MERGE) ;; Window colors ;; ============= ;; (if (eq window-system 'x) (if (x-display-color-p) (progn (set-background-color "#FFFFEEEECCCC") (set-foreground-color "black") (set-face-background 'region "black") (set-face-foreground 'region "#white") (set-face-background 'highlight "black") (set-face-foreground 'highlight "yellow") (set-face-background 'secondary-selection "black") (set-face-foreground 'secondary-selection "white") (set-face-background 'modeline "gold1") (set-face-foreground 'modeline "white") (setq x-pointer-shape x-pointer-left-ptr) (set-cursor-color "red") (set-mouse-color "blue") ))) (setq default-frame-alist (append '((width . 72) (height . 58) (background-color . "black") (foreground-color . "white") (mouse-color . "blue") (cursor-color . "green") ) default-frame-alist)) (setq pop-up-frame-alist '((width . 72) (height . 58) (background-color . "black") (foreground-color . "white") (cursor-color . "green") )) (set-frame-height (selected-frame) 58) (set-frame-width (selected-frame) 72) ;; Text Options ;; ============ (setq-default fill-column 70) ;(setq-default fill-prefix " ") ;; Time & Date Options ;; =================== (setq supress-day-of-week nil) (setq display-time-day-and-date t) ;; Mode Options ;; ============ (autoload 'c++-mode "cc-mode" "C++ Editing Mode" t) (autoload 'c-mode "cc-mode" "C Editing Mode" t) (autoload 'objc-mode "cc-mode" "Objective C Editing Mode" t) (autoload 'text-mode "indented-text-mode" "Indented Text Editing Mode" t) (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t) (autoload 'ps-mode "ps-mode" "Major mode for editing PostScript" t) (autoload 'LaTeX-mode "LaTeX mode for editing LaTeX" t) (setq auto-mode-alist (append '(("\\.C$" . c++-mode) ("\\.cc$" . c++-mode) ("\\.c$" . c-mode) ("\\.h$" . c++-mode) ("\\.i$" . c++-mode) ("\\.ii$" . c++-mode) ("\\.m$" . objc-mode) ("\\.pl$" . perl-mode) ("\\.sql$" . c-mode) ("\\.tex$" . LaTeX-mode) ("\\.sh$" . shell-script-mode) ("\\.mak$" . makefile-mode) ("\\.GNU$" . makefile-mode) ("makefile$" . makefile-mode) ("Imakefile$" . makefile-mode) ("\\.Xdefaults$" . xrdb-mode) ("\\.Xenvironment$" . xrdb-mode) ("\\.Xresources$" . xrdb-mode) ("*.\\.ad$" . xrdb-mode) ("\\.[eE]?[pP][sS]$" . ps-mode) ) auto-mode-alist)) (setq default-tab-width 2) (setq initial-major-mode 'text-mode) (setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'turn-on-auto-fill) (global-unset-key "\M-[") (global-unset-key "\M-O") (setq default-auto-fill-hook 'do-auto-fill) (add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-hungry-state 1))) (add-hook 'c-mode-common-hook '(lambda () (c-set-style "Ellemtel"))) ;; Remote Login Options ;; ==================== (setq rlogin-password-paranoia t) (setq rlogin-process-connection-type t) ;; Command Interpreter Options ;; =========================== ;; (setq comint-input-ignoredups t) (setq comint-scroll-show-maximum-output t) (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt) ;; Ediff Options ;; ============= ;; (setq ediff-window-setup-function 'ediff-setup-windows-plain) ;; Dired Options ;; ============= ;; (add-hook 'dired-load-hook (function (lambda () (load "dired-x") (define-key dired-mode-map "a" 'dired-mark-extension) (define-key dired-mode-map "b" 'dired-flag-extension) (define-key dired-mode-map "E" 'dired-unmark-all-files-no-query) (define-key dired-mode-map "\M-!" 'background) (setq dired-listing-switches "-alF" dired-ls-F-marks-symlinks t dired-bind-vm t dired-dwim-target t dired-guess-shell-gnutar "gnutar" dired-guess-shell-alist-user '(("\\.tgz$" "gnutar zxvf")) ) ))) (setq dired-enable-local-variables nil) (setq dired-local-variables-file nil) ;; Full ISO Latin-1 Character Set ;; ============================== (standard-display-european 1) (load "iso-insert") ;; Move date and time to frame-status line ;; ======================================= (display-time) (setq global-mode-string '("" vip-mode string)) (setq frame-title-format '(multiple-frames "%b" ("" invocation-name "@" system-name " :: " display-time-string))) (if (not (fboundp 'display-time)) (load "time")) ;; Key Bindings ;; ============ (define-key global-map "\C-[[H" 'beginning-of-line) (define-key global-map "\M-[K" 'end-of-line) (define-key global-map "\M-OL" 'backward-word) (define-key global-map "\M-OR" 'forward-word) (define-key global-map "\M-On" 'overwrite-mode) (define-key global-map "\M-Op" 'delete-char) (define-key global-map "\M-OA" 'previous-line) (define-key global-map "\M-OB" 'next-line) (define-key global-map "\M-OD" 'backward-char) (define-key global-map "\M-OC" 'forward-char) (define-key global-map "\M-O1" 'scroll-down) (define-key global-map "\M-O2" 'scroll-up) (define-key global-map "\M-O3" 'beginning-of-buffer) (define-key global-map "\M-O4" 'end-of-buffer) (define-key global-map "\M-OP" 'describe-bindings) (global-set-key [kp-f1] 'kill-compilation) (global-set-key [S-f9] 'kill-compilation) (global-set-key [C-f9] 'remote-compile) (global-set-key [S-f12] 'mail) (global-set-key [S-f10] 'ps-print-buffer-with-faces) (global-set-key [f2] 'man) (global-set-key [f3] 'aspell-buffer) (global-set-key [f4] 'imenu) (global-set-key [f5] 'copy-file) (global-set-key [f6] 'delete-file) (global-set-key [f7] 'rename-file) (global-set-key [f8] 'tags-search) (global-set-key [f9] 'compile) (global-set-key [f11] 'goto-line) (global-set-key [f12] 'vm (global-set-key "\C-x\C-b" 'electric-buffer-list) (global-set-key [pause] '[?\C-x ?\C-f ?/ ?t ?m ?p ?/ ?s ?t ?e ?p ?h return]) (defalias 'switch-to-next-buffer 'bury-buffer) (defun switch-to-previous-buffer () "Switches to previous buffer" (interactive) (switch-to-buffer (nth (- (length (buffer-list)) 1) (buffer-list))) ) (global-set-key [C-tab] 'switch-to-previous-buffer) (global-set-key [-backtab] 'switch-to-next-buffer) ;; Desktop ;; ======= (load "desktop") (desktop-load-default) (desktop-read) ;; Man Page Options ;; ================ (setq Man-notify 'bully Man-overstrike-face 'blue-bold Man-underline-face 'red-bold Man-see-also-regexp "SEE ALSO\\|RELATED INFORMATION") ;; FTP Options ;; =========== (setq ange-ftp-generate-anonymous-password t ange-ftp-retry-time 60 ange-ftp-smart-gateway t ange-ftp-binary-file-name-regexp ".") ;; Makefile Options ;; ================ (setq makefile-electric-keys t) ;; Compilation Options ;; =================== (setq compile-command "make -k") (setq compilation-window-height 20) (defadvice compile-internal (after my-scroll act comp) "Forces compile buffer to scroll " (let* ((ob (current-buffer)) (obw (get-buffer-window ob t)) win ) (save-excursion (if (or (null (setq win (get-buffer-window ad-return-value t))) (null obw)) nil (select-window win) (goto-char (point-max)) (select-window obw) )))) ;; Load ESS - Emacs Speaks Statistics ;; ---------------------------------- ;; Move cursor to the end after submitting R chunk ;; From Martin Maechler : ;; ---------------------------------------------------- (eval-after-load "comint" '(progn (setq comint-scroll-to-bottom-on-output t) ; (setq comint-scroll-show-maximum-output t) ; I find jumpy (define-key comint-mode-map [up] 'comint-previous-matching-input-from-input) (define-key comint-mode-map [down] 'comint-next-matching-input-from-input) (define-key comint-mode-map "\C-a" 'comint-bol-or-process-mark) ) ) (setq inferior-R-args "--vanilla") ;; Set up Emacs to recognize Sweave file automatically ;; --------------------------------------------------- (defun Rnw-mode () ;; (require 'ess-noweb) (load "/usr/local/share/emacs/site-lisp/ess-5.2.11/lisp/ess-noweb") (noweb-mode) (if (fboundp 'R-mode) (setq noweb-default-code-mode 'R-mode))) (add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode)) (add-to-list 'auto-mode-alist '("\\.Snw\\'" . Rnw-mode)) (setq reftex-file-extensions '(("Snw" "Rnw" "nw" "tex" ".tex" ".ltx") ("bib" ".bib"))) (setq TeX-file-extensions '("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))