;;;;
;;;;;; Path, Load path and libraries
;;;;

(unless (boundp 'user-emacs-directory)
  (defvar user-emacs-directory "~/.emacs.d/"
    "Directory beneath which additional per-user Emacs-specific files are placed.
Various programs in Emacs store information in this directory.
Note that this should end with a directory separator.
See also `locate-user-emacs-file'."))
(unless (fboundp 'locate-user-emacs-file)
  (defun locate-user-emacs-file (new-name &optional old-name)
    "Return an absolute per-user Emacs-specific file name.
If OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME.
Else return NEW-NAME in `user-emacs-directory'."
    (convert-standard-filename
     (let* ((home (concat "~" (or init-file-user "")))
            (at-home (and old-name (expand-file-name old-name home))))
       (if (and at-home (file-readable-p at-home))
           at-home
         (abbreviate-file-name
          (expand-file-name new-name user-emacs-directory)))))))

;; add to load-path everything under elisp, recursively
(let ((default-directory (locate-user-emacs-file "elisp")))
  (normal-top-level-add-to-load-path '("."))
  (normal-top-level-add-subdirs-to-load-path))

;; this has paths, so should go first
(require 'ew-rc)

;; customization file (I don't like it, but some things go there)
(setq custom-file (locate-user-emacs-file "elisp/conf/ew-custom.el"))
(load custom-file t)

;; provides dependencies for other configuration files
(require 'ew-package)

(require 'ew-buffer)
(require 'ew-devel)
(require 'ew-edit)
(require 'ew-font)
(require 'ew-gnus)
(require 'ew-jabber)
(require 'ew-main)
(require 'ew-shell)
(require 'ew-vc)
(require 'ew-window)

;; load site-specific file, if available
(require 'ew-local nil t)