2015-06-06 06:40:33 -04:00
|
|
|
;;; core.el --- The heart of the beast
|
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-01-16 23:15:48 -05: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-04 18:23:21 -04:00
|
|
|
;;
|
2016-05-21 18:54:58 -04:00
|
|
|
;;; Autoloaded functions are in {core,modules}/defuns/defuns-*.el
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(when (version< emacs-version "25.1")
|
|
|
|
(error "DOOM Emacs no longer supports Emacs <25.1! Time to upgrade!"))
|
2016-10-02 23:25:08 +02:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
;;;
|
|
|
|
(defvar doom-version "2.0.0"
|
2016-10-05 12:48:12 +02:00
|
|
|
"Current version of DOOM emacs")
|
|
|
|
|
2017-01-31 04:31:14 -05:00
|
|
|
(defvar doom-debug-mode nil
|
|
|
|
"If non-nil, all loading functions will be verbose and `use-package-debug'
|
|
|
|
will be set.")
|
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-emacs-dir user-emacs-directory
|
2016-10-02 23:25:08 +02:00
|
|
|
"The path to this emacs.d directory")
|
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-core-dir (concat doom-emacs-dir "core/")
|
2016-10-02 23:25:08 +02:00
|
|
|
"Where essential files are stored")
|
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-modules-dir (concat doom-emacs-dir "modules/")
|
2016-10-02 23:25:08 +02:00
|
|
|
"Where configuration modules are stored")
|
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-scripts-dir (concat doom-emacs-dir "scripts/")
|
2016-10-02 23:25:08 +02:00
|
|
|
"Where external dependencies are stored (like libraries or binaries)")
|
|
|
|
|
2017-01-31 18:58:56 -05:00
|
|
|
(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-16 23:15:48 -05:00
|
|
|
|
2017-01-31 18:58:56 -05:00
|
|
|
(defvar doom-cache-dir
|
|
|
|
(concat doom-local-dir "cache/" (system-name) "/")
|
|
|
|
"Hostname-based directory for temporary files.")
|
2016-10-02 23:25:08 +02:00
|
|
|
|
2017-01-31 18:58:56 -05:00
|
|
|
(defvar doom-packages-dir
|
|
|
|
(concat doom-local-dir "packages/")
|
|
|
|
"Where package.el and quelpa plugins (and their caches) are kept.")
|
2016-05-23 06:26:28 -04:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-org-dir "~/org/"
|
2016-10-21 23:57:51 +02:00
|
|
|
"Where to find org notes")
|
|
|
|
|
2017-01-31 18:59:14 -05:00
|
|
|
(defconst IS-MAC (eq system-type 'darwin))
|
|
|
|
(defconst IS-LINUX (eq system-type 'gnu/linux))
|
|
|
|
|
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
|
2016-09-23 16:13:49 +02:00
|
|
|
(set-charset-priority 'unicode) ; pretty
|
|
|
|
(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
|
|
|
|
|
|
|
;; Configuration
|
|
|
|
(setq ad-redefinition-accept 'accept ; silence advised function warnings
|
|
|
|
apropos-do-all t ; make `apropos' more useful
|
2017-01-31 18:59:58 -05:00
|
|
|
compilation-always-kill t ; kill compilation process before starting another
|
|
|
|
compilation-ask-about-save nil ; save all buffers on `compile'
|
2017-01-16 23:15:48 -05:00
|
|
|
compilation-scroll-output t
|
2016-05-28 21:51:21 -04:00
|
|
|
confirm-nonexistent-file-or-buffer t
|
2017-01-16 23:15:48 -05:00
|
|
|
enable-recursive-minibuffers nil
|
2017-01-31 18:59:58 -05:00
|
|
|
idle-update-delay 1 ; update ui less often
|
|
|
|
;; keep the point out of the minibuffer
|
2017-01-16 23:15:48 -05:00
|
|
|
minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
|
|
|
|
|
2017-01-31 18:59:58 -05:00
|
|
|
;; 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-16 23:15:48 -05:00
|
|
|
create-lockfiles nil
|
|
|
|
history-length 1000
|
|
|
|
make-backup-files nil
|
|
|
|
vc-make-backup-files nil)
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
2016-05-19 03:17:59 -04:00
|
|
|
;; Automatic minor modes
|
2016-05-20 22:37:30 -04:00
|
|
|
(defvar doom-auto-minor-mode-alist '()
|
2017-01-16 23:15:48 -05:00
|
|
|
"Alist mapping filename patterns to corresponding minor mode functions, like
|
2016-05-19 03:17:59 -04:00
|
|
|
`auto-mode-alist'. All elements of this alist are checked, meaning you can
|
|
|
|
enable multiple minor modes for the same regexp.")
|
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
(defun doom|enable-minor-mode-maybe ()
|
|
|
|
"Check file name against `doom-auto-minor-mode-alist'."
|
2016-05-19 03:17:59 -04:00
|
|
|
(when buffer-file-name
|
|
|
|
(let ((name buffer-file-name)
|
|
|
|
(remote-id (file-remote-p buffer-file-name))
|
2016-05-20 22:37:30 -04:00
|
|
|
(alist doom-auto-minor-mode-alist))
|
2016-05-19 03:17:59 -04: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-20 22:37:30 -04:00
|
|
|
(add-hook 'find-file-hook 'doom|enable-minor-mode-maybe)
|
2016-05-19 03:17:59 -04:00
|
|
|
|
2016-10-02 23:21:47 +02:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
;;;
|
|
|
|
;; Bootstrap
|
|
|
|
(setq gc-cons-threshold 339430400
|
|
|
|
gc-cons-percentage 0.6)
|
|
|
|
|
2017-01-31 04:31:14 -05: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-16 23:15:48 -05:00
|
|
|
(let (file-name-handler-list)
|
|
|
|
(eval-and-compile
|
2017-01-31 04:31:14 -05:00
|
|
|
(load (concat doom-core-dir "core-packages") nil :nomessage))
|
2017-01-16 23:15:48 -05:00
|
|
|
(eval-when-compile
|
2017-01-31 04:31:14 -05:00
|
|
|
(doom-initialize))
|
|
|
|
(setq load-path (eval-when-compile load-path))
|
2017-01-16 23:15:48 -05:00
|
|
|
|
|
|
|
;;; Essential packages
|
|
|
|
(require 'core-lib)
|
2017-01-31 04:31:14 -05:00
|
|
|
|
2017-01-16 23:15:48 -05: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 04:31:14 -05:00
|
|
|
(defvar pcache-directory (concat doom-cache-dir "pcache/"))
|
2017-01-16 23:15:48 -05:00
|
|
|
(package! persistent-soft
|
|
|
|
:commands (persistent-soft-exists-p
|
|
|
|
persistent-soft-fetch
|
|
|
|
persistent-soft-flush
|
2017-01-31 04:31:14 -05:00
|
|
|
persistent-soft-store))
|
2017-01-16 23:15:48 -05:00
|
|
|
|
|
|
|
(package! smex :commands smex)
|
|
|
|
|
|
|
|
;;; Let 'er rip! (order matters!)
|
2017-01-31 04:31:14 -05:00
|
|
|
(require 'core-ui) ; draw me like one of your French editors
|
2017-02-01 00:31:58 -05:00
|
|
|
(require 'core-states) ; TODO
|
2017-01-31 04:31:14 -05:00
|
|
|
(require 'core-popups) ; taming sudden yet inevitable windows
|
|
|
|
(require 'core-editor) ; baseline configuration for text editing
|
|
|
|
(require 'core-projects) ; getting around your projects
|
|
|
|
|
2017-02-01 00:31:58 -05:00
|
|
|
(unless (require 'autoloads (concat doom-local-dir "autoloads.el") t)
|
2017-01-31 18:47:59 -05:00
|
|
|
(add-hook 'after-init-hook 'doom/refresh-autoloads)))
|
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
(provide 'core)
|
|
|
|
;;; core.el ends here
|