(ansi-color-for-comint-mode-on)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(setq track-eol t)
(setq make-backup-files nil)
(setq auto-save-default nil)
(if window-system (tool-bar-mode nil))
(menu-bar-mode nil)
(display-time-mode 1)
(hl-line-mode t)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
(global-set-key (kbd "M-o") 'ff-find-other-file)
(global-set-key (kbd "C-c c") 'comment-or-uncomment-region)
(global-set-key (kbd "<f9>") 'smart-compile)
(global-set-key (kbd "<f5>") 'gdb)

(add-to-list 'load-path "~/opensource/go/misc/emacs/" t)
(require 'go-mode-load)

(setq auto-mode-alist (cons '("\\.h$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.qrc$" . nxml-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.tpl$" . html-mode) auto-mode-alist))

-(defun my-c-cpp-mode-common-hook()                                                                 
  (c-set-style "linux")                                                                             
  (setq c-basic-offset 4)                                                                           
  ;(c-toggle-auto-hungry-state 1)                                                                   
  (which-function-mode t)                                                                           
  (define-key c-mode-base-map [(return)] 'newline-and-indent)                                       
  (local-set-key (kbd "RET") 'newline-and-indent)                                                   
  (setq c-macro-shrink-window-flag t)                                                               
  (setq c-macro-preprocessor "cpp")                                                                 
  (setq c-macro-cppflags " ")                                                                       
  (setq c-macro-prompt-flag t)                                                                      
  (setq abbrev-mode t)                                                                              
  (make-local-variable 'skeleton-pair-alist)                                                        
  (setq skeleton-pair-alist  '(                                                                     
    (?{ > \n > _ \n ?} >)))                                                                         
  (setq skeleton-pair t)                                                                            
  (local-set-key (kbd "\'") 'skeleton-pair-insert-maybe)                                            
  (local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)                                            
  (local-set-key (kbd "(") 'skeleton-pair-insert-maybe)                                             
  (local-set-key (kbd "{") 'skeleton-pair-insert-maybe)                                             
  (local-set-key (kbd "`") 'skeleton-pair-insert-maybe)                                             
  (local-set-key (kbd "[") 'skeleton-pair-insert-maybe)                                             
  (local-set-key (kbd "C-c m") 'man)                                                                
  )
(add-hook 'c-mode-common-hook 'my-c-cpp-mode-common-hook)
(add-hook 'c++-mode-common-hook 'my-c-cpp-mode-common-hook)

(load-file "~/.emacs.d/site-lisp/smart-compile/smart-compile.el")

(add-to-list 'load-path "~/.emacs.d/site-lisp/yasnippet")
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/site-lisp/yasnippet/snippets")

(require 'xcscope)
-(defun cscope-index-sysfiles()                                                                    
  (interactive)                                                                                    
  (message "cscope find system header files...")                                                   
  (shell-command "find /usr/include /usr/local/include -type f > ~/cscope.files")                  
  (message "cscope index system header files...")                                                  
  (shell-command "cscope -b -q -i ~/cscope.files -f ~/cscope.out")                                 
  (message "cscope index system header files finished.")                                           
)

(load-file "~/.emacs.d/site-lisp/cedet/common/cedet.el")
;(semantic-load-enable-minimum-features)                                                           
(semantic-load-enable-code-helpers)
-;(semantic-load-enable-guady-code-helpers)                                                        
;(semantic-load-enable-excessive-code-helpers)                                                     
(semantic-load-enable-semantic-debugging-helpers)
(global-semantic-idle-local-symbol-highlight-mode 1)

-(require 'semantic-ia)                                                                            
(require 'semantic-gcc)                                                                            
(require 'semantic-idle)
(setq global-semantic-idle-scheduler-mode t)
(setq semantic-idle-scheduler-work-idle-time 15)
(setq semantic-idle-work-parse-neighboring-files-flag t)
(setq semantic-idle-scheduler-working-in-modeline-flag t)
(require 'semanticdb)
(global-semanticdb-minor-mode 1)
(global-semantic-show-parser-state-mode 1)
(require 'semantic-tag-folding nil 'noerror)
(global-semantic-tag-folding-mode 1)
(define-key semantic-tag-folding-mode-map (kbd "C-c -") 'semantic-tag-folding-fold-block)
(define-key semantic-tag-folding-mode-map (kbd "C-c =") 'semantic-tag-folding-show-block)
(define-key semantic-tag-folding-mode-map (kbd "C-c _") 'semantic-tag-folding-fold-all)
(define-key semantic-tag-folding-mode-map (kbd "C-c +") 'semantic-tag-folding-show-all)

(global-set-key "\C-cj" 'semantic-ia-fast-jump)
(global-set-key "\C-cb" 'my-semantic-ia-fast-jump-back)
(global-set-key (kbd "C-c TAB") 'semantic-complete-analyze-inline)
(eval-after-load "semantic-complete"                                                               
  '(setq semantic-complete-inline-analyzer-displayor-class                                         
         semantic-displayor-ghost))

-(defun my-cedet-hook()                                                                            
  (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle)                                      
  (local-set-key "\C-cr" 'semantic-symref-symbol)                                                  
  (local-set-key "\C-cr" 'semantic-symref-symbol)                                                  
  (local-set-key "." 'semantic-complete-self-insert)                                               
  (local-set-key ">" 'semantic-complete-self-insert)                                               
)
(add-hook 'c-mode-common-hook 'my-cedet-hook)
(add-hook 'c++-mode-common-hook 'my-cedet-hook)

-(defun my-semantic-ia-fast-jump-back()                                                            
  (interactive)                                                                                    
  (if (ring-empty-p (oref semantic-mru-bookmark-ring ring))                                        
      (error "Semantic Bookmark ring is currently empty"))                                         
  (let* ((ring (oref semantic-mru-bookmark-ring ring))                                             
         (alist (semantic-mrub-ring-to-assoc-list ring))                                           
         (first (cdr (car alist))))                                                                
    (if (semantic-equivalent-tag-p (oref first tag)                                                
                                   (semantic-current-tag))                                         
        (setq first (cdr (car (cdr alist)))))                                                      
    (semantic-mrub-switch-tags first)))

(global-ede-mode t)
(ede-cpp-root-project "apue.2e"                                                                    
                :name "apue.2e examples"                                                           
                :file "~/learn/apue/apue.2e/Makefile"                                              
                :include-path '("/include"                                                         
                               )                                                                   
                :spp-table '(("LINUX" . "")                                                        
                             ("_GNU_SOURCE" . "")))

(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.                                             
 '(semantic-highlight-edits-face ((((class color) (background light)) (:background "#010101")))))
(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.                                             
 )