 ;;-------------------------------------------
 ;;; auto load module
 ;;-------------------------------------------
+(defvar modules-with-manual nil)
+
+(defun module-get-path (&optional directory)
+  (or directory (expand-file-name "module" user-emacs-directory)))
+
 (defun module-load (path)
   (when (file-exists-p path)
     (if (file-directory-p path)

      (ignore-errors (load path t)))))

(defun autoload-modules (&optional directory)
  (let* ((dir (or directory
                  (expand-file-name "module"
                                    user-emacs-directory)))
         (files (directory-files dir))
         (module-files (remove-if-not
                        (lambda (x) (string-match-p "^module-" x))

  (when (not (executable-find exec))
    (throw 'require-exit nil)))

(defun module-require-manual ()
  (throw 'require-manual nil))

(defun module-install ()
  (interactive)
  (flet ((module-require-manual () nil))
    (let* ((dir (file-name-as-directory (module-get-path)))
           (path (concat
                  dir
                  (format "module-%s.el"
                          (read-string (format "module at %s: " dir))))))
      (module-load path))))

(provide 'core-module)
