       '(sql-mode nxml-mode cmake-mode folio-mode protobuf-mode
                  python-mode dos-mode gud-mode sh-mode
                  makefile-mode makefile-automake-mode makefile-gmake-mode
-                 autoconf-mode gdb-script-mode awk-mode
-                 mock-mode))
+                 autoconf-mode gdb-script-mode awk-mode csv-mode
+                 mock-mode org-mode html-mode text-mode sql-mode
+                 sql-interactive-mode
+                 git-commit-mode
+                 ))
 (require 'auto-complete-config)
-(ac-config-default)
-(setq-default ac-sources (append '(ac-source-filename) ac-sources))
+(setq-default ac-sources
+              '(ac-source-abbrev
+                ac-source-dictionary
+                ac-source-words-in-buffer
+                ac-source-words-in-same-mode-buffers
+                ac-source-filename
+                ))
+;; (ac-config-default)
+;; (setq-default ac-sources (append '(ac-source-filename) ac-sources))
+
+(setq ac-expand-on-auto-complete nil)
+(setq ac-auto-start nil)
+(setq ac-dwim nil)
 (setq ac-use-menu-map t)
-(setq ac-auto-start t)
-(setq ac-ignore-case nil)
+(setq ac-ignore-case 'smart)
+(setq ac-menu-height 20)
+
+(add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
+;(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
+(add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
+(add-hook 'css-mode-hook 'ac-css-mode-setup)
+(add-hook 'auto-complete-mode-hook 'ac-common-setup)
+(global-auto-complete-mode t)
+
+(defun my/auto-complete-at-point ()
+  (when (and (not (minibufferp))
+             (fboundp 'auto-complete-mode)
+             auto-complete-mode)
+    #'auto-complete))
+
+(defun my/add-ac-completion-at-point ()
+  (add-to-list 'completion-at-point-functions 'my/auto-complete-at-point))
+(add-hook 'auto-complete-mode-hook 'my/add-ac-completion-at-point)
+
+
 (ac-flyspell-workaround)
-(define-key ac-mode-map (kbd "M-/") 'auto-complete)
+;(define-key ac-mode-map (kbd "M-/") 'auto-complete)
 ;(define-key ac-mode-map (kbd "<lwindow> TAB") 'auto-complete)
-(define-key ac-mode-map (kbd "\C-c TAB") (lambda()(interactive)
-                                           (setq ac-auto-start
-                                                 (null ac-auto-start))))
-(setq ac-menu-height 20)
+;; (define-key ac-mode-map (kbd "\C-c TAB") (lambda()(interactive)
+;;                                            (setq ac-auto-start
+;;                                                  (null ac-auto-start))))
 ;; rtags
 (when (featurep 'rtags)
   (require 'rtags-ac)


(add-hook 'c-mode-common-hook
          (lambda()
            (set (make-local-variable 'ac-auto-start) nil)
            ;; we'll define a special key event for yasnippet
            (setq ac-sources (remove 'ac-source-yasnippet ac-sources))
            (setq ac-sources (remove 'ac-source-gtags ac-sources))
            (when (featurep 'rtags)
              (add-to-list 'ac-sources 'ac-source-rtags))
            (add-to-list 'ac-sources 'ac-source-etags)
            (add-to-list 'ac-sources 'ac-source-c-headers)
            ) t)                       ;append to hook list to take effect
                                       ;after ac-config-default
(add-hook 'protobuf-mode-hook

  ;; (add-hook 'flyspell-mode-hook #'flyspell-popup-auto-correct-mode)
  (defun my/toggle-flyspell() (interactive)
         (lambda() (flyspell-mode (if flyspell-mode 0 1))))
;  (global-set-key "\C-c\\t" #'my/toggle-flyspell)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; headers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
