diff options
-rw-r--r-- | emacs-win32 | 384 |
1 files changed, 384 insertions, 0 deletions
diff --git a/emacs-win32 b/emacs-win32 new file mode 100644 index 0000000..c56caae --- /dev/null +++ b/emacs-win32 @@ -0,0 +1,384 @@ +;; add my paths to load-path +(add-to-list 'load-path "~/.emacs.d/session") +(add-to-list 'load-path "~/.emacs.d/lisp") + +;; setup fontset +(if window-system + (progn + ;; font setting + (set-default-font "Bitstream Vera Sans Mono-9") + (set-fontset-font (frame-parameter nil 'font) + 'han '("Microsfot Yahei" . "unicode-bmp")) + + ;; window positioning + (setq default-frame-alist '((top . 0) (left . 0) + (width . 156) (height . 38))))) + +;; setup show startup message +(setq inhibit-startup-message t) +(setq semantic-load-turn-useful-things-on t) + +(require 'site-win32) + +;;(setq-default make-backup-files nil) +;; load ecb +(setq ecb-auto-activate t) +(require 'cedet) +(require 'ecb) + +;; set color theme if emacs is windowed +(require 'color-theme) +(color-theme-initialize) +(if window-system + (progn + (color-theme-bharadwaj-slate))) + +;;color terminal +(require 'ansi-color) +(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) + +;; ask for y or n instead +(fset 'yes-or-no-p 'y-or-n-p) + +(transient-mark-mode t) + +(add-hook 'find-file-hooks 'auto-insert) + +(show-paren-mode t) + +;;(setq lazy-lock-defer-on-scrolling t) +;;(setq font-lock-support-mode 'lazy-lock-mode) +;;(setq font-lock-maximum-decoration t) + +;; setup keybinds +(global-set-key [f5] 'ecb-activate) +(global-set-key [f6] 'ecb-deactivate) +(global-set-key [f9] 'compile) +(global-set-key [f12] 'gdb) + +;;session +(require 'session) +(add-hook 'after-init-hook 'session-initialize) + +;;kill a line +(defun kill-whole-line nil + "delete the whole line" + (interactive) + (beginning-of-line) + (push-mark) + (beginning-of-line 2) + (kill-region (point) (mark))) +(global-set-key (kbd "C-d") 'kill-whole-line) + +;; compile .emacs +(defun autocompile nil + "compile itself if ~/.emacs" + (interactive) + (if (string= (buffer-file-name) (concat default-directory ".emacs")) + (byte-compile-file (buffer-file-name)))) +(add-hook 'after-save-hook 'autocompile) + +;;---------------------------------------------------------------------------- +(setq tab-width 4) +;;(setq c-basic-offset 4) +;;(setq c-hanging-comment-ender-p nil) +;;(setq-default indent-tabs-mode nil) + +;; define a new indentation style +(require 'cc-styles) +(add-to-list 'c-style-alist + '("ljh" + (indent-tabs-mode nil) + (c-basic-offset . 4) + (c-comment-only-line-offset . 0) + (c-offsets-alist . ((statement-block-intro . +) + (knr-argdecl-intro . 0) + (substatement-open . 0) + (substatement-label . 0) + (label . 1) + (statement-cont . +) + (arglist-intro . c-lineup-arglist-intro-after-paren) + (arglist-close . c-lineup-arglist) + )) + ) + ) + +(add-to-list 'c-style-alist + '("tables" + (c-basic-offset . 8) + (c-comment-only-line-offset . 0) + (c-offsets-alist . ((statement-block-intro . +) + (knr-argdecl-intro . 0) + (substatement-open . 0) + (substatement-label . 0) + (label . 1) + (statement-cont . +) + (inline-open 0) + (innamespace . 0) + (arglist-intro . c-lineup-arglist-intro-after-paren) + (arglist-close . c-lineup-arglist) + )) + ) + ) + +(add-hook 'c-mode-common-hook + (function + (lambda () + ;; (c-set-style "ljh") + (hl-line-mode t) + (linum-mode) + ))) +(add-hook 'c++-mode-hook + (function + (lambda () + (c-set-style "ljh") + (hl-line-mode t) + ))) + +(add-hook 'python-mode-hook + (function + (lambda () + (hl-line-mode t) + (linum-mode) + ))) + +(defun gstreamer-c-mode () + "C mode with adjusted defaults for use with GStreamer." + (interactive) + (c-mode) + (c-set-style "K&R") + (setq c-basic-offset 2)) + +(setq auto-mode-alist (cons '("gst.*/.*\\.[ch]$" . gstreamer-c-mode) + auto-mode-alist)) + +(defun ljh-c-mode () + "C mode with adjusted defaults for myself." + (interactive) + (c-mode) + (c-set-style "ljh")) +(setq auto-mode-alist (cons '("milkway.*/.*\\.[ch]$" . ljh-c-mode) + auto-mode-alist)) + +(setq auto-mode-alist (cons '("openpps.*/.*\\.[ch]$" . ljh-c-mode) + auto-mode-alist)) + +;; guess offset +(require 'guess-offset) + +(require 'semanticdb) +;;(global-semanticdb-minor-mode 1) +(require 'semantic-ia) +(global-set-key [(control p)] 'semantic-ia-complete-symbol-menu) +;;# semantic-ia-complete-symbol +;;# semantic-ia-complete-symbol-menu +;;# semantic-ia-complete-tip + +(require 'tabbar) +(tabbar-mode) +(global-set-key [(s-down)] 'tabbar-backward-group);; +(global-set-key [(s-up)] 'tabbar-forward-group) +(global-set-key (kbd "s-b") 'tabbar-backward);; +(global-set-key (kbd "s-f") 'tabbar-forward) + +;;M-x desktop-clear +;;(load "desktop") +;;(desktop-save-mode) +;;(desktop-read) +;;(global-set-key [f11] 'desktop-save) + +;;(global-semantic-show-dirty-mode -1) +(global-semantic-show-unmatched-syntax-mode -1) +(require 'semantic-load) +;;(global-semantic-idle-completions-mode 1) + +(require 'doxymacs) +(add-hook 'c-mode-common-hook 'doxymacs-mode) + +;; emacs +(add-to-list 'auto-mode-alist '("emacs/emacs" . lisp-mode)) + +;; scons +(add-to-list 'auto-mode-alist '("SConstruct" . python-mode)) +(add-to-list 'auto-mode-alist '("SConscript" . python-mode)) +(add-to-list 'interpreter-mode-alist '("python" . python-mode)) + +;; Set the fill column to 70 for human text, and 80 for code. +;;(add-hook 'text-mode-hook '(lambda () (set-fill-column 70))) +;;(add-hook 'c-mode-hook '(lambda () (set-fill-column 80))) +;;(add-hook 'c++-mode-hook '(lambda () (set-fill-column 80))) +;;(add-hook 'python-mode-hook '(lambda () (set-fill-column 80))) +;;(add-hook 'java-mode-hook '(lambda () (set-fill-column 80))) + +;;auto-complete +(require 'auto-complete) +(require 'auto-complete-config) +(require 'yasnippet) + +(global-auto-complete-mode t) +(setq ac-auto-start 2) + +(define-key ac-complete-mode-map "\t" 'ac-expand) +(define-key ac-complete-mode-map "\r" 'ac-complete) +(define-key ac-complete-mode-map (kbd "M-j") 'ac-complete) +(define-key ac-complete-mode-map (kbd "M-n") 'ac-next) +(define-key ac-complete-mode-map (kbd "M-p") 'ac-previous) + +(setq ac-dwim t) +(setq ac-candidate-menu-height 20) +(setq ac-candidate-max ac-candidate-menu-height) + +(set-default 'ac-sources + '(ac-source-semantic + ac-source-yasnippet + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-imenu + ac-source-files-in-current-dir + ac-source-filename)) +;;(setq ac-modes ac+-modes) + +(setq ac-trigger-commands '(self-insert-command autopair-insert-or-skip-quote)) + +(defun ac-settings-4-lisp () + "Auto complete settings for lisp mode." + (setq ac-omni-completion-sources '(("require\s+'" ac-source-emacs-lisp-features) + ("load\s+\"" ac-source-emacs-lisp-features))) + (setq ac-sources + '(ac-source-yasnippet + ac-source-symbols + ac-source-semantic + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-imenu + ac-source-files-in-current-dir + ac-source-filename))) + +(defun ac-settings-4-java () + (setq ac-omni-completion-sources (list (cons "\\." '(ac-source-semantic)) + (cons "->" '(ac-source-semantic)))) + (setq ac-sources + '(ac-source-semantic + ac-source-yasnippet + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-files-in-current-dir + ac-source-filename))) + +(defun ac-settings-4-c () + (setq ac-omni-completion-sources (list (cons "\\." '(ac-source-semantic)) + (cons "->" '(ac-source-semantic)))) + (setq ac-sources + '(ac-source-semantic + ac-source-yasnippet + ac-source-c-keywords + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-files-in-current-dir + ac-source-filename))) + +(defun ac-settings-4-cpp () + (setq ac-omni-completion-sources + (list (cons "\\." '(ac-source-semantic)) + (cons "->" '(ac-source-semantic)))) + (setq ac-sources + '(ac-source-semantic + ac-source-yasnippet + ac-source-c++-keywords + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-files-in-current-dir + ac-source-filename))) + +(defun ac-settings-4-python () + (setq ac-omni-completion-sources + '(("\\." ac-source-ropemacs))) + (setq ac-sources + '(ac-source-semantic + ac-source-yasnippet + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-files-in-current-dir + ac-source-filename))) + +(defun ac-settings-4-text () + (setq ac-sources + '(;;ac-source-semantic + ac-source-yasnippet + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-imenu))) + +(defun ac-settings-4-eshell () + (setq ac-sources + '(;;ac-source-semantic + ac-source-yasnippet + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-files-in-current-dir + ac-source-filename + ac-source-symbols + ac-source-imenu))) + +(defun ac-settings-4-ruby () + (setq ac-omni-completion-sources + (list (cons "\\." '(ac-source-rcodetools)) + (cons "::" '(ac-source-rcodetools))))) + +(defun ac-settings-4-html () + (setq ac-sources + '(ac-source-semantic + ac-source-yasnippet + ac-source-abbrev + ac-source-words-in-buffer + ac-source-words-in-all-buffer + ac-source-files-in-current-dir + ac-source-filename))) + +(dolist (hook (list 'lisp-mode-hook 'emacs-lisp-mode-hook 'lisp-interaction-mode-hook + 'svn-log-edit-mode)) + (add-hook hook 'ac-settings-4-lisp)) + +(add-hook 'java-mode-hook 'ac-settings-4-java) +(add-hook 'c-mode-hook 'ac-settings-4-c) +(add-hook 'c++-mode-hook 'ac-settings-4-cpp) +(add-hook 'python-mode-hook 'ac-settings-4-python) +(add-hook 'text-mode-hook 'ac-settings-4-text) +(add-hook 'eshell-mode-hook 'ac-settings-4-eshell) +(add-hook 'html-mode-hook 'ac-settings-4-html) + +;;(dolist (mode ac-modes) +;; (let ((mode-name (symbol-name mode))) +;; (when (and (intern-soft mode-name) (intern-soft (concat mode-name "-map"))) +;; (define-key (symbol-value (concat-name mode-name "-map")) (kbd "C-c a") 'ac-start)))) + +(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. + '(column-number-mode t) + '(display-time-mode t) + '(ecb-options-version "2.40") + '(ecb-source-path (quote (("e:/Projects" "Projects")))) + '(scroll-bar-mode (quote right)) + '(show-paren-mode t) + '(show-trailing-whitespace t) + '(size-indication-mode t) + '(transient-mark-mode t)) +(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. + ) + +(put 'narrow-to-region 'disabled nil) |