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.

165 lines
6.5 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-2022 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; Version: 1.1.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 prelude-user
  35. (getenv
  36. (if (equal system-type 'windows-nt) "USERNAME" "USER")))
  37. (message "[Prelude] Prelude is powering up... Be patient, Master %s!" prelude-user)
  38. (when (version< emacs-version "25.1")
  39. (error "[Prelude] 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. ;; Define Prelude's directory structure
  43. (defvar prelude-dir (file-name-directory load-file-name)
  44. "The root dir of the Emacs Prelude distribution.")
  45. (defvar prelude-core-dir (expand-file-name "core" prelude-dir)
  46. "The home of Prelude's core functionality.")
  47. (defvar prelude-modules-dir (expand-file-name "modules" prelude-dir)
  48. "This directory houses all of the built-in Prelude modules.")
  49. (defvar prelude-personal-dir (expand-file-name "personal" prelude-dir)
  50. "This directory is for your personal configuration.
  51. Users of Emacs Prelude are encouraged to keep their personal configuration
  52. changes in this directory. All Emacs Lisp files there are loaded automatically
  53. by Prelude.")
  54. (defvar prelude-personal-preload-dir (expand-file-name "preload" prelude-personal-dir)
  55. "This directory is for your personal configuration, that you want loaded before Prelude.")
  56. (defvar prelude-vendor-dir (expand-file-name "vendor" prelude-dir)
  57. "This directory houses packages that are not yet available in ELPA (or MELPA).")
  58. (defvar prelude-savefile-dir (expand-file-name "savefile" user-emacs-directory)
  59. "This folder stores all the automatically generated save/history-files.")
  60. (defvar prelude-modules-file (expand-file-name "prelude-modules.el" prelude-personal-dir)
  61. "This file contains a list of modules that will be loaded by Prelude.")
  62. (unless (file-exists-p prelude-savefile-dir)
  63. (make-directory prelude-savefile-dir))
  64. (defun prelude-add-subfolders-to-load-path (parent-dir)
  65. "Add all level PARENT-DIR subdirs to the `load-path'."
  66. (dolist (f (directory-files parent-dir))
  67. (let ((name (expand-file-name f parent-dir)))
  68. (when (and (file-directory-p name)
  69. (not (string-prefix-p "." f)))
  70. (add-to-list 'load-path name)
  71. (prelude-add-subfolders-to-load-path name)))))
  72. ;; add Prelude's directories to Emacs's `load-path'
  73. (add-to-list 'load-path prelude-core-dir)
  74. (add-to-list 'load-path prelude-modules-dir)
  75. (add-to-list 'load-path prelude-vendor-dir)
  76. (prelude-add-subfolders-to-load-path prelude-vendor-dir)
  77. ;; reduce the frequency of garbage collection by making it happen on
  78. ;; each 50MB of allocated data (the default is on every 0.76MB)
  79. (setq gc-cons-threshold 50000000)
  80. ;; warn when opening files bigger than 100MB
  81. (setq large-file-warning-threshold 100000000)
  82. ;; preload the personal settings from `prelude-personal-preload-dir'
  83. (when (file-exists-p prelude-personal-preload-dir)
  84. (message "[Prelude] Loading personal configuration files in %s..." prelude-personal-preload-dir)
  85. (mapc 'load (directory-files prelude-personal-preload-dir 't "^[^#\.].*el$")))
  86. (message "[Prelude] Loading Prelude's core modules...")
  87. ;; load the core stuff
  88. (require 'prelude-packages)
  89. (require 'prelude-custom) ;; Needs to be loaded before core, editor and ui
  90. (require 'prelude-ui)
  91. (require 'prelude-core)
  92. (require 'prelude-mode)
  93. (require 'prelude-editor)
  94. (require 'prelude-global-keybindings)
  95. ;; macOS specific settings
  96. (when (eq system-type 'darwin)
  97. (require 'prelude-macos))
  98. ;; Linux specific settings
  99. (when (eq system-type 'gnu/linux)
  100. (require 'prelude-linux))
  101. ;; WSL specific setting
  102. (when (and (eq system-type 'gnu/linux) (getenv "WSLENV"))
  103. (require 'prelude-wsl))
  104. ;; Windows specific settings
  105. (when (eq system-type 'windows-nt)
  106. (require 'prelude-windows))
  107. (message "[Prelude] Loading Prelude's additional modules...")
  108. ;; the modules
  109. (if (file-exists-p prelude-modules-file)
  110. (load prelude-modules-file)
  111. (message "[Prelude] Missing personal modules file %s" prelude-modules-file)
  112. (message "[Prelude] Falling back to the bundled example file sample/prelude-modules.el")
  113. (message "[Prelude] You should copy this file to your personal configuration folder and tweak it to your liking")
  114. (load (expand-file-name "sample/prelude-modules.el" prelude-dir)))
  115. ;; config changes made through the customize UI will be stored here
  116. (setq custom-file (expand-file-name "custom.el" prelude-personal-dir))
  117. ;; load the personal settings (this includes `custom-file')
  118. (when (file-exists-p prelude-personal-dir)
  119. (message "[Prelude] Loading personal configuration files in %s..." prelude-personal-dir)
  120. (mapc 'load (delete
  121. prelude-modules-file
  122. (directory-files prelude-personal-dir 't "^[^#\.].*\\.el$"))))
  123. (message "[Prelude] Prelude is ready to do thy bidding, Master %s!" prelude-user)
  124. ;; Patch security vulnerability in Emacs versions older than 25.3
  125. (when (version< emacs-version "25.3")
  126. (with-eval-after-load "enriched"
  127. (defun enriched-decode-display-prop (start end &optional param)
  128. (list start end))))
  129. (prelude-eval-after-init
  130. ;; greet the use with some useful tip
  131. (run-at-time 5 nil 'prelude-tip-of-the-day))
  132. ;;; init.el ends here