;; asm4's .emacs. last modified Oct 09, 2004. ;; based on tkr's .emacs. ;; Set up the keyboard so the delete key on both the regular keyboard ;; and the keypad delete the character under the cursor and to the right ;; under X, instead of the default, backspace behavior. (global-set-key [delete] 'delete-char) (global-set-key [kp-delete] 'delete-char) (defvar domain-name (getenv "DOMAINNAME") "The value of the environment variable $DOMAINNAME") (defvar monochrome-p t "True if on a monochrome monitor.") ;; turn on font-lock mode (global-font-lock-mode t) ;; activate scrolling using mouse wheel (mouse-wheel-mode 't) ;; show matching parenthesis (require 'paren) (show-paren-mode 1) ;;define colors for tty (tty-color-define "white" 7 '(65535 65535 65535)) (tty-color-define "cyan" 6 '( 0 65535 65535)) (tty-color-define "magenta" 5 '(65535 0 65535)) (tty-color-define "blue" 4 '( 0 0 65535)) (tty-color-define "yellow" 3 '(65535 65535 0)) (tty-color-define "green" 2 '( 0 65535 0)) (tty-color-define "red" 1 '(65535 0 0)) (tty-color-define "black" 0 '( 0 0 0)) (tty-color-define "blah" 8 '(20000 10000 5000)) ;; set default window size to 80cols x 52 rows, good for 1024x768 ;; set font and frame colors (if (eq 'x window-system) (setq default-frame-alist '((foreground-color . "white") (background-color . "black") (top . 0) (left . 0) (width . 80) (height . 52) (cursor-type . box) (cursor-color . "white") (font . "-*-courier-medium-r-*-*-12-*-*-*-*-*-iso8859-*"))) ) ;; enable visual feedback on selections (setq-default transient-mark-mode t) (if (eq 'x window-system) (setq monochrome-p (not (string-match "-color" (symbol-name (x-display-visual-class)))))) ;; disable automatic adding of newlines at the end of the buffer with C-n (setq next-line-add-newlines nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Font locking (tkr) (if (eq 'x window-system) (if (not (eq 't monochrome-p)) (list (global-font-lock-mode 1)) (setq font-lock-support-mode 'lazy-lock-mode) (setq lazy-lock-defer-time nil) (setq lazy-lock-minimum-size 12288)) ) ;;; Some new functions (tkr) (defun untabify-all () (end-of-buffer) (set-mark) (beginning-of-buffer) (untabify)) (defun tabify-all () (end-of-buffer) (set-mark) (beginning-of-buffer) (tabify)) (defun scroll-down-in-place (n) (interactive "p") (previous-line n) (scroll-down n)) (defun scroll-up-in-place (n) (interactive "p") (next-line n) (scroll-up n)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The C definitions: (tkr) ;;; (add-hook 'c-mode-hook 'my-c-setting) (add-hook 'c++-mode-hook 'my-cpp-setting) (add-hook 'perl-mode-hook 'my-perl-setting) (defun my-c-setting () (interactive "") (defconst c-tab-always-indent t) (defconst c-basic-offset 3) (defconst auto-indent t) (c-set-offset 'case-label 1) (c-set-offset 'statement-case-intro 2) (define-key c-mode-map "}" 'c-closing-brace) (define-key c-mode-map "{" 'c-opening-brace) (define-key c-mode-map "\r" 'newline-and-indent) (c-toggle-hungry-state 1) ) (defun my-cpp-setting () (interactive "") (defconst c-tab-always-indent t) (defconst c-basic-offset 2) (defconst auto-indent t) (c-set-offset 'case-label 1) (c-set-offset 'statement-case-intro 2) (define-key c++-mode-map "}" 'c-closing-brace) (define-key c++-mode-map "{" 'c-opening-brace) (define-key c++-mode-map "\r" 'newline-and-indent) (c-toggle-hungry-state 1) (require 'paren) (show-paren-mode 1)) ;;; The C definitions: (asm4) (defun my-perl-setting () (interactive "") (defconst perl-tab-always-indent t) (setq tab-width 3) (setq perl-indent-level 3) (define-key perl-mode-map "{" 'c-opening-brace) (define-key perl-mode-map "\r" 'newline-and-indent) (auto-fill-mode 1) (require 'paren) (show-paren-mode 1)) (defun c-closing-brace () (interactive) "puts } where it belongs to" (insert "\n}") (indent-for-tab-command) (forward-line -1) (if (save-excursion (beginning-of-line) (skip-chars-forward " \t") (eolp)) (progn (beginning-of-line) (kill-line 1)) (progn (forward-line 1))) (end-of-line)) (defun c-opening-brace () (interactive) "puts { where it belongs to" (insert "{") (indent-for-tab-command)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Initial defaults (tkr) changed by asm4 ;;; (add-hook 'text-mode-hook 'turn-on-auto-fill) (add-hook 'html-mode-hook 'turn-off-auto-fill) (add-hook 'tex-mode-hook 'turn-off-auto-fill) ;;(add-hook 'perl-mode-hook 'turn-off-auto-fill) (setq sentence-end-double-space nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; for mutt, change to text mode ;;; for ampl, change to perl mode ;;; (setq auto-mode-alist (append '((".mod$" . perl-mode) (".dat$" . text-mode) ("/mutt-" . text-mode))auto-mode-alist)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; F? keys defined (tkr) ;;; (define-key global-map [f1] 'undo) ; F1 (define-key global-map [f2] 'query-replace) ; F2 (define-key global-map [f3] 'goto-line) ; F3 (define-key global-map [f4] 'end-of-buffer) ; F4 (define-key global-map [f5] 'scroll-up) ; F5 (define-key global-map [f6] 'recenter) ; F6 (define-key global-map [f7] 'beginning-of-buffer) ; F7 (define-key global-map [f8] 'scroll-down) ; F8 (define-key global-map [f9] 'what-line) ; F9 (define-key global-map [f10] 'goto-line) ; F10 (define-key global-map [f11] 'other-window) ; F11 (define-key global-map [f12] 'tabify-all) ; F12 (define-key global-map [home] 'beginning-of-buffer) (define-key global-map [end] 'end-of-buffer) ;; (define-key global-map "\C-x\C-k" 'kill-rectangle) ;; (define-key global-map "\C-x\C-y" 'yank-rectangle) (define-key global-map [delete] 'delete-char) ;; Delete (define-key global-map [kp-subtract] 'scroll-down-in-place) ;; KP_subtract (define-key global-map [kp-add] 'scroll-up-in-place) ;; KP_add (define-key global-map [kp-enter] 'other-window) ;; KP_enter (custom-set-variables '(undo-strong-limit 300000) '(c-basic-offset 3) '(undo-limit 20000000) '(fill-column 79)) ;; custom colors for X and non-X (require 'paren) (if (eq 'x window-system) (custom-set-faces '(font-lock-string-face ((((class color) (background light)) (:foreground "tan1")))) '(font-lock-keyword-face ((((class color) (background light)) (:foreground "cyan")))) '(font-lock-type-face ((((class color) (background light)) (:foreground "green")))) '(font-lock-function-name-face ((((class color) (background light)) (:foreground "red")))) '(font-lock-builtin-face ((((class color) (background light)) (:foreground "sky blue")))) '(show-paren-match-face ((((class color) (background light)) (:background "green3")))) '(show-paren-mismatch-face ((((class color) (background light)) (:background "hot pink")))) '(region ((((class color) (background light)) (:background "firebrick")))) '(isearch ((((class color) (background light)) (:background "wheat" :foreground "black")))) '(isearch-lazy-highlight-face ((((class color) (background light)) (:background "yellow3" :foreground "black")))) '(font-lock-comment-face ((((class color) (background light)) (:foreground "grey85")))) '(highlight ((((class color) (background light)) (:background "green2" :foreground "black")))) ) ;; otherwise on a terminal: (custom-set-faces '(font-lock-string-face ((((type tty) (class color)) (:foreground "yellow")))) '(font-lock-keyword-face ((((type tty) (class color)) (:foreground "blue")))) '(font-lock-type-face ((((type tty) (class color)) (:foreground "green")))) '(font-lock-function-name-face ((((type tty) (class color)) (:foreground "red")))) '(font-lock-builtin-face ((((type tty) (class color)) (:foreground "magenta")))) '(show-paren-match-face ((((type tty) (class color)) (:background "green")))) '(show-paren-mismatch-face ((((type tty) (class color)) (:background "red")))) ;; '(region ((((type tty) (class color)) (:foreground "red" :inverse-video t)))) '(region ((((type tty) (class color)) (:background "red" :inverse-video t)))) '(isearch ((((type tty) (class color)) (:background "yellow" :foreground "black")))) '(isearch-lazy-highlight-face ((((type tty) (class color)) (:background "white" :foreground "black")))) '(font-lock-comment-face ((((type tty) (class color)) (:foreground "yellow")))) '(font-lock-highlight ((((type tty) (class color)) (:background "green")))) ) )