;------------------------------------------------------------------------------ ; .emacs ; stephen niedzielski ;------------------------------------------------------------------------------ ; TODO: ; indent rule (just turn off) ; http://www.emacswiki.org/emacs/IndentingC ; makefile, c, C++ python, sh, lisp (?) ;------------------------------------------------------------------------------ ; add to search paths (add-to-list 'load-path "~/.emacs.d") ;------------------------------------------------------------------------------ ; additional files to load (require 'tabbar) ;------------------------------------------------------------------------------ ; hotkeys and shortcuts ; split-window-horizontally, vertically C-x 2 / 3 ; unsplit window C-x 1 ; top / bottom of buf C-pgup / dn ; set / clear mark C-spc ; insert literal C-q (literal) ; ispell ; downcase-region ; upcase-region ; delete-window ; list-buffers ; insert-dash-line ; shell ; dired ; next-error ; previous-error (defun hotkey () "loads hotkeys and shortcuts" ; y to yes, n to no (defalias 'yes-or-no-p 'y-or-n-p) ; goto line (global-set-key (kbd "C-g") 'goto-line) ; comments (global-set-key (kbd "C-/") 'comment-region) (global-set-key (kbd "C-\\") 'uncomment-region) ; wnd and buf sel (global-set-key (kbd "C-") 'other-window) (global-set-key (kbd "C-S-") (lambda () (interactive) (other-window -1))) (global-set-key (kbd "C-M-") 'tabbar-forward) (global-set-key (kbd "C-M-") 'tabbar-backward) ; Windows emulation (global-set-key (kbd "C-z") 'undo) ; HACK: one day redo support will be robust (global-set-key (kbd "C-y") 'undo) (global-set-key (kbd "C-o") 'find-file) (global-set-key (kbd "C-w") (lambda () (interactive) (kill-buffer))) (global-set-key (kbd "M-") 'save-buffers-kill-emacs) (global-set-key (kbd "C-s") 'save-buffer) (global-set-key (kbd "C-h") 'replace-regexp) (global-set-key (kbd "C-S-h") 'replace-string) (global-set-key (kbd "C-a") 'mark-whole-buffer) (global-set-key (kbd "C-f") 'isearch-forward-regexp) (define-key isearch-mode-map (kbd "C-f") 'isearch-repeat-forward) (define-key isearch-mode-map (kbd "C-S-f") 'isearch-repeat-backward) (global-set-key (kbd "") 'isearch-forward) (define-key isearch-mode-map (kbd "") 'isearch-repeat-forward) (define-key isearch-mode-map (kbd "S-") 'isearch-repeat-backward) ; load .emacs (global-set-key (kbd "") 'load-init-file) ; insert (global-set-key (kbd "") 'insert-timestamp) ; copy (global-set-key (kbd "C-_") 'copy-line) (global-set-key (kbd "C--") 'copy-line-above) (global-set-key (kbd "C-+") 'copy-line-below) (global-set-key (kbd "C-!") 'shell-command) (global-set-key (kbd "C-:") 'eval-expression) ; alaways indent when adding a new line (global-set-key "\r" 'reindent-then-newline-and-indent) ) ;------------------------------------------------------------------------------ ; title bar ; this doesn't always show accurate mod state, just use status bar ; (setq frame-title-format "%+%+%+ %b (%f) %+%+%+") (defun set-window-title (title) "specifies emacs window title" (interactive "title: ") (setq frame-title-format title) ) ;------------------------------------------------------------------------------ ; insert (defun insert-timestamp () "insert timestamp" (interactive) (insert (format-time-string "%Y-%m-%d-%0H-%0M-%0S")) ) (defun insert-dash-line () "insert dash line" (interactive) (insert "-------------------------------------------------------------------------------") ) ;------------------------------------------------------------------------------ ; copy (defun copy-line (&optional offset) "copies line at offset from cur line" (interactive) ; offset default 0 (unless offset (setq offset 0)) (let (pos line) ; save the cursor pos (setq pos (point)) ; step offset lines or as close as possible. also jumps to col 0 (forward-line offset) ; get line (setq line (thing-at-point 'line)) ; trim leading and trailing whitespace (setq line (replace-regexp-in-string "[\t ]*\\(.*\\)\n\r?" "\\1" line)) ; jump back to prev pos (goto-char pos) ; put line (when line (kill-new line)) ) ) (defun copy-line-above () "copies line above cursor" (interactive) (copy-line -1) ) (defun copy-line-below () "copies line below cursor" (interactive) (copy-line 1) ) ;------------------------------------------------------------------------------ (defun load-init-file () "loads .emacs" (interactive) (load-file ".emacs") ) ;------------------------------------------------------------------------------ ; lisp (add-hook 'emacs-lisp-mode-hook (lambda () (setq comment-add 0))) ;------------------------------------------------------------------------------ ; my init (set-window-title "emacs") (hotkey) (setq auto-mode-alist (append '( ("\\.c$" . c-mode) ("\\.cpp$" . c++-mode) ("\\.h$" . c++-mode) ("\\.hpp$" . c++-mode) ) auto-mode-alist)) ;------------------------------------------------------------------------------ ; customize ; HACK: not sure why this option never saves (menu-bar-mode 0) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(Buffer-menu-buffer+size-width 40) '(c++-font-lock-extra-types (quote ("\\sw+_t" "FILE" "lconv" "tm" "va_list" "jmp_buf" "istream" "istreambuf" "ostream" "ostreambuf" "ifstream" "ofstream" "fstream" "strstream" "strstreambuf" "istrstream" "ostrstream" "ios" "string" "rope" "list" "slist" "deque" "vector" "bit_vector" "set" "multiset" "map" "multimap" "hash" "hash_set" "hash_multiset" "hash_map" "hash_multimap" "stack" "queue" "priority_queue" "type_info" "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator" "reference" "const_reference" "TODO\\:" "HACK\\:" "CHANGEME\\:"))) '(c-basic-offset 2) '(c-default-style (quote ((c-mode . "bsd") (c++-mode . "bsd") (java-mode . "java") (awk-mode . "awk") (other . "gnu")))) '(c-font-lock-extra-types (quote ("\\sw+_t" "bool" "complex" "imaginary" "FILE" "lconv" "tm" "va_list" "jmp_buf" "Lisp_Object" "TODO\\:" "HACK\\:" "CHANGEME\\:"))) '(c-objc-method-arg-unfinished-offset 2) '(c-objc-method-parameter-offset 2) '(column-number-mode t) '(cua-highlight-region-shift-only t) '(cua-keep-region-after-copy t) '(cua-mode t nil (cua-base)) '(cua-remap-control-z nil) '(delete-selection-mode t) '(fringe-mode (quote (5 . 5)) nil (fringe)) '(global-whitespace-mode t) '(icomplete-mode t) '(ido-everywhere t) '(ido-mode (quote both) nil (ido)) '(indent-tabs-mode nil) '(inhibit-startup-screen t) '(initial-scratch-message nil) '(iswitchb-mode t) '(mouse-wheel-progressive-speed nil) '(mouse-wheel-scroll-amount (quote (1 ((shift) . 1) ((control))))) '(shift-select-mode nil) '(show-paren-mode t) '(size-indication-mode t) '(speedbar-frame-parameters (quote ((minibuffer) (width . 30) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t) (left-fringe . 0)))) '(standard-indent 2) '(tab-stop-list (quote (2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120))) '(tab-width 2) '(tabbar-background-color "systemscrollbar") '(tabbar-cycle-scope (quote tabs)) '(tabbar-mode t nil (tabbar)) '(tabbar-separator (quote (0.2))) '(tabbar-use-images t) '(tool-bar-mode nil) '(visible-bell t) '(whitespace-display-mappings (quote ((space-mark 32 [183] [46]) (space-mark 160 [164] [95]) (space-mark 2208 [2212] [95]) (space-mark 2336 [2340] [95]) (space-mark 3616 [3620] [95]) (space-mark 3872 [3876] [95]) (newline-mark 10 [182 10])))) '(whitespace-line-column 79) '(whitespace-style (quote (trailing tabs spaces newline empty space-after-tab::tab space-after-tab::space space-before-tab::tab space-before-tab::space space-mark tab-mark newline-mark)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:stipple nil :background "#000000" :foreground "#f9f9f9" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "outline" :family "Bitstream Vera Sans Mono")))) '(border ((t nil))) '(cursor ((t (:background "#87cefa" :foreground "black")))) '(font-lock-comment-face ((((class color) (min-colors 88) (background dark)) (:foreground "#777777")))) '(font-lock-doc-face ((t (:inherit font-lock-comment-face)))) '(font-lock-string-face ((((class color) (min-colors 88) (background dark)) (:foreground "#ddaa99")))) '(fringe ((((class color) (background dark)) (:background "#303030")))) '(header-line ((nil nil))) '(link ((t (:foreground "#6699ff" :underline t)))) '(link-visited ((t (:foreground "#7766dd" :underline t)))) '(menu ((t (:background "systemmenu" :foreground "systemmenutext" :inverse-video t)))) '(minibuffer-prompt ((((background dark)) (:background "#070707" :foreground "#00ff00")))) '(mode-line ((((class color) (min-colors 88)) (:background "#aaccff" :foreground "#101010" :box (:line-width 1 :color "#ffffff"))))) '(mode-line-buffer-id ((t (:box (:line-width 1 :color "#ffffff"))))) '(mode-line-emphasis ((t (:box (:line-width 1 :color "#ffffff") :weight bold)))) '(mode-line-highlight ((((class color) (min-colors 88)) (:box (:line-width 1 :color "#ffffff"))))) '(mode-line-inactive ((nil (:background "systemmenu" :foreground "#101010" :box (:line-width 1 :color "#ffffff"))))) '(mouse ((t nil))) '(scroll-bar ((t (:foreground "systemscrollbar")))) '(show-paren-match ((((class color) (background dark)) (:background "#bbddbb" :foreground "#000000" :underline t)))) '(show-paren-mismatch ((((class color)) (:background "#cc2222" :foreground "white")))) '(speedbar-directory-face ((((class color) (background dark)) (:foreground "light blue")))) '(speedbar-file-face ((((class color) (background dark)) (:foreground "cyan")))) '(tabbar-button ((t (:inherit tabbar-default :box (:line-width 1 :color "#777777" :style released-button))))) '(tabbar-button-highlight ((t (:inherit tabbar-default)))) '(tabbar-default ((((class color grayscale) (background dark)) (:inherit variable-pitch :background "#777777" :height 0.8)))) '(tabbar-highlight ((t (:background "#dddddd" :box (:line-width 3 :color "#dddddd"))))) '(tabbar-selected ((t (:inherit tabbar-default :background "#f2f2f6" :foreground "#000000" :box (:line-width 3 :color "#f2f2f6") :weight bold)))) '(tabbar-separator ((t (:inherit tabbar-default :height 0.7)))) '(tabbar-unselected ((t (:inherit tabbar-default :background "#aaaaaa" :foreground "#454545" :box (:line-width 3 :color "#aaaaaa"))))) '(tool-bar ((t (:background "systembuttonface" :foreground "systembuttontext" :box (:line-width 1 :style released-button))))) '(vertical-border ((nil nil))) '(whitespace-empty ((t (:background "#070707" :foreground "#440c0c")))) '(whitespace-indentation ((t (:foreground "#323232")))) '(whitespace-newline ((t (:foreground "#323232" :weight normal)))) '(whitespace-space ((t (:foreground "#323232")))) '(whitespace-space-after-tab ((t (:background "#070707" :foreground "#440c0c")))) '(whitespace-space-before-tab ((t (:background "#070707" :foreground "#440c0c")))) '(whitespace-tab ((((class color) (background dark)) (:foreground "#323232")))) '(whitespace-trailing ((t (:background "#070707" :foreground "#440c0c" :weight bold)))))