emacs-prelude/init.el

166 lines
6.5 KiB
EmacsLisp
Raw Permalink Normal View History

;;; init.el --- Prelude's configuration entry point.
2011-10-08 23:05:06 +03:00
;;
2023-02-24 08:57:29 +02:00
;; Copyright (c) 2011-2023 Bozhidar Batsov
2011-10-08 23:05:06 +03:00
;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
2020-09-15 09:19:15 +03:00
;; URL: https://github.com/bbatsov/prelude
2021-02-14 12:28:40 +02:00
;; Version: 1.1.0
2011-10-08 23:05:06 +03:00
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; Commentary:
;; This file simply sets up the default load path and requires
;; the various modules defined within Emacs Prelude.
;;; License:
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;(package-initialize)
2020-09-16 08:44:38 +03:00
(defvar prelude-user
2017-01-04 01:20:26 +02:00
(getenv
(if (equal system-type 'windows-nt) "USERNAME" "USER")))
(message "[Prelude] Prelude is powering up... Be patient, Master %s!" prelude-user)
2018-07-10 09:01:24 +03:00
(when (version< emacs-version "25.1")
(error "[Prelude] Prelude requires GNU Emacs 25.1 or newer, but you're running %s" emacs-version))
2013-09-05 14:24:38 +03:00
2014-04-03 15:43:51 +03:00
;; Always load newest byte code
(setq load-prefer-newer t)
2020-09-16 08:44:38 +03:00
;; Define Prelude's directory structure
(defvar prelude-dir (file-name-directory load-file-name)
"The root dir of the Emacs Prelude distribution.")
(defvar prelude-core-dir (expand-file-name "core" prelude-dir)
"The home of Prelude's core functionality.")
(defvar prelude-modules-dir (expand-file-name "modules" prelude-dir)
"This directory houses all of the built-in Prelude modules.")
(defvar prelude-personal-dir (expand-file-name "personal" prelude-dir)
2013-03-10 19:44:52 +02:00
"This directory is for your personal configuration.
Users of Emacs Prelude are encouraged to keep their personal configuration
changes in this directory. All Emacs Lisp files there are loaded automatically
by Prelude.")
(defvar prelude-personal-preload-dir (expand-file-name "preload" prelude-personal-dir)
"This directory is for your personal configuration, that you want loaded before Prelude.")
(defvar prelude-vendor-dir (expand-file-name "vendor" prelude-dir)
2013-03-10 19:44:52 +02:00
"This directory houses packages that are not yet available in ELPA (or MELPA).")
(defvar prelude-savefile-dir (expand-file-name "savefile" user-emacs-directory)
"This folder stores all the automatically generated save/history-files.")
(defvar prelude-modules-file (expand-file-name "prelude-modules.el" prelude-personal-dir)
"This file contains a list of modules that will be loaded by Prelude.")
2011-10-07 23:47:41 +03:00
(unless (file-exists-p prelude-savefile-dir)
(make-directory prelude-savefile-dir))
(defun prelude-add-subfolders-to-load-path (parent-dir)
"Add all level PARENT-DIR subdirs to the `load-path'."
(dolist (f (directory-files parent-dir))
(let ((name (expand-file-name f parent-dir)))
(when (and (file-directory-p name)
(not (string-prefix-p "." f)))
(add-to-list 'load-path name)
(prelude-add-subfolders-to-load-path name)))))
2012-02-14 17:48:03 +02:00
;; add Prelude's directories to Emacs's `load-path'
(add-to-list 'load-path prelude-core-dir)
(add-to-list 'load-path prelude-modules-dir)
2012-04-18 12:31:11 +03:00
(add-to-list 'load-path prelude-vendor-dir)
(prelude-add-subfolders-to-load-path prelude-vendor-dir)
2013-07-13 10:01:19 +03:00
;; reduce the frequency of garbage collection by making it happen on
;; each 50MB of allocated data (the default is on every 0.76MB)
(setq gc-cons-threshold 50000000)
;; warn when opening files bigger than 100MB
(setq large-file-warning-threshold 100000000)
;; preload the personal settings from `prelude-personal-preload-dir'
(when (file-exists-p prelude-personal-preload-dir)
(message "[Prelude] Loading personal configuration files in %s..." prelude-personal-preload-dir)
(mapc 'load (directory-files prelude-personal-preload-dir 't "^[^#\.].*el$")))
(message "[Prelude] Loading Prelude's core modules...")
2020-09-16 08:44:38 +03:00
;; load the core stuff
2011-10-08 23:05:06 +03:00
(require 'prelude-packages)
(require 'prelude-custom) ;; Needs to be loaded before core, editor and ui
(require 'prelude-ui)
2011-10-08 23:05:06 +03:00
(require 'prelude-core)
2012-02-23 18:02:34 +02:00
(require 'prelude-mode)
2011-10-08 23:05:06 +03:00
(require 'prelude-editor)
(require 'prelude-global-keybindings)
;; macOS specific settings
(when (eq system-type 'darwin)
(require 'prelude-macos))
;; Linux specific settings
(when (eq system-type 'gnu/linux)
(require 'prelude-linux))
;; WSL specific setting
2020-10-08 15:45:38 +03:00
(when (and (eq system-type 'gnu/linux) (getenv "WSLENV"))
(require 'prelude-wsl))
;; Windows specific settings
(when (eq system-type 'windows-nt)
(require 'prelude-windows))
(message "[Prelude] Loading Prelude's additional modules...")
;; the modules
2015-01-27 08:33:16 +02:00
(if (file-exists-p prelude-modules-file)
2020-06-18 10:45:54 +03:00
(load prelude-modules-file)
(message "[Prelude] Missing personal modules file %s" prelude-modules-file)
(message "[Prelude] Falling back to the bundled example file sample/prelude-modules.el")
(message "[Prelude] You should copy this file to your personal configuration folder and tweak it to your liking")
(load (expand-file-name "sample/prelude-modules.el" prelude-dir)))
2017-12-25 11:26:08 +02:00
;; config changes made through the customize UI will be stored here
(setq custom-file (expand-file-name "custom.el" prelude-personal-dir))
2012-02-15 18:14:03 +02:00
;; load the personal settings (this includes `custom-file')
2011-10-16 11:52:56 +03:00
(when (file-exists-p prelude-personal-dir)
(message "[Prelude] Loading personal configuration files in %s..." prelude-personal-dir)
(mapc 'load (delete
prelude-modules-file
(directory-files prelude-personal-dir 't "^[^#\.].*\\.el$"))))
(message "[Prelude] Prelude is ready to do thy bidding, Master %s!" prelude-user)
;; Patch security vulnerability in Emacs versions older than 25.3
(when (version< emacs-version "25.3")
(with-eval-after-load "enriched"
(defun enriched-decode-display-prop (start end &optional param)
(list start end))))
(prelude-eval-after-init
;; greet the use with some useful tip
(run-at-time 5 nil 'prelude-tip-of-the-day))
2012-05-07 18:04:03 +03:00
2011-10-08 23:05:06 +03:00
;;; init.el ends here