Commits

Anonymous committed 2f3cbaa

Better handling of tab

Comments (0)

Files changed (1)

 (require 'auto-complete-config)
 (add-to-list 'ac-dictionary-directories "~/.emacs.d/el-get/auto-complete/dict")
 (ac-config-default)
-(ac-set-trigger-key "TAB")
+;(define-key ac-mode-map (kbd "TAB") 'auto-complete)
+;(ac-set-trigger-key "TAB")
 (setq ac-auto-start nil)
 (add-to-list 'ac-sources 'ac-source-yasnippet)
 (ac-ropemacs-initialize)
 (add-hook 'python-mode-hook
           (lambda ()
             (add-to-list 'ac-sources 'ac-source-ropemacs)))
-; You need gocode for this to work
-; Check https://github.com/nsf/gocode
 (require 'go-autocomplete)
 
+; Fancy tab function to either complete or indent
+(defun fancy-tab (arg)
+  (interactive "P")
+  (setq this-command last-command)
+  (if (or (eq this-command 'auto-complete) (looking-at "\\_>"))
+      (progn
+	(setq this-command 'auto-complete)
+	(auto-complete arg))
+    (setq this-command 'indent-for-tab-command)
+    (indent-for-tab-command arg)))
+
+(define-key ac-mode-map (kbd "TAB") 'fancy-tab)
+
 ; Sunrise commander
 (require 'sunrise-commander)