2017-06-08 11:47:56 +02:00
|
|
|
;;; core.el --- the heart of the beast -*- lexical-binding: t; -*-
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2015-06-06 06:40:33 -04:00
|
|
|
;;; Naming conventions:
|
2015-06-04 18:23:21 -04:00
|
|
|
;;
|
2017-06-08 11:47:56 +02:00
|
|
|
;; doom-... public variables or non-interactive functions
|
2017-02-09 04:25:32 -05:00
|
|
|
;; doom--... private anything (non-interactive), not safe for direct use
|
2017-06-08 11:47:56 +02:00
|
|
|
;; doom/... an interactive function; safe for M-x or keybinding
|
2017-02-09 04:25:32 -05:00
|
|
|
;; doom:... an evil operator, motion or command
|
|
|
|
;; doom|... hook function
|
|
|
|
;; doom*... advising functions
|
2017-02-23 00:06:12 -05:00
|
|
|
;; ...! a macro or function that configures DOOM
|
2017-02-09 04:25:32 -05:00
|
|
|
;; %... functions used for in-snippet logic
|
2017-06-08 11:47:56 +02:00
|
|
|
;; +... Any of the above but part of a module, e.g. `+emacs-lisp|init-hook'
|
2015-06-04 18:23:21 -04:00
|
|
|
;;
|
2017-02-08 02:02:51 -05:00
|
|
|
;; Autoloaded functions are in core/autoload/*.el and modules/*/*/autoload.el or
|
|
|
|
;; modules/*/*/autoload/*.el.
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2017-07-14 15:27:18 +02:00
|
|
|
(defvar doom-version "2.0.4"
|
2017-02-13 04:53:16 -05:00
|
|
|
"Current version of DOOM emacs.")
|
2016-10-05 12:48:12 +02:00
|
|
|
|
2017-02-04 02:54:37 -05:00
|
|
|
(defvar doom-debug-mode (or (getenv "DEBUG") init-file-debug)
|
2017-02-03 08:00:38 -05:00
|
|
|
"If non-nil, all doom functions will be verbose. Set DEBUG=1 in the command
|
|
|
|
line or use --debug-init to enable this.")
|
2017-01-31 04:31:14 -05:00
|
|
|
|
2017-05-31 15:04:29 -05:00
|
|
|
(defvar doom-emacs-dir (expand-file-name user-emacs-directory)
|
2017-02-13 04:53:16 -05:00
|
|
|
"The path to this emacs.d directory.")
|
2016-10-02 23:25:08 +02:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-core-dir (concat doom-emacs-dir "core/")
|
2017-02-13 04:53:16 -05:00
|
|
|
"Where essential files are stored.")
|
2016-10-02 23:25:08 +02:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-modules-dir (concat doom-emacs-dir "modules/")
|
2017-02-13 04:53:16 -05:00
|
|
|
"Where configuration modules are stored.")
|
2016-10-02 23:25:08 +02:00
|
|
|
|
2017-03-16 23:38:22 -04:00
|
|
|
|
|
|
|
;; Multi-host directories: I namespace `doom-etc-dir' and `doom-cache-dir' with
|
|
|
|
;; host names because I use the same (often symlinked) emacs.d across several
|
|
|
|
;; computers -- often simultaneously. Cache or other temporary files would
|
|
|
|
;; conflict otherwise.
|
|
|
|
|
2017-01-31 18:58:56 -05:00
|
|
|
(defvar doom-local-dir (concat doom-emacs-dir ".local/")
|
2017-04-16 20:36:15 -04:00
|
|
|
"Root directory for local Emacs files. Use this as permanent storage for files
|
|
|
|
that are safe to share across systems (if this config is symlinked across
|
|
|
|
several computers).")
|
2017-03-16 23:38:22 -04:00
|
|
|
|
2017-06-11 23:50:50 +02:00
|
|
|
(defvar doom-host-dir (concat doom-local-dir "@" (system-name))
|
|
|
|
"Directory for hostname-specific file storage. Used by `doom-etc-dir' and
|
|
|
|
`doom-cache-dir'.")
|
|
|
|
|
|
|
|
(defvar doom-etc-dir (concat doom-host-dir "/etc/")
|
2017-04-16 20:36:15 -04:00
|
|
|
"Host-namespaced directory for non-volatile storage. These are not deleted or
|
|
|
|
tampored with by DOOM functions. Use this for dependencies like servers or
|
|
|
|
config files that are stable (i.e. it should be unlikely that you need to delete
|
|
|
|
them if something goes wrong).")
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-06-11 23:50:50 +02:00
|
|
|
(defvar doom-cache-dir (concat doom-host-dir "/cache/")
|
2017-07-09 22:50:29 +02:00
|
|
|
"Host-namespaced directory for volatile storage. Deleted when `doom/reset' is
|
|
|
|
called. Use this for transient files that are generated on the fly like caches
|
|
|
|
and temporary files. Anything that may need to be cleared if there are
|
|
|
|
problems.")
|
2017-04-16 20:36:15 -04:00
|
|
|
|
|
|
|
(defvar doom-packages-dir (concat doom-local-dir "packages/")
|
|
|
|
"Where package.el and quelpa plugins (and their caches) are stored.")
|
2016-05-23 06:26:28 -04:00
|
|
|
|
2017-02-06 01:25:48 -05:00
|
|
|
(defvar doom-autoload-file
|
|
|
|
(concat doom-local-dir "autoloads.el")
|
2017-02-20 13:12:24 -05:00
|
|
|
"Location of the autoloads file generated by `doom/reload-autoloads'.")
|
2017-02-06 01:25:48 -05:00
|
|
|
|
2017-02-13 04:53:16 -05:00
|
|
|
(defgroup doom nil
|
2017-06-11 00:59:02 +02:00
|
|
|
"DOOM Emacs, an Emacs configuration for a stubborn, shell-dwelling and
|
|
|
|
melodramatic ex-vimmer disappointed with the text-editor status quo."
|
2017-02-13 04:53:16 -05:00
|
|
|
:group 'emacs)
|
|
|
|
|
2016-05-26 18:51:39 -04:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
;;;
|
2017-01-31 18:59:58 -05:00
|
|
|
;; UTF-8 as the default coding system
|
2017-05-19 02:54:31 +02:00
|
|
|
(when (fboundp 'set-charset-priority)
|
|
|
|
(set-charset-priority 'unicode)) ; pretty
|
2016-09-23 16:13:49 +02:00
|
|
|
(prefer-coding-system 'utf-8) ; pretty
|
2016-06-06 23:53:49 -04:00
|
|
|
(set-terminal-coding-system 'utf-8) ; pretty
|
2017-01-31 18:59:58 -05:00
|
|
|
(set-keyboard-coding-system 'utf-8) ; pretty
|
|
|
|
(set-selection-coding-system 'utf-8) ; perdy
|
|
|
|
(setq locale-coding-system 'utf-8) ; please
|
|
|
|
(setq-default buffer-file-coding-system 'utf-8) ; with sugar on top
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-02-19 18:11:28 -05:00
|
|
|
(setq-default
|
|
|
|
ad-redefinition-action 'accept ; silence advised function warnings
|
|
|
|
apropos-do-all t ; make `apropos' more useful
|
|
|
|
compilation-always-kill t ; kill compilation process before starting another
|
|
|
|
compilation-ask-about-save nil ; save all buffers on `compile'
|
|
|
|
compilation-scroll-output t
|
|
|
|
confirm-nonexistent-file-or-buffer t
|
|
|
|
enable-recursive-minibuffers nil
|
|
|
|
debug-on-error (and (not noninteractive) doom-debug-mode)
|
2017-03-19 22:50:52 -04:00
|
|
|
idle-update-delay 2 ; update ui less often
|
2017-02-19 18:11:28 -05:00
|
|
|
;; keep the point out of the minibuffer
|
|
|
|
minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
|
2017-04-16 20:36:15 -04:00
|
|
|
;; History & backup settings (save nothing, that's what git is for)
|
2017-02-19 18:11:28 -05:00
|
|
|
auto-save-default nil
|
|
|
|
create-lockfiles nil
|
2017-06-08 11:47:56 +02:00
|
|
|
history-length 500
|
2017-02-19 18:11:28 -05:00
|
|
|
make-backup-files nil
|
2017-04-16 20:36:15 -04:00
|
|
|
;; files
|
|
|
|
abbrev-file-name (concat doom-local-dir "abbrev.el")
|
|
|
|
auto-save-list-file-name (concat doom-cache-dir "autosave")
|
|
|
|
backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/")))
|
|
|
|
pcache-directory (concat doom-cache-dir "pcache/")
|
|
|
|
server-auth-dir (concat doom-cache-dir "server/")
|
|
|
|
shared-game-score-directory (concat doom-etc-dir "shared-game-score/")
|
|
|
|
tramp-auto-save-directory (concat doom-cache-dir "tramp-auto-save/")
|
2017-03-27 13:05:01 -04:00
|
|
|
tramp-backup-directory-alist backup-directory-alist
|
2017-04-16 20:36:15 -04:00
|
|
|
tramp-persistency-file-name (concat doom-cache-dir "tramp-persistency.el")
|
|
|
|
url-cache-directory (concat doom-cache-dir "url/")
|
2017-05-15 11:18:26 +02:00
|
|
|
url-configuration-directory (concat doom-etc-dir "url/"))
|
|
|
|
|
|
|
|
;; move custom defs out of init.el
|
|
|
|
(setq custom-file (concat doom-etc-dir "custom.el"))
|
2017-05-15 20:47:14 +02:00
|
|
|
(load custom-file t t)
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-06-24 02:06:52 +02:00
|
|
|
;; be quiet at startup; don't load or display anything unnecessary
|
2017-04-17 02:17:10 -04:00
|
|
|
(advice-add #'display-startup-echo-area-message :override #'ignore)
|
2017-02-06 01:25:48 -05:00
|
|
|
(setq inhibit-startup-message t
|
2017-02-19 18:11:28 -05:00
|
|
|
inhibit-startup-echo-area-message user-login-name
|
2017-06-08 11:47:56 +02:00
|
|
|
inhibit-default-init t
|
2017-02-19 18:11:28 -05:00
|
|
|
initial-major-mode 'fundamental-mode
|
2017-06-24 02:06:52 +02:00
|
|
|
initial-scratch-message nil
|
|
|
|
mode-line-format nil)
|
2017-02-06 01:25:48 -05:00
|
|
|
|
2017-06-12 00:20:30 +02:00
|
|
|
;; Custom init hooks; clearer than `after-init-hook', `emacs-startup-hook', and
|
|
|
|
;; `window-setup-hook'.
|
|
|
|
(defvar doom-init-hook nil
|
|
|
|
"A list of hooks run when DOOM is initialized, before `doom-post-init-hook'.")
|
|
|
|
|
|
|
|
(defvar doom-post-init-hook nil
|
|
|
|
"A list of hooks run after DOOM initialization is complete, and after
|
|
|
|
`doom-init-hook'.")
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-06-14 12:17:36 +02:00
|
|
|
(defun doom-try-run-hook (fn hook)
|
|
|
|
"Runs a hook wrapped in a `condition-case-unless-debug' block; its objective
|
|
|
|
is to include more information in the error message, without sacrificing your
|
|
|
|
ability to invoke the debugger in debug mode."
|
|
|
|
(condition-case-unless-debug ex
|
2017-07-27 00:01:55 +02:00
|
|
|
(if noninteractive
|
|
|
|
(quiet! (funcall fn))
|
|
|
|
(funcall fn))
|
2017-06-14 12:17:36 +02:00
|
|
|
('error
|
2017-06-28 01:12:24 +02:00
|
|
|
(lwarn hook :error
|
|
|
|
"%s in '%s' -> %s"
|
|
|
|
(car ex) fn (error-message-string ex))))
|
2017-06-14 12:17:36 +02:00
|
|
|
nil)
|
|
|
|
|
2017-07-12 23:56:19 +02:00
|
|
|
(defun doom|finalize ()
|
|
|
|
(unless doom-init-p
|
|
|
|
(dolist (hook '(doom-init-hook doom-post-init-hook))
|
|
|
|
(run-hook-wrapped hook #'doom-try-run-hook hook))
|
|
|
|
(setq doom-init-p t))
|
|
|
|
|
|
|
|
;; Don't keep gc-cons-threshold too high. It helps to stave off the GC while
|
|
|
|
;; Emacs starts up, but afterwards it causes stuttering and random freezes. So
|
|
|
|
;; reset it to a reasonable default.
|
|
|
|
(setq gc-cons-threshold 16777216
|
|
|
|
gc-cons-percentage 0.1
|
|
|
|
file-name-handler-alist doom--file-name-handler-alist))
|
2017-07-05 18:19:51 +02:00
|
|
|
|
2016-10-02 23:21:47 +02:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
;;;
|
2017-06-12 00:20:30 +02:00
|
|
|
;; Initialize
|
2017-06-08 11:47:56 +02:00
|
|
|
(eval-and-compile
|
|
|
|
(defvar doom--file-name-handler-alist file-name-handler-alist)
|
|
|
|
(setq gc-cons-threshold 402653184
|
|
|
|
gc-cons-percentage 0.6
|
|
|
|
file-name-handler-alist nil)
|
2017-01-16 23:15:48 -05:00
|
|
|
|
2017-05-19 10:43:55 +02:00
|
|
|
(require 'cl-lib)
|
2017-06-11 23:52:56 +02:00
|
|
|
(require 'core-packages (concat doom-core-dir "core-packages"))
|
2017-06-08 11:47:56 +02:00
|
|
|
|
2017-07-14 18:19:52 +02:00
|
|
|
(eval-when-compile
|
|
|
|
(doom-initialize))
|
|
|
|
(setq load-path (eval-when-compile load-path)
|
|
|
|
doom--package-load-path (eval-when-compile doom--package-load-path))
|
2017-06-08 11:47:56 +02:00
|
|
|
|
2017-07-14 18:19:52 +02:00
|
|
|
(load! core-lib)
|
|
|
|
(load! core-os) ; consistent behavior across OSes
|
|
|
|
(condition-case-unless-debug ex
|
|
|
|
(require 'autoloads doom-autoload-file t)
|
|
|
|
('error
|
|
|
|
(lwarn 'doom-autoloads :warning
|
|
|
|
"%s in autoloads.el -> %s"
|
2017-08-08 14:25:36 +02:00
|
|
|
(car ex) (error-message-string ex))))
|
|
|
|
|
|
|
|
(load! core-ui) ; draw me like one of your French editors
|
|
|
|
(load! core-popups) ; taming sudden yet inevitable windows
|
|
|
|
(load! core-editor) ; baseline configuration for text editing
|
|
|
|
(load! core-projects) ; making Emacs project-aware
|
|
|
|
(load! core-keybinds)) ; centralized keybind system + which-key
|
2017-06-08 11:47:56 +02:00
|
|
|
|
2017-07-12 23:56:19 +02:00
|
|
|
(add-hook! '(emacs-startup-hook doom-reload-hook)
|
|
|
|
#'doom|finalize)
|
2017-06-08 11:47:56 +02:00
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
(provide 'core)
|
|
|
|
;;; core.el ends here
|