init.el 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ;; init.el --- user-init-file -*- emacs-lisp -*-
  2. ;;; Code:
  3. ;; load newest byte code
  4. (setq load-prefer-newer t)
  5. ;; Added by package.el
  6. (package-initialize)
  7. (setq package-archives
  8. '(("melpa" . "https://melpa.milkbox.net/packages/")
  9. ;; ("melpa-stable" . "https://melpa-stable.milkbox.net/packages/")
  10. ("gnu" . "https://elpa.gnu.org/packages/")
  11. ("org" . "https://orgmode.org/elpa/")))
  12. ;(setq package-archive-priorities
  13. ; '(("melpa" . 3)
  14. ; ("melpa-stable" . 0)
  15. ; ("gnu" . 1)
  16. ; ("org" . 2)))
  17. ;; Bootstrap `use-package'
  18. (unless (package-installed-p 'use-package)
  19. (package-refresh-contents)
  20. (package-install 'use-package))
  21. (eval-when-compile
  22. (require 'use-package))
  23. ;; Always ensure packages
  24. (setq use-package-always-ensure t)
  25. (use-package diminish)
  26. (use-package bind-key)
  27. (use-package validate)
  28. (defun load-directory (dir)
  29. "Load all files in a directory"
  30. (let ((load-it (lambda (f)
  31. (load-file (concat (file-name-as-directory dir) f)))
  32. ))
  33. (mapc load-it (directory-files dir nil "\\.el$"))))
  34. (defun add-subdirs-to-load-path (dir)
  35. "Recursive add directories to `load-path'."
  36. (let ((default-directory (file-name-as-directory dir)))
  37. (add-to-list 'load-path dir)
  38. (normal-top-level-add-subdirs-to-load-path)))
  39. ;; Load settings
  40. (add-subdirs-to-load-path (expand-file-name "lib" user-emacs-directory))
  41. (load-directory (expand-file-name "etc/core" user-emacs-directory))
  42. (load-directory (expand-file-name "etc/packages" user-emacs-directory))
  43. ;; Redirect customize settings to custom.el
  44. (setq custom-file (expand-file-name "var/custom.el" user-emacs-directory))
  45. (when (file-exists-p custom-file)
  46. (load custom-file))