doomemacs/core/core.el

147 lines
5.3 KiB
EmacsLisp
Raw Normal View History

2015-06-06 18:40:33 +08:00
;;; core.el --- The heart of the beast
2017-01-17 12:15:48 +08:00
2015-06-06 18:40:33 +08:00
;;; Naming conventions:
2015-06-05 06:23:21 +08:00
;;
2017-01-17 12:15:48 +08:00
;; doom-... A public variable or function (non-interactive use)
;; doom--... A private variable, function (non-interactive use) or macro
;; doom/... An interactive function
;; doom:... An evil operator, motion or command
;; doom|... A hook
;; doom*... An advising function
;; ...! Macro, shortcut alias or defsubst
;; @... lambda macro for keybinds
;; +... Any of the above, but part of a module, e.g. +emacs-lisp|init-hook
2015-06-05 06:23:21 +08:00
;;
;;; Autoloaded functions are in {core,modules}/defuns/defuns-*.el
2015-06-05 06:23:21 +08:00
2017-01-17 12:15:48 +08:00
(when (version< emacs-version "25.1")
(error "DOOM Emacs no longer supports Emacs <25.1! Time to upgrade!"))
2017-01-17 12:15:48 +08:00
;;;
(defvar doom-version "2.0.0"
2016-10-05 18:48:12 +08:00
"Current version of DOOM emacs")
(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 17:31:14 +08:00
2017-01-17 12:15:48 +08:00
(defvar doom-emacs-dir user-emacs-directory
"The path to this emacs.d directory")
2017-01-17 12:15:48 +08:00
(defvar doom-core-dir (concat doom-emacs-dir "core/")
"Where essential files are stored")
2017-01-17 12:15:48 +08:00
(defvar doom-modules-dir (concat doom-emacs-dir "modules/")
"Where configuration modules are stored")
(defvar doom-local-dir (concat doom-emacs-dir ".local/")
"Untracked directory for local Emacs files, including the cache
(`doom-cache-dir'), packages (`doom-packages-dir') and autoloads file.")
2017-01-17 12:15:48 +08:00
(defvar doom-cache-dir
(concat doom-local-dir "cache/" (system-name) "/")
"Hostname-based directory for temporary files.")
(defvar doom-packages-dir
(concat doom-local-dir "packages/")
"Where package.el and quelpa plugins (and their caches) are kept.")
2017-02-06 14:25:48 +08:00
(defvar doom-autoload-file
(concat doom-local-dir "autoloads.el")
"Location of the autoloads.el, which is generated by `doom/refresh-autoloads'
and `doom-initialize-autoloads'.")
2017-02-01 07:59:14 +08:00
(defconst IS-MAC (eq system-type 'darwin))
(defconst IS-LINUX (eq system-type 'gnu/linux))
2016-05-27 06:51:39 +08:00
2017-01-17 12:15:48 +08: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 12:15:48 +08:00
;; Configuration
(setq ad-redefinition-accept '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'
2017-01-17 12:15:48 +08:00
compilation-scroll-output t
confirm-nonexistent-file-or-buffer t
2017-01-17 12:15:48 +08:00
enable-recursive-minibuffers nil
idle-update-delay 1 ; update ui less often
;; keep the point out of the minibuffer
2017-01-17 12:15:48 +08:00
minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
;; History & backup settings
auto-save-default nil
auto-save-list-file-name (concat doom-cache-dir "/autosave")
backup-directory-alist (list (cons ".*" (concat doom-cache-dir "/backup/")))
2017-01-17 12:15:48 +08:00
create-lockfiles nil
history-length 1000
make-backup-files nil
vc-make-backup-files nil)
2017-02-06 14:25:48 +08:00
;; be quiet at startup
(advice-add 'display-startup-echo-area-message :override 'ignore)
(setq inhibit-startup-message t
inhibit-startup-echo-area-message user-login-name)
2017-01-17 12:15:48 +08:00
;;;
2016-05-19 15:17:59 +08:00
;; Automatic minor modes
2016-05-21 10:37:30 +08:00
(defvar doom-auto-minor-mode-alist '()
2017-01-17 12:15:48 +08:00
"Alist mapping filename patterns to corresponding minor mode functions, like
2016-05-19 15:17:59 +08: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 10:37:30 +08:00
(defun doom|enable-minor-mode-maybe ()
"Check file name against `doom-auto-minor-mode-alist'."
2016-05-19 15:17:59 +08:00
(when buffer-file-name
(let ((name buffer-file-name)
(remote-id (file-remote-p buffer-file-name))
2016-05-21 10:37:30 +08:00
(alist doom-auto-minor-mode-alist))
2016-05-19 15:17:59 +08: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 10:37:30 +08:00
(add-hook 'find-file-hook 'doom|enable-minor-mode-maybe)
2016-05-19 15:17:59 +08:00
2016-10-03 05:21:47 +08:00
2017-01-17 12:15:48 +08:00
;;;
;; Bootstrap
(setq gc-cons-threshold 339430400
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 12:15:48 +08:00
(eval-when-compile
2017-01-31 17:31:14 +08:00
(doom-initialize))
(setq load-path (eval-when-compile load-path))
2017-01-17 12:15:48 +08:00
;;; Let 'er rip
(require 'core-lib)
(unless noninteractive
(require 'core-ui) ; draw me like one of your French editors
(require 'core-popups) ; taming sudden yet inevitable windows
(require 'core-editor) ; baseline configuration for text editing
2017-02-06 14:25:48 +08:00
(require 'core-projects)) ; making Emacs project-aware
2017-02-06 14:25:48 +08:00
;; We do this last to promise that core files will not use autoloaded files.
;; If they did, those functions shouldn't be autoloaded!
(doom-initialize-autoloads))
2015-06-05 06:23:21 +08:00
(provide 'core)
;;; core.el ends here