2015-06-06 06:40:33 -04:00
|
|
|
;;; core.el --- The heart of the beast
|
2015-06-04 18:23:21 -04:00
|
|
|
;;
|
2015-06-06 06:40:33 -04:00
|
|
|
;;; Naming conventions:
|
2015-06-04 18:23:21 -04:00
|
|
|
;;
|
2016-05-20 22:37:30 -04:00
|
|
|
;; doom-... A public variable/constant or function
|
|
|
|
;; doom--... An internal variable or function (non-interactive)
|
|
|
|
;; doom/... An autoloaded interactive function
|
|
|
|
;; doom:... An ex command
|
|
|
|
;; doom|... A hook
|
|
|
|
;; doom*... An advising function
|
|
|
|
;; doom.... Custom prefix commands
|
2016-05-24 22:15:44 -04:00
|
|
|
;; ...! Macro, shortcut alias or subst defun
|
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
|
|
|
|
2016-05-23 06:26:28 -04:00
|
|
|
;; Paths
|
|
|
|
(defalias '! 'eval-when-compile)
|
|
|
|
|
|
|
|
(defconst doom-emacs-dir (! (expand-file-name user-emacs-directory)))
|
|
|
|
(defconst doom-core-dir (! (expand-file-name "core" doom-emacs-dir)))
|
|
|
|
(defconst doom-modules-dir (! (expand-file-name "modules" doom-emacs-dir)))
|
|
|
|
(defconst doom-private-dir (! (expand-file-name "private" doom-emacs-dir)))
|
|
|
|
(defconst doom-packages-dir (! (expand-file-name (concat ".cask/" emacs-version "/elpa") doom-emacs-dir)))
|
|
|
|
(defconst doom-ext-dir (! (expand-file-name "ext" doom-emacs-dir)))
|
|
|
|
(defconst doom-temp-dir
|
|
|
|
(! (format "%s/cache/%s/%s.%s"
|
|
|
|
doom-private-dir (system-name)
|
|
|
|
emacs-major-version emacs-minor-version))
|
|
|
|
"Hostname and emacs-version-based elisp temp directories")
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
;; UTF-8 please
|
2016-05-21 23:12:50 -04:00
|
|
|
(set-charset-priority 'unicode)
|
2015-09-30 13:47:57 -04:00
|
|
|
(setq locale-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) ; please
|
|
|
|
(prefer-coding-system 'utf-8) ; with sugar on top
|
2016-03-10 23:54:56 -05:00
|
|
|
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
|
|
|
|
|
2016-05-23 06:26:28 -04:00
|
|
|
;; Premature optimization for faster startup
|
|
|
|
(setq-default gc-cons-threshold 4388608
|
|
|
|
gc-cons-percentage 0.4
|
|
|
|
major-mode 'text-mode)
|
|
|
|
|
2016-05-21 18:54:58 -04:00
|
|
|
;; stop package.el from being annoying. I rely solely on Cask.
|
|
|
|
(setq package--init-file-ensured t
|
|
|
|
package-enable-at-startup nil
|
|
|
|
package-archives
|
|
|
|
'(("gnu" . "http://elpa.gnu.org/packages/")
|
|
|
|
("melpa" . "http://melpa.org/packages/")
|
2016-05-23 06:26:28 -04:00
|
|
|
("org" . "http://orgmode.org/elpa/"))
|
2016-05-21 18:54:58 -04:00
|
|
|
|
2016-05-23 06:26:28 -04:00
|
|
|
ad-redefinition-action 'accept ; silence the advised function warnings
|
|
|
|
confirm-nonexistent-file-or-buffer t
|
2016-05-21 18:54:58 -04:00
|
|
|
compilation-always-kill t ; kill compl. process before spawning another
|
|
|
|
compilation-ask-about-save nil ; save all buffers before compiling
|
|
|
|
compilation-scroll-output t ; scroll with output while compiling
|
|
|
|
delete-by-moving-to-trash t
|
|
|
|
echo-keystrokes 0.02 ; show me what I type
|
|
|
|
ediff-diff-options "-w"
|
|
|
|
ediff-split-window-function 'split-window-horizontally ; side-by-side diffs
|
|
|
|
ediff-window-setup-function 'ediff-setup-windows-plain ; no extra frames
|
|
|
|
enable-recursive-minibuffers nil ; no minibufferception
|
2016-05-23 06:26:28 -04:00
|
|
|
idle-update-delay 5 ; update a little less often
|
2016-05-21 18:54:58 -04:00
|
|
|
ring-bell-function 'ignore ; silence of the bells!
|
|
|
|
save-interprogram-paste-before-kill nil
|
|
|
|
sentence-end-double-space nil
|
|
|
|
;; http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
|
|
|
|
minibuffer-prompt-properties
|
|
|
|
'(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
|
|
|
|
;; persistent bookmarks
|
|
|
|
bookmark-save-flag t
|
|
|
|
bookmark-default-file (concat doom-temp-dir "/bookmarks")
|
|
|
|
;; Disable backups (that's what git/dropbox are for)
|
|
|
|
history-length 1000
|
|
|
|
vc-make-backup-files nil
|
|
|
|
auto-save-default nil
|
|
|
|
auto-save-list-file-name (concat doom-temp-dir "/autosave")
|
|
|
|
make-backup-files nil
|
|
|
|
create-lockfiles nil
|
|
|
|
backup-directory-alist `((".*" . ,(concat doom-temp-dir "/backup/")))
|
|
|
|
;; Remember undo history
|
|
|
|
undo-tree-auto-save-history nil
|
|
|
|
undo-tree-history-directory-alist `(("." . ,(concat doom-temp-dir "/undo/"))))
|
|
|
|
|
2015-09-30 13:47:57 -04:00
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
;;
|
2016-05-23 06:26:28 -04:00
|
|
|
;; Load path
|
2016-03-03 15:04:14 -05:00
|
|
|
;;
|
2015-09-30 13:47:57 -04:00
|
|
|
|
2016-05-23 06:26:28 -04:00
|
|
|
(defvar doom--load-path load-path
|
|
|
|
"Initial `load-path'; so we don't clobber it on consecutive reloads.")
|
2016-05-21 23:12:50 -04:00
|
|
|
|
2016-05-23 06:26:28 -04:00
|
|
|
;; Populate the load-path manually; cask shouldn't be an internal dependency
|
|
|
|
(setq load-path
|
2016-05-24 22:15:44 -04:00
|
|
|
(! (defsubst --subdirs (path &optional include-self)
|
2016-05-23 06:26:28 -04:00
|
|
|
(let ((result (if include-self (list path) (list))))
|
2016-05-24 22:15:44 -04:00
|
|
|
(mapc (lambda (file)
|
|
|
|
(when (file-directory-p file)
|
|
|
|
(push file result)))
|
|
|
|
(ignore-errors (directory-files path t "^[^.]" t)))
|
2016-05-23 06:26:28 -04:00
|
|
|
result))
|
|
|
|
(append (list doom-private-dir)
|
|
|
|
(--subdirs doom-core-dir t)
|
|
|
|
(--subdirs doom-modules-dir t)
|
|
|
|
(--subdirs doom-packages-dir)
|
|
|
|
(--subdirs (expand-file-name "../bootstrap" doom-packages-dir))
|
|
|
|
doom--load-path))
|
|
|
|
custom-theme-load-path
|
|
|
|
(! (append (list (expand-file-name "themes/" doom-private-dir))
|
|
|
|
custom-theme-load-path)))
|
2016-05-20 22:37:30 -04:00
|
|
|
|
2016-05-23 06:26:28 -04:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Libraries
|
|
|
|
;;
|
|
|
|
|
|
|
|
(require 'f)
|
|
|
|
(require 'dash)
|
|
|
|
(require 's)
|
2015-09-30 13:47:57 -04:00
|
|
|
|
2016-05-20 09:23:46 -04:00
|
|
|
(autoload 'use-package "use-package" "" nil 'macro)
|
2016-05-23 06:26:28 -04:00
|
|
|
(require 'core-vars)
|
|
|
|
(require 'core-defuns)
|
|
|
|
(unless (require 'autoloads nil t)
|
|
|
|
(doom-reload-autoloads)
|
|
|
|
(unless (require 'autoloads nil t)
|
|
|
|
(error "Autoloads weren't generated! Run `make autoloads`")))
|
2016-05-20 09:23:46 -04:00
|
|
|
|
2016-05-18 16:58:07 -04:00
|
|
|
(use-package anaphora
|
|
|
|
:commands (awhen aif acond awhile))
|
|
|
|
|
2015-11-17 02:08:35 -05:00
|
|
|
(use-package persistent-soft
|
|
|
|
:commands (persistent-soft-store
|
|
|
|
persistent-soft-fetch
|
|
|
|
persistent-soft-exists-p
|
|
|
|
persistent-soft-flush
|
|
|
|
persistent-soft-location-readable
|
2015-11-17 02:18:56 -05:00
|
|
|
persistent-soft-location-destroy)
|
2016-05-20 22:37:30 -04:00
|
|
|
:init (defvar pcache-directory (concat doom-temp-dir "/pcache/")))
|
2015-11-17 02:08:35 -05:00
|
|
|
|
|
|
|
(use-package async
|
|
|
|
:commands (async-start
|
|
|
|
async-start-process
|
|
|
|
async-get
|
|
|
|
async-wait
|
|
|
|
async-inject-variables))
|
|
|
|
|
2016-05-19 03:17:59 -04:00
|
|
|
(use-package json
|
|
|
|
:commands (json-read-from-string json-encode json-read-file))
|
|
|
|
|
|
|
|
(use-package help-fns+ ; Improved help commands
|
|
|
|
:commands (describe-buffer describe-command describe-file
|
|
|
|
describe-keymap describe-option describe-option-of-type))
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Automatic minor modes
|
|
|
|
;;
|
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
(defvar doom-auto-minor-mode-alist '()
|
2016-05-19 03:17:59 -04:00
|
|
|
"Alist of filename patterns vs corresponding minor mode functions, see
|
|
|
|
`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-05-21 23:12:50 -04:00
|
|
|
;;
|
|
|
|
(add-hook! emacs-startup
|
2016-05-20 09:23:46 -04:00
|
|
|
;; We add this to `after-init-hook' to allow errors to stop it
|
2016-01-29 07:09:53 -05:00
|
|
|
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
|
|
|
|
"Prevent annoying \"Active processes exist\" query when you quit Emacs."
|
2016-05-21 23:12:50 -04:00
|
|
|
(cl-flet ((process-list ())) ad-do-it)))
|
2016-01-29 07:09:53 -05:00
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
(provide 'core)
|
|
|
|
;;; core.el ends here
|