Atis Emacs config file
Put this in your ~/.emacs:
(require 'compile) ; Uncomment this (and install show-wspace package) if you want to highlight whitespace symbols ; (require 'show-wspace) ;;; look and feel (column-number-mode t) (global-font-lock-mode t) (setq font-lock-maximum-decoration t) (setq case-fold-search nil) (setq compilation-scroll-output t) (setq compilation-window-height 6) (setq indicate-empty-lines t) (setq iswitchb-mode t) (setq menu-bar-mode nil) (setq mouse-sel-mode t) (setq mouse-yank-at-point t) (setq pc-selection-mode t) (setq scroll-conservatively 5) (setq scroll-preserve-screen-position t) (setq tool-bar-mode nil) (setq truncate-partial-width-windows nil) (setq scroll-step 1) (setq scroll-conservatively 50) (setq show-trailing-whitespace t) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) ; Uncomment this to highlight tabs (show-wspace package required) ; (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs) (setq c-offsets-alist (quote ((innamespace . 0) (member-init-intro . ++) (inher-intro . ++) (arglist-intro . ++) (func-decl-cont . ++) (topmost-intro-cont . ++) (member-init-cont . 0) (inher-cont . 0) (statement-cont . ++) (arglist-cont . 0) (template-args-cont c-lineup-template-args ++) (arglist-cont-nonempty . ++) (inlambda . 0)))) (setq c-indent-level 4) (setq c-brace-offset -4) (setq c-brace-imaginary-offset -4) (setq c-argdecl-indent 4) (setq c-label-offset -4) (setq c-default-style "user") ;;;tab key indent and complete (setq c-insert-tab-function (lambda () (dabbrev-expand nil))) (setq c-tab-always-indent nil) ;;; compilation (defvar arch "i386") (defun recompile () (interactive) (compile (concat "make ARCH=" arch)) ) (defvar make-clean-command "make clean && make") (defun make-clean (&optional arg) (interactive "P") (save-some-buffers (not compilation-ask-about-save) nil) (compile-internal make-clean-command "No more errors")) (defvar make-dist-clean-command "make clean && make D=1 -j4 ARCH=") (defun make-dist-clean (&optional arg) (interactive "P") (save-some-buffers (not compilation-ask-about-save) nil) (compile-internal (concat make-dist-clean-command arch) "No more errors")) (defvar make-dist-command "make D=1 -j4 ARCH=") (defun make-dist (&optional arg) (interactive "P") (save-some-buffers (not compilation-ask-about-save) nil) (compile-internal (concat make-dist-command arch) "No more errors")) (setq mos-arch "telosb") (defun get-mansos-arch () (if (not mos-arch) (setq mos-arch "telosb")) mos-arch ) (defun make-mansos () (interactive) (compile (concat "make " (get-mansos-arch))) ) (defun make-mansos-upload () (interactive) (compile (concat "make " (get-mansos-arch) " upload")) ) (defvar make-mansos-clean-command "make clean") (defun make-mansos-clean (&optional arg) (interactive "P") (compile-internal make-mansos-clean-command "No more errors")) ;;; convenience (defun mygrep (arg) (interactive "sgrep what: ") (grep (concat "grep -n -r -e \"" arg "\" *"))) (defun unbury-buffer () "\ Switch to the last buffer in the buffer list that is not hidden." (interactive) (let ((list (reverse (buffer-list)))) (while (eq (aref (buffer-name (car list)) 0) ? ) (setq list (cdr list))) (switch-to-buffer (car list)))) (defun search-forward-delimiter () "\ Search forward for the next occurence of delimiter string." (interactive) (search-forward "/.")) (defun search-backward-delimiter () "\ Search backward for the previous occurence of delimiter string." (interactive) (search-backward "/.")) (defun change-arch (arg) (interactive "sarhitecture: ") (setq arch arg)) (global-set-key [kp-decimal] 'kill-buffer) (global-set-key [kp-2] 'delete-window) (global-set-key [kp-4] 'bury-buffer) (global-set-key [kp-5] 'other-window) (global-set-key [kp-6] 'unbury-buffer) (global-set-key [kp-7] 'search-backward-delimiter) (global-set-key [kp-8] 'delete-other-windows) (global-set-key [kp-9] 'search-forward-delimiter) (global-set-key [f5] 'make-dist) (global-set-key [f6] 'make-dist-clean) (global-set-key [f7] 'recompile) (global-set-key [f8] 'make-clean) (global-set-key [f9] 'change-arch) (global-set-key [C-f5] 'make-mansos) (global-set-key [C-f6] 'make-mansos-clean) (global-set-key [C-f7] 'make-mansos-upload) (global-set-key [C-f8] 'make-mansos-clean) (global-set-key [C-f9] 'change-mansos-arch) (global-set-key [f3] 'mygrep) (defun kill-curr-buffer () "Kill current buffer." (interactive) (kill-buffer (current-buffer))) (global-set-key [C-f4] 'kill-curr-buffer) (global-set-key [kp-decimal] 'kill-curr-buffer) (global-set-key [kp-delete] 'kill-curr-buffer) (global-unset-key "\C-z") (global-unset-key "\C-x\C-c") (global-set-key "\C-z" 'undo) (global-set-key "\M-z" 'redo) (global-unset-key "\C-c\C-u") (global-set-key "\C-c\C-u" 'uncomment-region) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq initial-frame-alist (cons '(foreground-color . "Black") initial-frame-alist)) (setq initial-frame-alist (cons '(background-color . "#ddddcc") initial-frame-alist)) (setq initial-frame-alist (cons '(cursor-color . "Black") initial-frame-alist)) ;; Display settings ;; default size and color options for all frames ;; foreground, background, and cursor colors (setq default-frame-alist (cons '(foreground-color . "Black") default-frame-alist)) (setq default-frame-alist (cons '(background-color . "#ddddcc") default-frame-alist)) (setq default-frame-alist (cons '(cursor-color . "Black") default-frame-alist)) ;; disable the normal emacs backup system (setq make-backup-file-name-function nil) (setq make-backup-files nil) (setq vc-make-backup-files nil) (setq default-tab-width 8) (defun linux-c-mode () "C mode with adjusted defaults for use with the Linux kernel." (interactive) (c-mode) (c-set-style "K&R") (setq tab-width 8) (setq indent-tabs-mode t) (setq c-basic-offset 8)) (defun mansos-c-mode () "C mode for MansOS" (interactive) ; use C++ mode, for "//" comments (c++-mode) ; convert tabe to spaces when typing (setq indent-tabs-mode nil) (setq c-brace-offset -4) (setq c-brace-imaginary-offset -4) (setq tab-width 4)) (defun haiku-c-mode () "C mode with adjusted defaults for use with Haiku OS." (interactive) (c-mode) (c-set-style "K&R") (setq tab-width 4) (setq indent-tabs-mode t) (c-set-offset 'arglist-cont 4) (c-set-offset 'arglist-cont-nonempty 4) (setq c-basic-offset 4)) (defun haiku-c++-mode () "C++ mode with adjusted defaults for use with Haiku OS." (interactive) (c++-mode) (c-set-style "K&R") (setq tab-width 4) (setq indent-tabs-mode t) (c-set-offset 'arglist-cont 4) (c-set-offset 'arglist-cont-nonempty 4) (setq c-basic-offset 4)) ;;; treat headers as c++ code (setq auto-mode-alist (append '(("\\.h$" . c++-mode)) auto-mode-alist)) ;;; use C mode for NesC files (setq auto-mode-alist (append '(("\\.nc$" . c-mode)) auto-mode-alist)) ;;; use C mode for PDE (Arduino) file (setq auto-mode-alist (append '(("\\.pde$" . c-mode)) auto-mode-alist)) ; May wish to change this to the directory where MansOS resides (setq auto-mode-alist (cons '("/mansos/.*\\.[ch]p?p?$" . mansos-c-mode) auto-mode-alist))