Skip to content

Instantly share code, notes, and snippets.

@mwilliams
Created January 14, 2010 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwilliams/276754 to your computer and use it in GitHub Desktop.
Save mwilliams/276754 to your computer and use it in GitHub Desktop.
(global-set-key [(tab)] 'smart-tab)
(defun smart-tab ()
"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)
(if (minibufferp)
(unless (minibuffer-complete)
(dabbrev-expand nil))
(if mark-active
(indent-region (region-beginning)
(region-end))
(if (looking-at "\\_>")
(dabbrev-expand nil)
(indent-for-tab-command)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment