 (setq ff-always-try-to-create nil)
 ;; Preserve line position on scroll
 (setq scroll-preserve-screen-position t)
-;; Ignore case when completing file names
-(setq read-file-name-completion-ignore-case nil)
 (show-paren-mode t)
 (size-indication-mode 1)
 ;; don't add new-lines to end of buffer on scroll


(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

      '(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 csv-mode
                 mock-mode org-mode html-mode text-mode sql-mode
                 sql-interactive-mode
                 git-commit-mode
                 ))
(require 'auto-complete-config)
(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-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 "<lwindow> TAB") 'auto-complete)
;; (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)
