doom-emacs/core/core.el

172 lines
6.3 KiB
EmacsLisp
Raw Normal View History

2015-06-06 10:40:33 +00:00
;;; core.el --- The heart of the beast
2017-01-17 04:15:48 +00:00
2015-06-06 10:40:33 +00:00
;;; Naming conventions:
2015-06-04 22:23:21 +00:00
;;
;; doom-... public variables or functions (non-interactive)
;; doom--... private anything (non-interactive), not safe for direct use
;; doom/... an interactive function
;; doom:... an evil operator, motion or command
;; doom|... hook function
;; doom*... advising functions
;; ...! a macro or function that configures DOOM
;; %... functions used for in-snippet logic
2017-01-17 04:15:48 +00:00
;; +... Any of the above, but part of a module, e.g. +emacs-lisp|init-hook
2015-06-04 22:23:21 +00:00
;;
2017-02-08 07:02:51 +00:00
;; Autoloaded functions are in core/autoload/*.el and modules/*/*/autoload.el or
;; modules/*/*/autoload/*.el.
2015-06-04 22:23:21 +00:00
2017-04-08 05:36:40 +00:00
(defvar doom-version "2.0.1"
"Current version of DOOM emacs.")
2016-10-05 10:48:12 +00:00
(defvar doom-debug-mode (or (getenv "DEBUG") init-file-debug)
"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 09:31:14 +00:00
2017-01-17 04:15:48 +00:00
(defvar doom-emacs-dir user-emacs-directory
"The path to this emacs.d directory.")
2017-01-17 04:15:48 +00:00
(defvar doom-core-dir (concat doom-emacs-dir "core/")
"Where essential files are stored.")
2017-01-17 04:15:48 +00:00
(defvar doom-modules-dir (concat doom-emacs-dir "modules/")
"Where configuration modules are stored.")
;; 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.
(defvar doom-local-dir (concat doom-emacs-dir ".local/")
"Root directory for local Emacs files.")
(defvar doom-packages-dir (concat doom-local-dir "packages/")
"Where package.el and quelpa plugins (and their caches) are kept.")
(defvar doom-etc-dir
(concat doom-local-dir "etc/" (system-name) "/")
"Hostname-based directory for non-volatile temporary files. These are not
deleted or tampored with by DOOM functions. It should not be used for transient
or unstable files.")
2017-01-17 04:15:48 +00:00
(defvar doom-cache-dir
(concat doom-local-dir "cache/" (system-name) "/")
"Hostname-based directory for volatile temporary files. They are deleted when
`doom/clean-cache' is called. For more stable local storage, use
`doom-local-dir'.")
2017-02-06 06:25:48 +00:00
(defvar doom-autoload-file
(concat doom-local-dir "autoloads.el")
2017-02-20 18:12:24 +00:00
"Location of the autoloads file generated by `doom/reload-autoloads'.")
2017-02-06 06:25:48 +00:00
(defgroup doom nil
""
:group 'emacs)
2016-05-26 22:51:39 +00:00
2017-01-17 04:15:48 +00:00
;;;
;; UTF-8 as the default coding system
(set-charset-priority 'unicode) ; pretty
(prefer-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(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-17 04:15:48 +00:00
;; Configuration
2017-02-19 23:11:28 +00: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
custom-file (concat doom-etc-dir "custom.el")
2017-02-19 23:11:28 +00:00
enable-recursive-minibuffers nil
debug-on-error (and (not noninteractive) doom-debug-mode)
2017-03-20 02:50:52 +00:00
idle-update-delay 2 ; update ui less often
2017-03-06 23:49:48 +00:00
url-configuration-directory (concat doom-cache-dir "url/")
2017-02-19 23:11:28 +00:00
;; keep the point out of the minibuffer
minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
;; History & backup settings
auto-save-default nil
2017-02-21 03:10:02 +00:00
auto-save-list-file-name (concat doom-cache-dir "autosave")
backup-directory-alist (list (cons ".*" (concat doom-cache-dir "backup/")))
2017-02-19 23:11:28 +00:00
create-lockfiles nil
history-length 1000
make-backup-files nil
2017-04-11 22:47:37 +00:00
server-auth-dir (concat doom-cache-dir "server/")
tramp-auto-save-directory (concat doom-cache-dir "tramp/")
2017-04-11 22:47:37 +00:00
vc-make-backup-files nil
tramp-backup-directory-alist backup-directory-alist
2017-02-19 23:11:28 +00:00
;; in case of `persistent-soft'
pcache-directory (concat doom-cache-dir "pcache/"))
2017-01-17 04:15:48 +00:00
2017-02-06 06:25:48 +00:00
;; be quiet at startup
(advice-add 'display-startup-echo-area-message :override 'ignore)
(setq inhibit-startup-message t
2017-02-19 23:11:28 +00:00
inhibit-startup-echo-area-message user-login-name
initial-major-mode 'fundamental-mode
initial-scratch-message nil)
2017-02-06 06:25:48 +00:00
2017-01-17 04:15:48 +00:00
;;;
2016-05-19 07:17:59 +00:00
;; Automatic minor modes
2016-05-21 02:37:30 +00:00
(defvar doom-auto-minor-mode-alist '()
2017-01-17 04:15:48 +00:00
"Alist mapping filename patterns to corresponding minor mode functions, like
2016-05-19 07:17:59 +00:00
`auto-mode-alist'. All elements of this alist are checked, meaning you can
enable multiple minor modes for the same regexp.")
2016-05-21 02:37:30 +00:00
(defun doom|enable-minor-mode-maybe ()
"Check file name against `doom-auto-minor-mode-alist'."
2016-05-19 07:17:59 +00:00
(when buffer-file-name
(let ((name buffer-file-name)
(remote-id (file-remote-p buffer-file-name))
2016-05-21 02:37:30 +00:00
(alist doom-auto-minor-mode-alist))
2016-05-19 07:17:59 +00:00
;; Remove backup-suffixes from file name.
(setq name (file-name-sans-versions name))
;; Remove remote file name identification.
(when (and (stringp remote-id)
(string-match-p (regexp-quote remote-id) name))
(setq name (substring name (match-end 0))))
(while (and alist (caar alist) (cdar alist))
(if (string-match (caar alist) name)
(funcall (cdar alist) 1))
(setq alist (cdr alist))))))
2016-05-21 02:37:30 +00:00
(add-hook 'find-file-hook 'doom|enable-minor-mode-maybe)
2016-05-19 07:17:59 +00:00
2016-10-02 21:21:47 +00:00
2017-01-17 04:15:48 +00:00
;;;
;; Bootstrap
2017-02-21 03:10:29 +00:00
(setq gc-cons-threshold 402653184
2017-01-17 04:15:48 +00:00
gc-cons-percentage 0.6)
(let (file-name-handler-list)
(eval-and-compile
(require 'core-packages (concat doom-core-dir "core-packages")))
2017-01-17 04:15:48 +00:00
(eval-when-compile
2017-01-31 09:31:14 +00:00
(doom-initialize))
(setq load-path (eval-when-compile load-path))
2017-01-17 04:15:48 +00:00
;;; Let 'er rip
(require 'core-lib)
2017-02-19 12:02:03 +00:00
(require 'core-os) ; consistent behavior across Oses
2017-02-20 18:12:24 +00:00
(with-demoted-errors "AUTOLOAD ERROR: %s"
(require 'autoloads doom-autoload-file t))
2017-03-22 23:55:22 +00:00
(unless noninteractive
2017-03-23 23:49:58 +00:00
(require 'core-ui) ; draw me like one of your French editors
2017-03-22 23:55:22 +00:00
(require 'core-popups) ; taming sudden yet inevitable windows
(require 'core-editor) ; baseline configuration for text editing
(require 'core-projects) ; making Emacs project-aware
(require 'core-keybinds))) ; centralized keybind system + which-key
(add-hook! 'window-setup-hook
(setq gc-cons-threshold 16777216
gc-cons-percentage 0.1))
2017-02-21 03:10:29 +00:00
2015-06-04 22:23:21 +00:00
(provide 'core)
;;; core.el ends here