2014-09-05 17:08:40 -04:00
|
|
|
(provide 'core)
|
|
|
|
|
2014-09-20 16:54:04 -04:00
|
|
|
(require 'f)
|
|
|
|
|
2014-09-05 17:08:40 -04:00
|
|
|
(defconst is-mac (eq system-type 'darwin))
|
|
|
|
(defconst is-linux (eq system-type 'gnu/linux))
|
|
|
|
|
2014-08-07 18:35:22 -04:00
|
|
|
;; Setup theme
|
2014-09-05 17:08:40 -04:00
|
|
|
(add-to-list 'custom-theme-load-path *themes-dir)
|
|
|
|
(load-theme *theme t)
|
2014-07-15 02:21:56 -04:00
|
|
|
|
|
|
|
;; Emacs under-the-hood
|
2014-08-09 19:25:06 -04:00
|
|
|
(global-auto-revert-mode 1) ; revert buffers for changed files
|
2014-08-07 18:35:22 -04:00
|
|
|
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
|
2014-09-05 17:08:40 -04:00
|
|
|
|
2014-09-20 16:54:04 -04:00
|
|
|
(prefer-coding-system 'utf-8)
|
|
|
|
(setq-default load-prefer-newer t ; load newer .el over older .elc
|
|
|
|
gc-cons-threshold 50000000 ; avoid garbage collection (default is 400k)
|
|
|
|
enable-recursive-minibuffers nil
|
|
|
|
redisplay-dont-pause t
|
|
|
|
confirm-kill-emacs nil
|
|
|
|
compilation-scroll-output t)
|
|
|
|
|
|
|
|
;; Show keystrokes
|
2014-08-29 22:37:25 -04:00
|
|
|
(setq echo-keystrokes 0.02)
|
2014-08-09 19:25:06 -04:00
|
|
|
|
|
|
|
;; Sane scroll settings
|
|
|
|
(setq scroll-margin 3
|
|
|
|
scroll-conservatively 100000
|
|
|
|
scroll-preserve-screen-position 1)
|
|
|
|
|
2014-09-20 16:54:04 -04:00
|
|
|
(setq inhibit-startup-screen t ; don't show EMACs start screen
|
2014-08-09 19:25:06 -04:00
|
|
|
inhibit-splash-screen t
|
|
|
|
inhibit-startup-buffer-menu t
|
|
|
|
inhibit-startup-echo-area-message t
|
|
|
|
initial-major-mode 'text-mode
|
2014-08-21 03:33:30 -04:00
|
|
|
initial-scratch-message nil
|
|
|
|
initial-scratch-buffer nil) ; empty scratch buffer
|
2014-08-09 19:25:06 -04:00
|
|
|
|
2014-09-05 17:08:40 -04:00
|
|
|
;;; Backups
|
2014-09-20 16:54:04 -04:00
|
|
|
(defconst *tmp-dir-undo (f-expand "undo" *tmp-dir))
|
|
|
|
(defconst *tmp-dir-backup (f-expand "backup" *tmp-dir))
|
|
|
|
(unless (f-dir? *tmp-dir)
|
|
|
|
(f-mkdir *tmp-dir *tmp-dir-undo *tmp-dir-backup))
|
|
|
|
|
|
|
|
(setq make-backup-files nil ; Don't want any backup
|
|
|
|
auto-save-list-file-name nil ; Don't want any .saves
|
2014-09-05 17:08:40 -04:00
|
|
|
auto-save-default nil ; Don't want any auto saving
|
|
|
|
create-lockfiles nil)
|
|
|
|
|
2014-09-20 16:54:04 -04:00
|
|
|
;; In case I want to reactivate backup files
|
|
|
|
(setq backup-directory-alist `((".*" . ,*tmp-dir-backup)))
|
2014-07-15 02:21:56 -04:00
|
|
|
|
2014-08-07 18:35:22 -04:00
|
|
|
;; window layout undo/redo, keymaps in core-keymaps.el
|
2014-07-15 02:21:56 -04:00
|
|
|
(when (fboundp 'winner-mode) (winner-mode 1))
|
|
|
|
|
2014-08-07 18:35:22 -04:00
|
|
|
;;;; Advice ;;;;;;;;;;;;;;;;;;;;;;;;
|
2014-07-20 09:01:56 -04:00
|
|
|
;; Make next/previous-buffer skip special buffers
|
2014-09-20 16:54:04 -04:00
|
|
|
(defadvice next-buffer (after avoid-messages-buffer-in-next-buffer activate)
|
2014-07-20 09:01:56 -04:00
|
|
|
"Advice around `next-buffer' to avoid going into the *Messages* buffer."
|
2014-08-21 03:33:30 -04:00
|
|
|
(when (string-match "\\`\\*.+\\*\\'" (buffer-name)) (next-buffer)))
|
2014-09-20 16:54:04 -04:00
|
|
|
(defadvice previous-buffer (after avoid-messages-buffer-in-previous-buffer activate)
|
2014-07-20 09:01:56 -04:00
|
|
|
"Advice around `previous-buffer' to avoid going into the *Messages* buffer."
|
2014-08-21 03:33:30 -04:00
|
|
|
(when (string-match "\\`\\*.+\\*\\'" (buffer-name)) (previous-buffer)))
|
2014-07-20 09:01:56 -04:00
|
|
|
|
2014-07-15 02:21:56 -04:00
|
|
|
;;;; My personal minor mode ;;;;;;;;
|
2014-09-05 17:08:40 -04:00
|
|
|
(defvar my-mode-map (make-sparse-keymap))
|
|
|
|
(define-minor-mode my-mode :global t :keymap my-mode-map)
|
|
|
|
|
|
|
|
;; Automatic minor modes
|
|
|
|
(defvar auto-minor-mode-alist ()
|
2014-09-20 16:54:04 -04:00
|
|
|
"Alist of filename patterns vs correpsonding 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.")
|
|
|
|
|
2014-09-05 17:08:40 -04:00
|
|
|
(defun enable-minor-mode-based-on-extension ()
|
|
|
|
"check file name against auto-minor-mode-alist to enable minor modes
|
|
|
|
the checking happens for all pairs in auto-minor-mode-alist"
|
|
|
|
(when buffer-file-name
|
|
|
|
(let ((name buffer-file-name)
|
|
|
|
(remote-id (file-remote-p buffer-file-name))
|
|
|
|
(alist auto-minor-mode-alist))
|
|
|
|
;; 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))))))
|
|
|
|
|
|
|
|
(add-hook 'find-file-hook 'enable-minor-mode-based-on-extension)
|
2014-07-15 02:21:56 -04:00
|
|
|
|
2014-08-07 18:35:22 -04:00
|
|
|
;;;; Load the rest ;;;;;;;;;;;;;;;;;;
|
2014-09-05 17:08:40 -04:00
|
|
|
(require 'shut-up)
|
2014-09-20 16:54:04 -04:00
|
|
|
(when noninteractive
|
|
|
|
(shut-up-silence-emacs))
|
2014-09-05 17:08:40 -04:00
|
|
|
|
|
|
|
;; Package management bootstrap
|
|
|
|
(setq package-enable-at-startup nil
|
|
|
|
delete-old-versions t)
|
|
|
|
|
|
|
|
(let ((default-directory *elisp-dir))
|
|
|
|
(normal-top-level-add-to-load-path '("."))
|
|
|
|
(normal-top-level-add-subdirs-to-load-path))
|
|
|
|
|
|
|
|
(require 'use-package)
|