Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
5.9 KiB

13 years ago
13 years ago
14 years ago
8 years ago
  1. ;;; init.el --- Prelude's configuration entry point.
  2. ;;
  3. ;; Copyright (c) 2011-2020 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://prelude.emacsredux.com
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; This file simply sets up the default load path and requires
  12. ;; the various modules defined within Emacs Prelude.
  13. ;;; License:
  14. ;; This program is free software; you can redistribute it and/or
  15. ;; modify it under the terms of the GNU General Public License
  16. ;; as published by the Free Software Foundation; either version 3
  17. ;; of the License, or (at your option) any later version.
  18. ;;
  19. ;; This program is distributed in the hope that it will be useful,
  20. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;; GNU General Public License for more details.
  23. ;;
  24. ;; You should have received a copy of the GNU General Public License
  25. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  26. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  27. ;; Boston, MA 02110-1301, USA.
  28. ;;; Code:
  29. ;; Added by Package.el. This must come before configurations of
  30. ;; installed packages. Don't delete this line. If you don't want it,
  31. ;; just comment it out by adding a semicolon to the start of the line.
  32. ;; You may delete these explanatory comments.
  33. ;(package-initialize)
  34. (defvar current-user
  35. (getenv
  36. (if (equal system-type 'windows-nt) "USERNAME" "USER")))
  37. (message "Prelude is powering up... Be patient, Master %s!" current-user)
  38. (when (version< emacs-version "25.1")
  39. (error "Prelude requires GNU Emacs 25.1 or newer, but you're running %s" emacs-version))
  40. ;; Always load newest byte code
  41. (setq load-prefer-newer t)
  42. (defvar prelude-dir (file-name-directory load-file-name)
  43. "The root dir of the Emacs Prelude distribution.")
  44. (defvar prelude-core-dir (expand-file-name "core" prelude-dir)
  45. "The home of Prelude's core functionality.")
  46. (defvar prelude-modules-dir (expand-file-name "modules" prelude-dir)
  47. "This directory houses all of the built-in Prelude modules.")
  48. (defvar prelude-personal-dir (expand-file-name "personal" prelude-dir)
  49. "This directory is for your personal configuration.
  50. Users of Emacs Prelude are encouraged to keep their personal configuration
  51. changes in this directory. All Emacs Lisp files there are loaded automatically
  52. by Prelude.")
  53. (defvar prelude-personal-preload-dir (expand-file-name "preload" prelude-personal-dir)
  54. "This directory is for your personal configuration, that you want loaded before Prelude.")
  55. (defvar prelude-vendor-dir (expand-file-name "vendor" prelude-dir)
  56. "This directory houses packages that are not yet available in ELPA (or MELPA).")
  57. (defvar prelude-savefile-dir (expand-file-name "savefile" prelude-dir)
  58. "This folder stores all the automatically generated save/history-files.")
  59. (defvar prelude-modules-file (expand-file-name "prelude-modules.el" prelude-personal-dir)
  60. "This file contains a list of modules that will be loaded by Prelude.")
  61. (unless (file-exists-p prelude-savefile-dir)
  62. (make-directory prelude-savefile-dir))
  63. (defun prelude-add-subfolders-to-load-path (parent-dir)
  64. "Add all level PARENT-DIR subdirs to the `load-path'."
  65. (dolist (f (directory-files parent-dir))
  66. (let ((name (expand-file-name f parent-dir)))
  67. (when (and (file-directory-p name)
  68. (not (string-prefix-p "." f)))
  69. (add-to-list 'load-path name)
  70. (prelude-add-subfolders-to-load-path name)))))
  71. ;; add Prelude's directories to Emacs's `load-path'
  72. (add-to-list 'load-path prelude-core-dir)
  73. (add-to-list 'load-path prelude-modules-dir)
  74. (add-to-list 'load-path prelude-vendor-dir)
  75. (prelude-add-subfolders-to-load-path prelude-vendor-dir)
  76. ;; reduce the frequency of garbage collection by making it happen on
  77. ;; each 50MB of allocated data (the default is on every 0.76MB)
  78. (setq gc-cons-threshold 50000000)
  79. ;; warn when opening files bigger than 100MB
  80. (setq large-file-warning-threshold 100000000)
  81. ;; preload the personal settings from `prelude-personal-preload-dir'
  82. (when (file-exists-p prelude-personal-preload-dir)
  83. (message "Loading personal configuration files in %s..." prelude-personal-preload-dir)
  84. (mapc 'load (directory-files prelude-personal-preload-dir 't "^[^#\.].*el$")))
  85. (message "Loading Prelude's core...")
  86. ;; the core stuff
  87. (require 'prelude-packages)
  88. (require 'prelude-custom) ;; Needs to be loaded before core, editor and ui
  89. (require 'prelude-ui)
  90. (require 'prelude-core)
  91. (require 'prelude-mode)
  92. (require 'prelude-editor)
  93. (require 'prelude-global-keybindings)
  94. ;; macOS specific settings
  95. (when (eq system-type 'darwin)
  96. (require 'prelude-macos))
  97. ;; Linux specific settings
  98. (when (eq system-type 'gnu/linux)
  99. (require 'prelude-linux))
  100. (message "Loading Prelude's modules...")
  101. ;; the modules
  102. (if (file-exists-p prelude-modules-file)
  103. (load prelude-modules-file)
  104. (message "Missing modules file %s" prelude-modules-file)
  105. (message "You can get started by copying the bundled example file from sample/prelude-modules.el"))
  106. ;; config changes made through the customize UI will be stored here
  107. (setq custom-file (expand-file-name "custom.el" prelude-personal-dir))
  108. ;; load the personal settings (this includes `custom-file')
  109. (when (file-exists-p prelude-personal-dir)
  110. (message "Loading personal configuration files in %s..." prelude-personal-dir)
  111. (mapc 'load (delete
  112. prelude-modules-file
  113. (directory-files prelude-personal-dir 't "^[^#\.].*\\.el$"))))
  114. (message "Prelude is ready to do thy bidding, Master %s!" current-user)
  115. ;; Patch security vulnerability in Emacs versions older than 25.3
  116. (when (version< emacs-version "25.3")
  117. (with-eval-after-load "enriched"
  118. (defun enriched-decode-display-prop (start end &optional param)
  119. (list start end))))
  120. (prelude-eval-after-init
  121. ;; greet the use with some useful tip
  122. (run-at-time 5 nil 'prelude-tip-of-the-day))
  123. ;;; init.el ends here