Created
April 4, 2015 03:01
-
-
Save ajchemist/aae8794c08ef0467c799 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun check-expansion () | |
| (save-excursion | |
| (cond ((looking-at "\\_>") t) | |
| ((unless (bobp) (backward-char 1) (looking-at "\\.")) t) | |
| ((unless (bobp) (backward-char 1) (looking-at "->")) t) | |
| (t nil)))) | |
| (defun smart-tab (&optional prefix) | |
| "This smart tab is minibuffer compliant: it acts as usual in | |
| the minibuffer. Else, if mark is active, indents region. Else if | |
| point is at the end of a symbol, expands it. Else indents the | |
| current line." | |
| (interactive "P") | |
| (cond ((minibufferp) | |
| (unless (minibuffer-complete) | |
| (dabbrev-expand nil))) | |
| ((use-region-p) ;mark-active | |
| (indent-region (region-beginning) | |
| (region-end))) | |
| ((check-expansion) (hippie-expand prefix)) | |
| ((indent-for-tab-command)))) | |
| (defun tab-indent-or-complete (&optional prefix) | |
| (interactive "P") | |
| (cond ((minibufferp) | |
| (unless (minibuffer-complete) (dabbrev-expand nil))) | |
| ((and yas-minor-mode | |
| (let ((yas-fallback-behavior 'return-nil)) | |
| (yas-expand)))) | |
| ((and (check-expansion) (company-complete-common))) | |
| ((indent-for-tab-command)))) | |
| (global-set-key [?\t] #'tab-indent-or-complete) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment