   (with-current-buffer buffer
     (let* ((column-num (+ 1 (ycmd--column-in-bytes)))
            (line-num (line-number-at-pos pos))
-           (full-path (ycmd--encode-string (or (buffer-file-name) "")))
+           (full-path (ycmd--get-full-path-to-current-buffer))
            (file-contents (ycmd--encode-string
                            (buffer-substring-no-properties
                             (point-min) (point-max))))

(defvar-local ycmd--last-status-change 'unparsed
  "The last status of the current buffer.")

(defvar ycmd--mode-keywords-loaded nil
  "List of modes for which keywords have been loaded.")


       (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"
                         `(("unloaded_buffer" . ,(ycmd--get-full-path-to-current-buffer)))))
  (ycmd--teardown))

(defun ycmd--teardown ()
  "Teardown ycmd in current buffer."
  (ycmd--kill-timer ycmd--notification-timer)
