2014-09-05 17:08:40 -04:00
|
|
|
(provide 'core)
|
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
(defconst is-mac (eq system-type 'darwin))
|
2014-09-05 17:08:40 -04:00
|
|
|
(defconst is-linux (eq system-type 'gnu/linux))
|
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
;;;; Load 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
|
|
|
|
2014-09-05 17:08:40 -04:00
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
;;;; Emacs under the hood ;;;;;;;;;;;;;;;;
|
2014-09-20 16:54:04 -04:00
|
|
|
(prefer-coding-system 'utf-8)
|
2014-11-29 20:21:03 -05:00
|
|
|
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
|
|
|
|
(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)
|
2014-08-09 19:25:06 -04:00
|
|
|
|
|
|
|
;; Sane scroll settings
|
2014-11-29 20:21:03 -05:00
|
|
|
(setq scroll-margin 5
|
2014-08-09 19:25:06 -04:00
|
|
|
scroll-conservatively 100000
|
2014-11-29 20:21:03 -05:00
|
|
|
scroll-preserve-screen-position 1
|
|
|
|
echo-keystrokes 0.02 ; Show keystrokes
|
|
|
|
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
|
|
|
|
initial-major-mode 'text-mode
|
2014-08-21 03:33:30 -04:00
|
|
|
initial-scratch-message nil
|
2014-11-29 20:21:03 -05:00
|
|
|
initial-scratch-buffer nil) ; empty scratch buffer
|
2014-08-09 19:25:06 -04:00
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
;; Make sure undo/backup folders exist
|
|
|
|
(require 'f)
|
|
|
|
(defconst *tmp-dir-undo (f-expand "undo" *tmp-dir))
|
|
|
|
(defconst *tmp-dir-backup (f-expand "backup" *tmp-dir))
|
|
|
|
(defconst *tmp-dir-autosave (f-expand "autosave" *tmp-dir))
|
2014-09-20 16:54:04 -04:00
|
|
|
(unless (f-dir? *tmp-dir)
|
2014-11-29 20:21:03 -05:00
|
|
|
(f-mkdir *tmp-dir
|
|
|
|
*tmp-dir-undo
|
|
|
|
*tmp-dir-backup
|
|
|
|
*tmp-dir-autosave))
|
|
|
|
|
|
|
|
;; Disable all backups (that's what git/dropbox are for)
|
|
|
|
(setq make-backup-files nil
|
|
|
|
create-lockfiles nil
|
|
|
|
auto-save-default nil
|
|
|
|
auto-save-list-file-name (concat *tmp-dir-autosave ".auto-save")
|
|
|
|
;; In case I want to reactivate backup files
|
|
|
|
backup-directory-alist `((".*" . ,*tmp-dir-backup))
|
|
|
|
auto-save-file-name-transforms `((".*" ,*tmp-dir-autosave t)))
|
|
|
|
|
|
|
|
;; Remember undo history
|
|
|
|
(setq-default undo-tree-history-directory-alist `(("." . ,*tmp-dir-undo)))
|
|
|
|
(setq-default undo-tree-auto-save-history t)
|
|
|
|
|
|
|
|
;;;; Save history across sessions
|
|
|
|
;; search entries
|
|
|
|
(defvar savehist-additional-variables '(search ring regexp-search-ring))
|
|
|
|
;; keep the home clean
|
|
|
|
(defvar savehist-file (f-expand "savehist" *tmp-dir))
|
|
|
|
(savehist-mode 1)
|
|
|
|
|
|
|
|
|
|
|
|
;;;; My personal global mode ;;;;;;;;;;;;;
|
|
|
|
(defvar my-mode-map (make-sparse-keymap))
|
|
|
|
(define-minor-mode my-mode
|
|
|
|
"My personal global mode."
|
|
|
|
:global t
|
|
|
|
:keymap my-mode-map)
|
2014-07-15 02:21:56 -04:00
|
|
|
|
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
;;;; Behavior adjustments ;;;;;;;;;;;;;;;;
|
2014-07-20 09:01:56 -04:00
|
|
|
;; Make next/previous-buffer skip special buffers
|
2014-11-29 20:21:03 -05:00
|
|
|
(defadvice next-buffer (after void-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-09-05 17:08:40 -04:00
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
;;;; Automatic minor modes ;;;;;;;;;;;;;;;
|
2014-09-05 17:08:40 -04:00
|
|
|
(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-11-29 20:21:03 -05:00
|
|
|
(global-auto-revert-mode 1) ; revert buffers for changed files
|
2014-09-05 17:08:40 -04:00
|
|
|
(require 'shut-up)
|
2014-11-29 20:21:03 -05:00
|
|
|
(when noninteractive (shut-up-silence-emacs))
|
|
|
|
|
|
|
|
;; What we do every night, Pinkie...
|
|
|
|
(defun my/greeter () (message "What're we gonna do tonight, Brain?"))
|
|
|
|
(defalias 'display-startup-echo-area-message 'my/greeter)
|
|
|
|
|
|
|
|
(when (fboundp 'winner-mode) (winner-mode 1)) ; window layout undo/redo
|
2014-09-05 17:08:40 -04:00
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
|
|
|
|
;;;; Utility plugins ;;;;;;;;;;;;;;;;;;
|
2014-09-05 17:08:40 -04:00
|
|
|
;; Package management bootstrap
|
2014-11-29 20:21:03 -05:00
|
|
|
(require 'use-package)
|
2014-09-05 17:08:40 -04:00
|
|
|
(setq package-enable-at-startup nil
|
|
|
|
delete-old-versions t)
|
2014-11-29 20:21:03 -05:00
|
|
|
;; Add ./elisp/* to load-path
|
2014-09-05 17:08:40 -04:00
|
|
|
(let ((default-directory *elisp-dir))
|
|
|
|
(normal-top-level-add-to-load-path '("."))
|
|
|
|
(normal-top-level-add-subdirs-to-load-path))
|
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
(use-package key-chord
|
|
|
|
:init (key-chord-mode 1)
|
|
|
|
:config (setq key-chord-two-keys-delay 0.5))
|
|
|
|
|
|
|
|
(use-package recentf
|
|
|
|
:init
|
|
|
|
(progn (setq recentf-max-menu-items 0
|
|
|
|
recentf-max-saved-items 100
|
|
|
|
recentf-auto-cleanup 'never
|
|
|
|
recentf-save-file (concat *tmp-dir "recentf")
|
|
|
|
recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last\\'" "\\.revive\\'", "/TAGS\\'"))
|
|
|
|
(recentf-mode 1)))
|
|
|
|
|
|
|
|
(use-package smex
|
|
|
|
:commands (smex smex-major-mode-commands)
|
|
|
|
:config
|
|
|
|
(progn (smex-initialize)
|
|
|
|
;; Hook up smex to auto-update, rather than update on every run
|
|
|
|
(defun smex-update-after-load (unused)
|
|
|
|
(when (boundp 'smex-cache) (smex-update)))
|
|
|
|
(add-hook 'after-load-functions 'smex-update-after-load)))
|
|
|
|
|
|
|
|
(use-package popwin
|
|
|
|
:init (popwin-mode 1)
|
|
|
|
:config
|
|
|
|
(progn (setq popwin:popup-window-height 0.45)
|
|
|
|
(push '(diff-mode :position bottom :stick t) popwin:special-display-config)
|
|
|
|
(push '("*Backtrace*") popwin:special-display-config)
|
|
|
|
(push '("*Warnings*") popwin:special-display-config)
|
|
|
|
(push '("*Process List*") popwin:special-display-config)))
|