 	    (when (< 3000 cont) ; timeout after 3 seconds
 	      (error "Server timeout.")))))))))
 
-(defun ycmd-load-conf-file (filename)
-  (interactive
-   (list
-    (read-file-name "Filename: ")))
-  (let ((filename (expand-file-name filename)))
-    (ycmd-request
-     "/load_extra_conf_file"
-     `(("filepath" . ,filename)))))
-
-(defun ycmd-display-completions (pos)
-  (interactive "d")
-  (let ((completions (ycmd-get-completions pos)))
-    (pop-to-buffer "*ycmd-completions*")
-    (erase-buffer)
-    (insert (pp-to-string completions))))
-
-(defun ycmd-get-completions (pos)
-  (let* ((column-num (+ 1 (save-excursion (goto-char pos) (current-column))))
-         (line-num (line-number-at-pos (point)))
-         (full-path (buffer-file-name))
-         (file-contents (buffer-string))
-         (file-types '("cpp"))
-         (content `(("column_num" . ,column-num)
-                    ("file_data" .
-                     ((,full-path . (("contents" . ,file-contents)
-                                     ("filetypes" . ,file-types)))))
-                    ("filepath" . ,full-path)
-                    ("line_num" . ,line-num))))
-         (ycmd-request "/completions" content :parser 'json-read)))
-
 (defun* ycmd-request (location content &key (parser 'buffer-string))
+  "Send a request to the ycmd server.
+
+LOCATION specifies the location portion of the URL. For example,
+if LOCATION is '/feed_llama', the request URL is
+'http://host:port/feed_llama'.
+
+CONTENT will be JSON-encoded and sent over at the content of the
+HTTP message.
+
+PARSER specifies the function that will be used to parse the
+response to the message. Typical values are buffer-string and
+json-read. This function will be passed an the completely
+unmodified contents of the response (i.e. not JSON-decoded or
+anything like that.)
+"
   (let* ((content (json-encode content))
          (hmac (ycmd-hmac-function content ycmd-hmac-secret))
          (hex-hmac (encode-hex-string hmac))

(require 'json)
(require 'request)

(defcustom ycmd-host "127.0.0.1"
  "The host on which the ycmd server is running."
  :type '(string)

  defconst. It is not, however, treated as a constant by this
  code. This value gets set in ycmd-open.")

(defconst ycmd-server-process "ycmd-server"
  "The emacs name of the server process. This is used by
  functions like start-process, get-process, and delete-process.")

(defun ycmd-generate-hmac-secret ()
  "Generate a new, random 16-byte HMAC secret key."
  (let ((result '()))
    (dotimes (x 16 result)
      (setq result (cons (byte-to-string (random 256)) result)))
    (apply 'concat result)))

(defun ycmd-json-encode (obj)
  "A version of json-encode that uses {} instead of null for nil
