   "The version number of Erlang mode.")
 
 (defcustom erlang-root-dir nil
-  "The directory where the Erlang system is installed.
-The name should not contain the trailing slash.
+  "The directory where the Erlang man pages are installed. The
+name should not contain a trailing slash.
 
 Should this variable be nil, no manual pages will show up in the
-Erlang mode menu."
+Erlang mode menu unless man pages have been downloaded by Erlang
+mode (see below).
+
+You can download the Erlang man pages automatically by placing
+the following lines in your Emacs init file or by executing the
+Emacs command `M-x erlang-man-download-ask RET' (the download URL
+can be customized with the Emacs variable
+erlang-man-download-url):
+
+    (require 'erlang)
+    (erlang-man-download)
+
+"
   :group 'erlang
   :type '(restricted-sexp :match-alternatives (stringp 'nil))
   :safe (lambda (val) (or (eq nil val) (stringp val))))

      '(("Man Pages"
         (("Error! Why?" erlang-man-describe-error)))))))

(defun erlang-man-dir (subdir)
  (let ((default_man_dir (concat (file-name-as-directory erlang-root-dir)
                                 (file-name-as-directory "lib")
                                 (file-name-as-directory "erlang") subdir)))
    (if (or (equal erlang-root-dir nil) (file-directory-p default_man_dir))
        default_man_dir
      (concat (file-name-as-directory erlang-root-dir) subdir)
      )
    )
  )

;; Should the menu be to long, let's split it into a number of
;; smaller menus.  Warning, this code contains beautiful

      (setq dir (cond ((nth 2 (car dir-list))
                       ;; Relative to `erlang-root-dir'.
                       (and (stringp erlang-root-dir)
                            (erlang-man-dir (nth 1 (car dir-list)) t)))
                      (t
                       ;; Absolute
                       (nth 1 (car dir-list)))))
