   (dolist (it ycmd-file-type-map)
     (add-hook (intern (format "%s-hook" (symbol-name (car it)))) 'ycmd-mode)))
 (make-obsolete 'ycmd-setup 'global-ycmd-mode "0.9.1")
+
+(defun ycmd-version (&optional show-version)
+  "Get the `emacs-ycmd' version as string.
+
+If called interactively or if SHOW-VERSION is non-nil, show the
+version in the echo area and the messages buffer.
+
+The returned string includes both, the version from package.el
+and the library version, if both a present and different.
+
+If the version number could not be determined, signal an error,
+if called interactively, or if SHOW-VERSION is non-nil, otherwise
+just return nil."
+  (interactive (list t))
+  (if (require 'pkg-info nil :no-error)
+      (let ((version (pkg-info-version-info 'ycmd)))
+        (when show-version
+          (message "emacs-ycmd version: %s" version))
+        version)
+    (error "Cannot determine version without package pkg-info")))
 
 (defun ycmd--maybe-enable-mode ()
   "Enable `ycmd-mode' according `ycmd-global-modes'."

(defun ycmd-show-debug-info ()
  "Show debug information."
  (interactive)
  (when ycmd-mode
    (let ((data (ycmd--get-request-data)))
      (deferred:$
        (ycmd--request "/debug_info" (plist-get data :content))
        (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)))
                  (princ ":\n\n")
                  (insert res)
                  (princ "\n\n")
                  (insert (format "Server running at: %s:%d"
                                  ycmd-host ycmd--server-actual-port)))))))))))

(defun ycmd--get-request-hmac (method path body)
  "Generate HMAC for request from METHOD, PATH and BODY."

(require 'diff)
(require 'diff-mode)

(declare-function pkg-info-version-info "pkg-info" (package))

(defgroup ycmd nil
  "a ycmd emacs client"
