;; ============================ ;; Fonts and Colors ;; ============================ (set-background-color "midnightblue") ;(set-background-color "gray25") (set-foreground-color "white") (set-cursor-color "white") ;(set-background-color "white") ;(set-foreground-color "black") ;(set-cursor-color "black") (set-face-background 'region "gray") (set-face-foreground 'region "black") (set-frame-height (selected-frame) 60) (set-frame-width (selected-frame) 85) ;; Automatic coloring (global-font-lock-mode t) ; Even more colors (setq font-lock-maximum-decoration t) ;; Default font (check with xfontsel) (set-default-font "-adobe-courier-medium-r-normal--14-140-75-75-m-90-iso8859-1") ;(set-default-font "-adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1") ;; ============================ ;; Mouse Settings ;; ============================ ;; mouse button one drags the scroll bar (global-set-key [vertical-scroll-bar down-mouse-1] 'scroll-bar-drag) ;; setup scroll mouse settings (defun up-slightly () (interactive) (scroll-up 5)) (defun down-slightly () (interactive) (scroll-down 5)) (global-set-key [mouse-4] 'down-slightly) (global-set-key [mouse-5] 'up-slightly) (defun up-one () (interactive) (scroll-up 1)) (defun down-one () (interactive) (scroll-down 1)) (global-set-key [S-mouse-4] 'down-one) (global-set-key [S-mouse-5] 'up-one) (defun up-a-lot () (interactive) (scroll-up)) (defun down-a-lot () (interactive) (scroll-down)) (global-set-key [C-mouse-4] 'down-a-lot) (global-set-key [C-mouse-5] 'up-a-lot) ;; ============================ ;; Key mappings ;; ============================ ;; Let backspace and delete be defined as usual if ;; nothing is highlighted, otherwise the marked region is deleted (defun kill-something() (interactive) (if (and mark-active transient-mark-mode) (kill-region (point) (mark)) (backward-delete-char-untabify 1))) ;;(global-set-key [delete] 'kill-something) (global-set-key [backspace] 'kill-something) ;; PC-selection-mode: highligt regions with shift-arrow etc. ;; For more details , see C-h f pc-sel (pc-selection-mode) ;; Indents buffer by C-c b (defun indent-buffer () "Indent every line in the buffer." (interactive) (indent-region (point-min) (point-max) nil)) (global-set-key "\C-cb" 'indent-buffer) ;; Compilation commands (global-set-key [f7] 'previous-error) (global-set-key [f8] 'next-error) ;; Complete incomplete words by M-< instead of the default M-/ (global-set-key "\M-<" 'dabbrev-expand) (global-set-key [f4] 'kill-this-buffer) ;;(global-set-key [f5] 'delete-other-windows) ;; ============================ ;; Display ;; ============================ ;; Visible bell (setq visible-bell t) ;; Match parenthesis (show-paren-mode t) (setq show-paren-ring-bell-on-mismatch t) ;; Alias y to yes and n to no (defalias 'yes-or-no-p 'y-or-n-p) ;; Highlight matches from searches (setq isearch-highlight t) (setq search-highlight t) (setq-default transient-mark-mode t) (when (fboundp 'blink-cursor-mode) (blink-cursor-mode -1)) ;; Disable startup message (setq inhibit-default-init t) (setq inhibit-startup-message t) ;; =========================== ;; Behaviour ;; =========================== ;; Arrow down can never make the file bigger (setq next-line-add-newlines nil) ;; Save files with newline characters in them (setq require-final-newline t) ;; C-k (kill-line) also removes newline character (setq kill-whole-line t) ;; Use space instead of tab for indentation (setq-default indent-tabs-mode nil) ;; Format the title-bar to always include the buffer name (setq frame-title-format "emacs - %b") ;; Turn off the toolbar (if (>= emacs-major-version 21) (tool-bar-mode -1)) ;; Turn on word wrapping in text mode (add-hook 'text-mode-hook 'turn-on-auto-fill) ;; Replace highlighted text rather than just inserting at a point (delete-selection-mode t) ;; Resize the mini-buffer when necessary (setq resize-minibuffer-mode t) ;; Highlight during searching (setq query-replace-highlight t) ;; Highlight incremental search (setq search-highlight t) ;; Spellcheck and complete abbreviations (setq-default abbrev-mode t) (read-abbrev-file "~/.abbrev_defs") (setq save-abbrevs t) ;; Highlight current line (global-hl-line-mode 1) ;; Scroll just one line when hitting the bottom of the window (setq scroll-step 1) ;;(setq scroll-conservatively 0) ;; Prevent creating backup-files (setq make-backup-files nil) ;; Keep track of previously opened files ;; Requires the (possibly empty) file .emacs.desktop ;; in the local directory. ;;(if (require 'desktop nil t) ;; (setq desktop-enable t)) ;; =========================== ;; Java Mode ;; =========================== ;; Use JDE for Java-files if it exists. (when (locate-library "jde") (autoload 'jde-mode "jde" "JDE mode." t) (add-to-list 'auto-mode-alist '("\\.java\\'" . jde-mode)) ;; Fix for inkompatibility between Emacs 20 and 21 (defvar browse-url-new-window-p browse-url-new-window-flag)) ;; =========================== ;; Matlab Mode ;; =========================== (autoload 'matlab-mode "~/matlab.el" "Enter Matlab mode." t) (setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist)) (autoload 'matlab-shell "~/matlab.el" "Interactive Matlab mode." t) ;; =========================== ;; C Mode ;; =========================== ;; C-mode-common-hook is run by c-mode and derives modes eg. jde-mode (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) (defun my-c-mode-common-hook () ;; Automatically indent new line (define-key c-mode-base-map "\r" 'reindent-then-newline-and-indent)) ;; =========================== ;; Latex Mode ;; =========================== (setq tex-default-mode 'latex-mode) (setq tex-dvi-view-command "kdvi") (add-hook 'TeX-mode-hook 'turn-on-auto-fill) ;; To get colors in TeX-buffers (add-hook 'TeX-mode-hook 'turn-on-font-lock) (add-to-list 'load-path "~/AucTex") (load "auctex.el" nil t t) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (setq reftex-plug-into-AUCTex t) ;; =========================== ;; HTML Mode ;; =========================== (autoload 'html-helper-mode "~/beta-html-helper-mode.el" "Yay HTML" t) (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist)) ;; =========================== ;; Customize ;; Variables set by customize ?? ;; =========================== (custom-set-variables '(load-home-init-file t t)) (custom-set-faces) ;; =========================== ;; Additional key mappings ;; =========================== ;; Insert functions (global-unset-key "\C-a") ;; Insert new file header (author) (global-set-key "\C-a\C-n" 'insert-file-header) ;; Insert new file header in form file (global-set-key "\C-a\C-f" 'insert-file-header-form) ;; Change file header (author) (global-set-key "\C-a\C-c" 'change-file-header) (defun insert-file-header () (interactive) (beginning-of-buffer) (insert "// Copyright (C) 2007 Jesper Carlsson.\n") (insert "// Licensed under the GNU GPL Version 2.\n") (insert "//\n") (insert "// Modified by Jesper Carlsson\n") (insert "// First added: ") (insert (format-time-string "%Y-%m-%d\n")) (insert "// Last changed: ") (insert (format-time-string "%Y-%m-%d\n"))) (defun insert-file-header-form () (interactive) (beginning-of-buffer) (insert "# Copyright (C) 2007 Jesper Carlsson.\n") (insert "# Licensed under the GNU GPL Version 2.\n") (insert "#\n") (insert "# Modified by Jesper Carlsson\n") (insert "# First added: ") (insert (format-time-string "%Y-%m-%d\n")) (insert "# Last changed: ") (insert (format-time-string "%Y-%m-%d\n"))) (defun change-file-header () (interactive) (beginning-of-buffer) (goto-line 4) (kill-line 1) (insert "// Modified by Jesper Carlsson\n") (forward-line 1) (kill-line 1) (insert "// Last changed: ") (insert (format-time-string "%Y-%m-%d\n")))