   '((after-save-hook                  . ycmd--on-save)
     (after-change-functions           . ycmd--on-change)
     (window-configuration-change-hook . ycmd--on-window-configuration-change)
-    (kill-buffer-hook                 . ycmd--close-buffer)
+    (kill-buffer-hook                 . ycmd--on-close-buffer)
     (before-revert-hook               . ycmd--teardown))
   "Hooks which ycmd hooks in.")
 

       (when ycmd-mode
         ,@body))))

(defun ycmd--close-buffer ()
  "Notify server that the current buffer is no longer open, and cleanup emacs-ycmd variables."
  (when (ycmd-running?)
    (ycmd--notify-server "BufferUnload"

  (when (and ycmd-mode
             (or (not condition)
                 (memq condition ycmd-parse-conditions)))
    (ycmd--on-visit-buffer)
    (ycmd-notify-file-ready-to-parse)))

(defun ycmd--on-save ()
