Permalink
Browse files

smart-tab.el: Clean name space and reorder defuns

Rename `call-completion-function' to
`smart-tab-call-completion-function' to make the
utility name space safe.

Reorder function defintions so that they are
defined before use.
  • Loading branch information...
1 parent 909a27d commit ba7803737646720e7b188d7aa324b362877d8ffa @jaalto jaalto committed with Dec 17, 2010
Showing with 23 additions and 23 deletions.
  1. +23 −23 smart-tab.el
View
@@ -74,23 +74,7 @@ smart-tab-using-hippie-expand"
:type 'sexp
:group 'smart-tab)
-;;;###autoload
-(defun smart-tab (prefix)
- "Try to 'do the smart thing' when tab is pressed.
-`smart-tab' attempts to expand the text before the point or
-indent the current line or selection.
-
-In a regular buffer, `smart-tab' will attempt to expand with
-either `hippie-expand' or `dabbrev-expand', depending on the
-value of `smart-tab-using-hippie-expand'. If the mark is active,
-or PREFIX is \\[universal-argument], then `smart-tab' will indent
-the region or the current line (if the mark is not active)."
- (interactive "P")
- (if (smart-tab-must-expand prefix)
- (call-completion-function))
- (smart-tab-default))
-
-(defun call-completion-function()
+(defun smart-tab-call-completion-function ()
"Get a completion function according to current major mode."
(let ((completion-function
(cdr (assq major-mode smart-tab-completion-functions-alist))))
@@ -100,6 +84,13 @@ the region or the current line (if the mark is not active)."
(dabbrev-expand nil))
(funcall completion-function))))
+(defun smart-tab-must-expand (&optional prefix)
+ "If PREFIX is \\[universal-argument] or the mark is active, do not expand.
+Otherwise, uses `hippie-expand' or `dabbrev-expand' to expand the text at point.."
+ (unless (or (consp prefix)
+ mark-active)
+ (looking-at "\\_>")))
+
(defun smart-tab-default ()
"Indents region if mark is active, or current line otherwise."
(interactive)
@@ -108,12 +99,21 @@ the region or the current line (if the mark is not active)."
(region-end))
(indent-for-tab-command)))
-(defun smart-tab-must-expand (&optional prefix)
- "If PREFIX is \\[universal-argument] or the mark is active, do not expand.
-Otherwise, uses `hippie-expand' or `dabbrev-expand' to expand the text at point.."
- (unless (or (consp prefix)
- mark-active)
- (looking-at "\\_>")))
+;;;###autoload
+(defun smart-tab (prefix)
+ "Try to 'do the smart thing' when tab is pressed.
+`smart-tab' attempts to expand the text before the point or
+indent the current line or selection.
+
+In a regular buffer, `smart-tab' will attempt to expand with
+either `hippie-expand' or `dabbrev-expand', depending on the
+value of `smart-tab-using-hippie-expand'. If the mark is active,
+or PREFIX is \\[universal-argument], then `smart-tab' will indent
+the region or the current line (if the mark is not active)."
+ (interactive "P")
+ (if (smart-tab-must-expand prefix)
+ (smart-tab-call-completion-function))
+ (smart-tab-default))
;;;###autoload
(defun smart-tab-mode-on ()

0 comments on commit ba78037

Please sign in to comment.