doomemacs/core/core.el

177 lines
5.8 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")
2017-01-31 17:31:14 +08:00
(defvar doom-debug-mode nil
"If non-nil, all loading functions will be verbose and `use-package-debug'
will be set.")
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")
2017-01-17 12:15:48 +08:00
(defvar doom-scripts-dir (concat doom-emacs-dir "scripts/")
"Where external dependencies are stored (like libraries or binaries)")
(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-01-17 12:15:48 +08:00
(defvar doom-org-dir "~/org/"
2016-10-22 05:57:51 +08:00
"Where to find org notes")
2016-05-27 06:51:39 +08:00
2017-01-17 12:15:48 +08:00
;;;
;; UTF-8 as the default coding system, please
(set-charset-priority 'unicode) ; pretty
(prefer-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; perdy
(set-selection-coding-system 'utf-8) ; please
(setq locale-coding-system 'utf-8) ; with sugar on top
2017-01-17 12:15:48 +08:00
(setq-default buffer-file-coding-system 'utf-8)
;; Configuration
(setq ad-redefinition-accept 'accept ; silence advised function warnings
apropos-do-all t ; make `apropos' more useful
byte-compile-warnings nil
compilation-always-kill t
compilation-ask-about-save nil
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 5
minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
save-interprogram-paste-before-kill nil)
;; History & backup settings
(setq auto-save-default nil
auto-save-list-file-name (concat doom-temp-dir "/autosave")
backup-directory-alist (list (cons ".*" (concat doom-temp-dir "/backup/")))
create-lockfiles nil
history-length 1000
make-backup-files nil
vc-make-backup-files nil)
;;;
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)
2017-01-31 17:31:14 +08:00
(eval-when-compile
(unless (file-exists-p doom-packages-dir)
(error "No packages are installed, run 'make install'"))
;; Ensure cache folder exist
(unless (file-exists-p doom-cache-dir)
(make-directory doom-cache-dir t)))
2017-01-17 12:15:48 +08:00
(let (file-name-handler-list)
(eval-and-compile
2017-01-31 17:31:14 +08:00
(load (concat doom-core-dir "core-packages") nil :nomessage))
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
;;; Essential packages
(require 'core-lib)
2017-01-31 17:31:14 +08:00
2017-01-17 12:15:48 +08:00
(package! dash :demand t)
(package! s :demand t)
(package! f :demand t)
;;; Helper packages (autoloaded)
(package! async
:commands (async-start
async-start-process
async-byte-recompile-directory))
2017-01-31 17:31:14 +08:00
(defvar pcache-directory (concat doom-cache-dir "pcache/"))
2017-01-17 12:15:48 +08:00
(package! persistent-soft
:commands (persistent-soft-exists-p
persistent-soft-fetch
persistent-soft-flush
2017-01-31 17:31:14 +08:00
persistent-soft-store))
2017-01-17 12:15:48 +08:00
(package! smex :commands smex)
;;; Let 'er rip! (order matters!)
2017-01-31 17:31:14 +08:00
(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
(require 'core-projects) ; getting around your projects
(unless (require 'autoloads nil t)
(add-hook 'after-init-hook 'doom/refresh-autoloads)))
;; (require 'core-workspaces) ; TODO
;; (require 'core-completion) ; TODO company & auto-complete, for the lazy typist
;; (require 'core-evil)
;; (require 'core-jump)
;; (require 'core-repl)
;; (require 'core-snippets)
;; (require 'core-syntax-checking)
2015-06-05 06:23:21 +08:00
(provide 'core)
;;; core.el ends here