 ;;
 ;;   (set-variable 'ycmd-extra-conf-whitelist '("~/projects/*"))
 ;;
-;; Now, wo start a ycmd server, use 'ycmd-open. Then you can use
-;; 'ycmd-get-completions to get completions at some point in a
+;; Now, the first time you open a file for which ycmd can perform
+;; completions, a ycmd server will be automatically started.
+;;
+;; Use 'ycmd-get-completions to get completions at some point in a
 ;; file. For example:
 ;;
-;;   (ycmd-open)
 ;;   (ycmd-get-completions)
 ;;
 ;; You can use 'ycmd-display-completions to toy around with completion

    (ycmd--start-server hmac-secret)
    (setq ycmd--hmac-secret hmac-secret))

  (ycmd--start-notification-timer)

  (add-hook 'find-file-hook 'ycmd-notify-file-ready-to-parse)
  (add-hook 'kill-emacs-hook 'ycmd-close))

(defun ycmd-close ()
  "Shutdown any running ycmd server.

    (ycmd--log-content "HTTP RESPONSE CONTENT" response)
    response))

(defun ycmd--on-find-file ()
  (when (ycmd--major-mode-to-file-types major-mode)
    (unless (ycmd-running?) (ycmd-open))
    (ycmd-notify-file-ready-to-parse)))

(add-hook 'find-file-hook 'ycmd--on-find-file)
(add-hook 'kill-emacs-hook 'ycmd-close)

(provide 'ycmd)

;;; ycmd.el ends here
