(require 'bswitch) (require 'cua) (CUA-mode t) (find-file "C:/Documents and Settings/jCrawford/Desktop/todo.txt") (set-background-color "Black") (set-foreground-color "Green") (set-cursor-color "White") (set-default-font "-*-Lucida console-*-r-*-*-16-97-*-*-c-*-*-ansi-") (global-font-lock-mode t) (setq-default scroll-step 1) (setq-default tab-width 2) (setq-default indent-tabs-mode nil) (setq column-number-mode t) (setq backup-directory-alist '(("." . "c:/emacs/backup" ))) (define-key global-map [C-f4] 'kill-this-buffer) (define-key global-map [C-f8] 'swapquotes) (define-key global-map [f4] 'revert-buffer) (define-key global-map "\C-s" 'save-buffer) (define-key global-map "\C-m" 'my-enter) (define-key global-map "\C-a" 'mark-whole-buffer) (define-key global-map [backspace] 'my-backspace) (define-key global-map [tab] 'my-indent) (define-key global-map [(shift tab)] 'my-outdent) (define-key global-map [C-backspace] 'kill-whitespace-backward) (define-key global-map [C-delete] 'kill-whitespace-forward) (define-key global-map [home] 'my-beginning-of-line) (define-key global-map "\C-f" 'isearch-forward) (define-key global-map [f3] 'isearch-repeat-forward) (define-key isearch-mode-map [backspace] 'isearch-delete-char) (define-key isearch-mode-map "\C-f" 'isearch-repeat-forward) (define-key isearch-mode-map "\C-s" 'save-buffer) (defun my-indent (from to) (interactive "r") (indent-rigidly from to tab-width)) (defun my-outdent (from to) (interactive "r") (indent-rigidly from to (- tab-width))) (defun my-backspace (&optional arg) "If backspacing onto a line containing only whitespace, clear the whitespace." (interactive) (if arg (delete-backward-char arg) (if (/= (current-column) 0) (delete-backward-char 1) (let ((from (point))) (backward-char 1) (skip-chars-backward " \t") (if (and (/= from (point)) (= (current-column) 0)) (delete-region from (point)) (progn (goto-char from) (delete-backward-char 1))))))) (defun my-enter (&optional arg) "Start a new line at the same indentation level of the previous line. If enter is pressed at or before the first non-whitespace character on the line, lower the whole line instead of just the part after the cursor." (interactive) (let ((depth 0)) (save-excursion (beginning-of-line) (if (looking-at "^[ \t]+") (setq depth (length (buffer-substring (match-beginning 0) (match-end 0)))))) (if arg (newline arg) (if (< (current-column) depth) (let ((col (current-column))) (beginning-of-line) (newline) (forward-char col)) (progn (newline) (if depth (indent-to depth))))))) (defun kill-whitespace-backward (&optional arg) (interactive) (let ((from (point))) (skip-chars-backward " \t") (if (/= from (point)) (delete-region from (point))))) (defun kill-whitespace-forward (&optional arg) (interactive) (let ((from (point))) (skip-chars-forward " \t") (if (/= from (point)) (delete-region from (point))))) (add-hook 'c++-mode-hook 'c-setup) (add-hook 'c-mode-hook 'c-setup) (add-hook 'perl-mode-hook 'c-setup) (defun c-setup () (setq c-set-style "user") (setq c-basic-offset 2) (setq c-syntactic-indentation nil) (setq c-offsets-alist nil) (setq indent-line-function 'indent-relative) (setq c-style-alist nil) (local-set-key [tab] 'indent-for-tab-command) (local-unset-key "{") (local-unset-key "}") (local-unset-key "(") (local-unset-key ")") (local-unset-key ";") (local-unset-key ",") (local-unset-key "\t")) (defun my-beginning-of-line(&optional N) "Only move back to the first non-whitespace character, unless already at or before that point." (interactive) (if (and N (> N 1)) (next-line N)) (let ((depth 0) (cur (point))) (beginning-of-line) (setq cur (- cur (point))) (if (looking-at "^[ \t]+") (setq depth (- (match-end 0) (match-beginning 0)))) (if (> cur depth) (forward-char depth)))) (defun swapquotes (&optional arg) (interactive) (query-replace "``" "[closequote]" t (region-beginning) (region-end)) (query-replace "''" "[openquote]" t (region-beginning) (region-end)) (query-replace "[openquote]" "``" t (region-beginning) (region-end)) (query-replace "[closequote]" "''" t (region-beginning) (region-end))) (add-hook 'font-lock-mode-hook '(lambda () (font-lock-add-keywords nil '(("^............................................................................\\(.\\)" 1 font-lock-warning-face prepend))))) (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. '(recentf-mode t nil (recentf))) (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. '(font-lock-warning-face ((t (:background "blue" :foreground "green" :weight bold)))))