Skip to content

Instantly share code, notes, and snippets.

Created May 3, 2010 22:13
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 anonymous/388648 to your computer and use it in GitHub Desktop.
Save anonymous/388648 to your computer and use it in GitHub Desktop.
;; a modified version from http://www.emacswiki.org/emacs/TabCompletion
(defun smart-tab (completion-hook)
"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 using the `completion-hook'.
Else indents the current line."
(interactive)
(if (string-match "Minibuf" (buffer-name))
(unless (minibuffer-complete)
(dabbrev-expand nil))
(if mark-active
(indent-region (region-beginning)
(region-end))
(if (looking-at "\\>")
(funcall completion-hook)
(indent-for-tab-command)))))
(add-hook 'clojure-mode-hook
(lambda ()
;; custom keybindings
(defun complete-clojure ()
(interactive)
(smart-tab 'slime-complete-symbol))
(local-set-key (kbd "<tab>") 'complete-clojure)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment