   "Get the full (encoded) path to the buffer returned by `current-buffer`, or the empty string."
   (ycmd--encode-string (or (buffer-file-name) "")))
 
-(defun ycmd--standard-content (buffer pos)
+(defun ycmd--get-request-data ()
   "Generate the 'standard' content for ycmd posts.
 
 This extracts a bunch of information from BUFFER at POS which
 will be passed to the ycmd server."
-  (with-current-buffer buffer
-    (let* ((column-num (+ 1 (ycmd--column-in-bytes)))
-           (line-num (line-number-at-pos pos))
-           (full-path (ycmd--get-full-path-to-current-buffer))
-           (file-contents (ycmd--encode-string
-                           (buffer-substring-no-properties
-                            (point-min) (point-max))))
-           (file-types (or (ycmd-major-mode-to-file-types major-mode)
-                           '("generic"))))
-      `(("file_data" .
-         ((,full-path . (("contents" . ,file-contents)
-                         ("filetypes" . ,file-types)))))
-        ("filepath" . ,full-path)
-        ("line_num" . ,line-num)
-        ("column_num" . ,column-num)))))
+  (let* ((buffer (current-buffer))
+         (pos (point))
+         (column-num (+ 1 (ycmd--column-in-bytes)))
+         (line-num (line-number-at-pos pos))
+         (full-path (ycmd--get-full-path-to-current-buffer))
+         (file-contents (ycmd--encode-string
+                         (buffer-substring-no-properties
+                          (point-min) (point-max))))
+         (file-types (or (ycmd-major-mode-to-file-types major-mode)
+                         '("generic")))
+         (data `(("file_data" .
+                  ((,full-path . (("contents" . ,file-contents)
+                                  ("filetypes" . ,file-types)))))
+                 ("filepath" . ,full-path)
+                 ("line_num" . ,line-num)
+                 ("column_num" . ,column-num))))
+    (list :content data :buffer buffer :pos pos)))
 
 (defvar ycmd--log-enabled nil
   "If non-nil, http content will be logged.

    (if (ycmd-parsing-in-progress-p)
        (message "Can't send \"%s\" request while parsing is in progress!"
                 subcommand)
      (let* ((buffer (current-buffer))
             (pos (point))
             (subcommand (if (listp subcommand)
                             subcommand
                           (list subcommand)))
             (content (cons (append (list "command_arguments")
                                    subcommand)
                            (ycmd--standard-content buffer pos))))
        (deferred:$
          (ycmd--request "/run_completer_command"
                         content :parser 'json-read)

  "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)))
