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-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-private-dir (concat doom-emacs-dir "private/")
|
2016-10-02 23:25:08 +02:00
|
|
|
"Where private configuration filse and assets are stored (like snippets)")
|
|
|
|
|
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-16 23:15:48 -05:00
|
|
|
(defvar doom-packages-dir (concat doom-private-dir "packages/")
|
|
|
|
"Where package.el and quelpa plugins (and their caches) are kept.")
|
|
|
|
|
|
|
|
(defvar doom-themes-dir (concat doom-private-dir "themes/")
|
2016-10-02 23:25:08 +02:00
|
|
|
"Where theme files and subfolders go")
|
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(defvar doom-temp-dir
|
|
|
|
(concat doom-private-dir "cache/" (system-name) "/")
|
2016-06-06 23:48:26 -04:00
|
|
|
"Hostname-based elisp temp directories")
|
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")
|
|
|
|
|
2016-05-26 18:51:39 -04:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
;;;
|
2016-09-23 16:13:49 +02:00
|
|
|
;; UTF-8 as the default coding system, please
|
|
|
|
(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
|
2016-09-23 16:13:49 +02:00
|
|
|
(set-keyboard-coding-system 'utf-8) ; perdy
|
2016-06-06 23:53:49 -04:00
|
|
|
(set-selection-coding-system 'utf-8) ; please
|
2016-09-23 16:13:49 +02:00
|
|
|
(setq locale-coding-system 'utf-8) ; with sugar on top
|
2017-01-16 23:15:48 -05: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
|
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
|
|
|
|
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 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)
|
|
|
|
|
|
|
|
(let (file-name-handler-list)
|
|
|
|
(eval-and-compile
|
|
|
|
(load (concat doom-core-dir "core-packages") nil t))
|
|
|
|
(eval-when-compile
|
|
|
|
;; Ensure cache folder exists
|
|
|
|
(unless (file-exists-p doom-temp-dir)
|
|
|
|
(make-directory doom-temp-dir t))
|
|
|
|
(doom-package-init))
|
|
|
|
|
|
|
|
(setq load-path (eval-when-compile load-path)
|
|
|
|
custom-theme-load-path (append (list doom-themes-dir) custom-theme-load-path))
|
|
|
|
|
|
|
|
;;; Essential packages
|
|
|
|
(require 'core-lib)
|
|
|
|
(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))
|
|
|
|
|
|
|
|
(package! persistent-soft
|
|
|
|
:commands (persistent-soft-exists-p
|
|
|
|
persistent-soft-fetch
|
|
|
|
persistent-soft-flush
|
|
|
|
persistent-soft-store)
|
|
|
|
:init (defvar pcache-directory (concat doom-temp-dir "/pcache/")))
|
|
|
|
|
|
|
|
(package! smex :commands smex)
|
|
|
|
|
|
|
|
;;; Let 'er rip! (order matters!)
|
2017-01-17 23:28:19 -05:00
|
|
|
;; (require 'core-set) ; configuration management system
|
|
|
|
;; (require 'core-popups) ; taming sudden yet inevitable windows
|
|
|
|
(require 'core-evil) ; come to the dark side, we have cookies
|
2017-01-16 23:15:48 -05:00
|
|
|
;; (require 'core-project)
|
|
|
|
;; (require 'core-os)
|
|
|
|
;; (require 'core-ui)
|
|
|
|
;; (require 'core-modeline)
|
|
|
|
;; (require 'core-editor)
|
|
|
|
;; (require 'core-completion)
|
2017-01-17 23:28:19 -05:00
|
|
|
;; (require 'core-jump)
|
2017-01-16 23:15:48 -05:00
|
|
|
;; (require 'core-repl)
|
2017-01-17 23:28:19 -05:00
|
|
|
;; (require 'core-snippets)
|
|
|
|
;; (require 'core-syntax-checking)
|
2017-01-16 23:15:48 -05:00
|
|
|
;; (require 'core-vcs)
|
2017-01-17 23:28:19 -05:00
|
|
|
;; (require 'core-workspaces)
|
2016-10-02 23:21:47 +02:00
|
|
|
|
2017-01-16 23:15:48 -05:00
|
|
|
(unless (require 'autoloads nil t)
|
|
|
|
(doom/refresh-autoloads t)))
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
;;
|
|
|
|
(defmacro doom! (&rest packages)
|
|
|
|
(let (paths)
|
|
|
|
(dolist (p packages)
|
|
|
|
(if (memq p '(:apps :emacs :lang :lib :private :ui))
|
|
|
|
(setq mode p)
|
|
|
|
(unless mode
|
|
|
|
(error "No namespace specified on `doom!' for %s" p))
|
|
|
|
(pushnew (format "%s%s/%s/" doom-modules-dir (substring (symbol-name mode) 1) (symbol-name p))
|
|
|
|
paths)))
|
|
|
|
|
|
|
|
`(let (file-name-handler-alist)
|
|
|
|
(unless noninteractive
|
|
|
|
(load "~/.emacs.local.el" t t))
|
|
|
|
|
|
|
|
(with-demoted-errors "ERROR: %s"
|
|
|
|
,@(mapcar
|
|
|
|
(lambda (path)
|
|
|
|
(macroexp-progn
|
|
|
|
(mapcar (lambda (file)
|
|
|
|
(when noninteractive (setq file (file-name-sans-extension file)))
|
|
|
|
`(load ,(expand-file-name file path) t t (not noninteractive)))
|
|
|
|
(append (list "packages.el")
|
|
|
|
(unless noninteractive (list "config.el"))))))
|
|
|
|
paths))
|
|
|
|
|
|
|
|
(unless noninteractive
|
|
|
|
(require 'my-bindings)
|
|
|
|
(require 'my-commands)
|
|
|
|
|
|
|
|
(when (display-graphic-p)
|
|
|
|
(require 'server)
|
|
|
|
(unless (server-running-p)
|
|
|
|
(server-start)))
|
|
|
|
|
|
|
|
;; Prevent any auto-displayed text + benchmarking
|
|
|
|
(advice-add 'display-startup-echo-area-message :override 'ignore)
|
|
|
|
(message "")))))
|
2016-01-29 07:09:53 -05:00
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
(provide 'core)
|
|
|
|
;;; core.el ends here
|