     (ycmd--report-status 'parsed)
     (run-hook-with-args 'ycmd-file-parse-result-hook response)))
 
-(defun ycmd--notify-server (event-name &optional event-content-alist)
-  "Send a simple event notification for EVENT-NAME to the
-server, ignoring response. Optionally, include EVENT-CONTENT-ALIST
-as additional content in the request."
-  (let* ((buff (current-buffer))
-         (pos (point))
-         (content (append (cons `("event_name" . ,event-name)
-                                (ycmd--standard-content buff pos))
-                          event-content-alist)))
+(defun ycmd--event-notification (event-name content-alist &optional handler)
+  "Send a event notification for EVENT-NAME.
+CONTENT-ALIST cotains the request data.  Optional third argument
+HANDLER is the callback function for the response."
+  (let ((content (append `(("event_name" . ,event-name))
+                         content-alist)))
     (deferred:$
       ;; try
-      (ycmd--request "/event_notification"
-                     content
-                     :parser 'json-read)
+      (deferred:$
+        (ycmd--request "/event_notification"
+                       content :parser 'json-read)
+        (deferred:nextc it handler))
       (deferred:error it
         (lambda (err)
           (message "Error sending %s request: %s" event-name err)
           (ycmd--report-status 'errored))))))
 
+(defun ycmd--notify-server (event-name &optional event-content-alist)
+  "Send a simple event notification for EVENT-NAME, ignoring response.
+Optionally, include EVENT-CONTENT-ALIST as additional content in
+the request."
+  (let* ((data (ycmd--get-request-data))
+         (content (append (plist-get data :content)
+                          event-content-alist)))
+    (ycmd--event-notification event-name content)))
+
 (defun ycmd-notify-file-ready-to-parse ()
   "Send a notification to ycmd that the buffer is ready to be parsed.
 

The response of the notification are passed to all of the
functions in `ycmd-file-parse-result-hook'."
  (when (and ycmd-mode (not (ycmd-parsing-in-progress-p)))
    (let* ((buff (current-buffer))
           (pos (point))
           (content
            (append '(("event_name" . "FileReadyToParse"))
                    (ycmd--standard-content buff pos)
                    (--when-let (and ycmd-tag-files
                                     (ycmd--get-tag-files buff))
                      (list (cons "tag_files" it)))
                    (--when-let (and ycmd-seed-identifiers-with-keywords
                                     (ycmd--get-keywords buff))
                      (list (cons "syntax_keywords" it))))))
      (deferred:$
        ;; try
        (deferred:$
          ;; Record that the buffer is being parsed
          (ycmd--report-status 'parsing)

          ;; Make the request.
          (ycmd--request "/event_notification"
                         content
                         :parser 'json-read)

          (deferred:nextc it
            (lambda (response)
              (with-current-buffer buff
                (ycmd--handle-notify-response response)))))

        ;; catch
        (deferred:error it
          (lambda (err)
            (message "Error sending notification request: %s" err)
            (ycmd--report-status 'errored)))))))

(defun ycmd-major-mode-to-file-types (mode)
  "Map a major mode MODE to a list of file-types suitable for ycmd.

  "Show debug information."
  (interactive)
  (when ycmd-mode
    (let ((data (ycmd--get-request-data)))
      (deferred:$
        (ycmd--request "/debug_info"
                       (plist-get data :content)
                       :parser 'json-read)
        (deferred:nextc it
          (lambda (res)
            (when res
              (with-help-window (get-buffer-create " *ycmd-debug-info*")
                (with-current-buffer standard-output
                  (princ "ycmd debug information for buffer ")
                  (insert (propertize (buffer-name (plist-get data :buffer))
                                      'face 'bold))
                  (princ " in ")
                  (let ((mode (buffer-local-value
                               'major-mode (plist-get data :buffer))))
                    (insert-button (symbol-name mode)
                                   'type 'help-function
                                   'help-args (list mode)))
