 			(substring-no-properties possible-syntax
 									 (length node-ac-evaluated-syntax)))))))
 
-;;; Main function: Start auto-complete process
-(defun node-ac-complete ()
+;;; Send auto-complete request to node.js for evaluation
+(defun node-ac-send-request-to-nodejs ()
   "Send the auto-complete request to node.js for evaluation.
 It spawns a new process async, and processes the results with
 `node-ac-update' as call-back."
-  ;; First get the current syntax
-  (let* ((point (point))
-		 syntax-for-eval context)
-	;; Check if the last evaluated syntax is a prefix of the possible syntax.
-	;; If true, no need to re-evaluate.
-	(unless (node-ac-evaluated-syntax-is-prefix-of-current-syntax)
-	  (when (setq syntax-for-eval (node-ac-syntax-under-cursor))
-		(node-ac-reset)
-		(setq node-ac-evaluating-syntax syntax-for-eval)
-		;; Put together a context for node.js evaluation before invoking auto-complete
-		(setq context (node-ac-generate-context (line-beginning-position)))
-		;; Start the process async
-		(setq node-ac-current-process
-			  (start-process node-ac-current-process-name node-ac-output-buffer-name
-							 "node" node-ac-js-source context syntax-for-eval))  ;; Execute this line in shell
-		;; When kill the process, kill quitely
-		(set-process-query-on-exit-flag node-ac-current-process nil)
-		;; Set call-back function
-		(set-process-sentinel node-ac-current-process 'node-ac-update-candidates)))))
+  (let ((syntax-for-eval (node-ac-syntax-under-cursor))
+		context)
+	(node-ac-reset)
+	(setq node-ac-evaluating-syntax syntax-for-eval)
+	;; Put together a context for node.js evaluation before invoking auto-complete
+	(setq context (node-ac-generate-context (line-beginning-position)))
+	;; Start the process async
+	(setq node-ac-current-process
+		  (start-process node-ac-current-process-name node-ac-output-buffer-name
+						 "node" node-ac-js-source context syntax-for-eval))  ;; Execute this line in shell
+	;; When kill the process, kill quitely
+	(set-process-query-on-exit-flag node-ac-current-process nil)
+	;; Set call-back function
+	(set-process-sentinel node-ac-current-process 'node-ac-update-candidates)))
 
 ;;; Auto-complete call-back function
 (defun node-ac-update-candidates (process event)

  - the point behind the last dot.

For  require('  case, the prefix point is at 'r'."
  (if (current-idle-time)
	  ;; Start completion immediately when emacs becomes idle for a while
	  (if node-ac-evaluated-syntax
		  ;; When there's an evaluated syntax, try to match the prefix
		  (let ((possible-syntax (node-ac-possible-syntax)))
			(if (and possible-syntax
					 (or (null ac-auto-start)
						 (>= (length possible-syntax) ac-auto-start)))
				;; Should start an auto-complete
				(let ((last-property-start-point (string-match "\\.[^\.]*$" possible-syntax)))
				  (if last-property-start-point
					  (+ (- (point) (length possible-syntax)) last-property-start-point 1)
					(- (point) (length possible-syntax))))
			  ;; Else, reset
			  (node-ac-reset)))
		;; If no syntax evaluated, return current point just to trigger a new evaluation
		(point))
	;; Emacs not idle now, schedule auto-completion in a while
	(when node-ac-idle-timer
	  (cancel-timer node-ac-idle-timer))
	;; (setq node-ac-idle-timer (run-with-idle-timer 0.1 0 'node-ac-auto-complete))
	(setq node-ac-idle-timer (run-with-idle-timer 0.1 0 'ac-complete-node))
	nil))

(ac-define-source "node"
  '((candidates . node-ac-candidates)
    (prefix . node-ac-prefix)
    (init . node-ac-complete)
    (requires . -1)))



(defcustom node-ac-doc-min-width 20
  "The min-width of the document strings for each line")

(defcustom node-ac-completion-delay 0.25
  "The delay sections before sending completion request to node.js.")


;;; Private variables

