Skip to content

Commit

Permalink
More intelligent fall back when not expanding.
Browse files Browse the repository at this point in the history
Rather than calling `indent-for-tab-command', do a search for a binding of tab
in any active minor mode map (aside from `smart-tab-mode'), then search the
major mode's binding, then the global binding. This allows a fallback to the
mode-specific binding of tab.

Signed-off-by: Dan Hackney <chrono325@gmail.com>
  • Loading branch information
Dan Hackney committed Aug 9, 2009
1 parent 8134a70 commit 7c80c79
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions smart-tab.el
Expand Up @@ -74,15 +74,24 @@ the region or the current line (if the mark is not active)."
(if smart-tab-using-hippie-expand
(hippie-expand nil)
(dabbrev-expand nil))
(smart-indent)))
(smart-tab-default)))

(defun smart-indent ()
(defun smart-tab-default ()
"Indents region if mark is active, or current line otherwise."
(interactive)
(if mark-active
(indent-region (region-beginning)
(region-end))
(indent-for-tab-command)))

(call-interactively
(or
;; Minor mode maps for tab (without smart-tab-mode)
(cdar (assq-delete-all 'smart-tab-mode (minor-mode-key-binding "\t")))
(cdar (assq-delete-all 'smart-tab-mode (minor-mode-key-binding [(tab)])))
(local-key-binding "\t")
(local-key-binding [(tab)])
(global-key-binding "\t")
(global-key-binding [(tab)])))))

(defun smart-tab-must-expand (&optional prefix)
"If PREFIX is \\[universal-argument] or the mark is active, do not expand.
Expand Down

0 comments on commit 7c80c79

Please sign in to comment.