   :type 'boolean
   :group 'auto-complete)
 
-(defface ac-menu-face
+(defface ac-completion-face
+  '((t (:background "darkblue" :foreground "white")))
+  "Face for inline completion"
+  :group 'auto-complete)
+
+(defface ac-candidate-face
   '((t (:background "lightgray" :foreground "black")))
-  "Face for candidate menu."
+  "Face for candidate."
   :group 'auto-complete)
 
 (defface ac-selection-face
   '((t (:background "blue" :foreground "white")))
-  "Face for the selected candidate."
+  "Face for selected candidate."
   :group 'auto-complete)
 
 (defvar auto-complete-mode-hook nil
   "Hook for `auto-complete-mode'.")
+
+(defvar ac-completion-overlay nil
+  "Overlay of showing inline completion.")
 
 (defvar ac-menu nil
   "Menu instance.")

       (let ((selection (1- ac-selection)))
         (if (< selection ac-menu-offset)
             (if (= ac-menu-scroll 0)
                 (prog1 (1- (+ ac-menu-offset (min ac-candidate-menu-height (length ac-candidates))))
                   (setq ac-menu-scroll (- (length ac-candidates) (min ac-candidate-menu-height (length ac-candidates))))
                   (ac-redraw-candidates))
               (setq ac-menu-scroll (1- ac-menu-scroll))
               (ac-redraw-candidates)
               ac-selection)
           selection)))))

(defun ac-expand-1 ()
  "Try expansion."
  (let ((string (overlay-get (ac-menu-line-overlay ac-menu ac-selection) 'real-string)))
    (delete-region ac-point (point))
    (insert string)
    (setq ac-prefix string)))

(defun ac-expand ()
  "Try expansion but select next if expanded twice."
  (interactive)
  (if (and ac-dwim ac-dwim-enable)
      (ac-complete)
    (let ((target ac-prefix)
          (string (ac-expand-1)))
      (when (equal target string)
        (ac-next)
        (ac-expand-1)))))

(defun ac-expand-common ()
  "Try expansion common part."

  (interactive)
  (let* ((candidate (ac-get-selected-candidate))
         (action (ac-get-candidate-action candidate)))
    (ac-expand-string candidate)
    (if action
        (funcall action))
    (ac-abort)))
