diff options
| author | jason | 2017-06-16 11:31:24 -0600 |
|---|---|---|
| committer | jason | 2017-06-16 11:31:24 -0600 |
| commit | 9de78f34f36851e6471cb8e20b80bee907d0711a (patch) | |
| tree | db15ff66de9962e0338d8792ed16ab6b6a9c21e1 | |
| download | dotemacs-9de78f34f36851e6471cb8e20b80bee907d0711a.tar.gz dotemacs-9de78f34f36851e6471cb8e20b80bee907d0711a.zip | |
Initial commit
| -rw-r--r-- | init.el | 197 | ||||
| -rw-r--r-- | local-lib/persp-conf.el | 38 | ||||
| -rw-r--r-- | local-lib/powerline-conf.el | 95 | ||||
| -rw-r--r-- | local-lib/projectile-conf.el | 16 | ||||
| -rw-r--r-- | local-lib/zzq-funcs.el | 17 |
5 files changed, 363 insertions, 0 deletions
| @@ -0,0 +1,197 @@ | |||
| 1 | ;;; init.el --- emacs start up | ||
| 2 | ;; Author: jason <jason@zzq.org> | ||
| 3 | ;; Created: 03 Dec 2015 | ||
| 4 | ;; Version: 0.2 | ||
| 5 | ;; Keywords: | ||
| 6 | ;; X-URL: https://beehive.io/jason/emacs.d/ | ||
| 7 | ;;; Commentary: | ||
| 8 | ;; | ||
| 9 | ;;; Code: | ||
| 10 | (defconst emacs-start-time (current-time)) | ||
| 11 | (setq inhibit-startup-screen t ;; Hide the default startup screen | ||
| 12 | savehist-file "~/.emacs.d/savehist" | ||
| 13 | ;; Define where to store recovery files | ||
| 14 | backup-directory-alist '(("." . "~/.emacs.d/backups")) | ||
| 15 | ;; Use version numbers for backups. | ||
| 16 | version-control t | ||
| 17 | ;; Number of newest versions to keep. | ||
| 18 | kept-new-versions 10 | ||
| 19 | ;; Number of oldest versions to keep. | ||
| 20 | kept-old-versions 0 | ||
| 21 | ;; Don't ask to delete excess backup versions. | ||
| 22 | delete-old-versions -1 | ||
| 23 | ;; Copy all files, don't rename them. | ||
| 24 | backup-by-copying t | ||
| 25 | ;; Make backups files under version control. | ||
| 26 | vc-make-backup-files t | ||
| 27 | ;; Don't confirm following when opening a symlink | ||
| 28 | vc-follow-symlinks t) | ||
| 29 | |||
| 30 | (setq package-archives '(("elpa" . "http://elpa.gnu.org/packages/") | ||
| 31 | ;; For org-mode | ||
| 32 | ("org" . "http://orgmode.org/elpa/") | ||
| 33 | ;; melpa builds git repositories and can be unstable | ||
| 34 | ("melpa" . "http://melpa.org/packages/") | ||
| 35 | ;; marmalade has maintainers upload versions | ||
| 36 | ;; ("marmalade" . "https://marmalade-repo.org/packages/") | ||
| 37 | ;; melpa-stable builds from git tags but may be missing dependencies | ||
| 38 | ;; ("melpa-stable" . "https://stable.melpa.org/packages/") | ||
| 39 | ;; Elpy packages for the Python language | ||
| 40 | ;; ("elpy" . "https://jorgenschaefer.github.io/packages/") | ||
| 41 | )) | ||
| 42 | |||
| 43 | ;; Initializes installed packages | ||
| 44 | (package-initialize) | ||
| 45 | |||
| 46 | ;; Packages are managed by the use-package package, so we need to make sure it's installed | ||
| 47 | (unless (package-installed-p 'use-package) | ||
| 48 | (package-refresh-contents) | ||
| 49 | (package-install 'use-package)) | ||
| 50 | (eval-when-compile | ||
| 51 | (require 'use-package)) | ||
| 52 | ;; slight optimization for use-package's :bind directive | ||
| 53 | (require 'bind-key) | ||
| 54 | |||
| 55 | ;; Add local library to the load path | ||
| 56 | (add-to-list 'load-path "~/.emacs.d/local-lib/") | ||
| 57 | ;; Usernames and passwords are stored in a file that isn't sync'd to VC | ||
| 58 | (load "~/.emacs.d/secrets" t) | ||
| 59 | |||
| 60 | ;; My misc functions | ||
| 61 | (require 'zzq-funcs) | ||
| 62 | |||
| 63 | (add-hook 'after-init-hook | ||
| 64 | (lambda () | ||
| 65 | (progn | ||
| 66 | ;; Maximize the frame on startup | ||
| 67 | (toggle-frame-maximized) | ||
| 68 | ;; Always ensure packages are installed if they are defined with use-package | ||
| 69 | ;; (setq use-package-always-ensure t) | ||
| 70 | |||
| 71 | ;; Set default encoding to UTF-8 | ||
| 72 | (set-language-environment "UTF-8") | ||
| 73 | (set-default-coding-systems 'utf-8) | ||
| 74 | ;; Hide the toolbar | ||
| 75 | (tool-bar-mode -1) | ||
| 76 | ;; Hide the scrollbar | ||
| 77 | (scroll-bar-mode -1) | ||
| 78 | ;; no beep and no blinking cursor | ||
| 79 | (setq ring-bell-function 'ignore | ||
| 80 | visible-bell nil | ||
| 81 | ;; display the full file path in the titlebar | ||
| 82 | frame-title-format | ||
| 83 | (list (format "%s %%S: %%j " (system-name)) | ||
| 84 | '(buffer-file-name "%f" (dired-directory dired-directory "%b")))) | ||
| 85 | |||
| 86 | ;; Show matched parens | ||
| 87 | (show-paren-mode t) | ||
| 88 | ;; Allow undoing/redoing of window layouts with C-c left/right arrows | ||
| 89 | (winner-mode 1) | ||
| 90 | ;; Let y and n be good enough for yes and no questions | ||
| 91 | (fset 'yes-or-no-p 'y-or-n-p) | ||
| 92 | ;; Auto-refresh files changed on the file system | ||
| 93 | (global-auto-revert-mode 1) | ||
| 94 | ;; Save commands and their history | ||
| 95 | (savehist-mode +1) | ||
| 96 | (setq savehist-save-minibuffer-history +1) | ||
| 97 | (setq savehist-additional-variables | ||
| 98 | '(kill-ring | ||
| 99 | search-ring | ||
| 100 | regexp-search-ring)) | ||
| 101 | ;; Allow mouse support in xterm | ||
| 102 | (xterm-mouse-mode 1) | ||
| 103 | ;; Automatically close parens when opening them | ||
| 104 | (electric-pair-mode 1) | ||
| 105 | ;; Ovewrite selected regions with what you're typing/pasting/etc | ||
| 106 | (delete-selection-mode 1) | ||
| 107 | ;; A region is only active when it is highlighted (mimics other editors) | ||
| 108 | (transient-mark-mode 1) | ||
| 109 | ;;;;;;;;;;; | ||
| 110 | ;; Hooks ;; | ||
| 111 | ;;;;;;;;;;; | ||
| 112 | (add-hook 'write-file-hooks | ||
| 113 | '(lambda () | ||
| 114 | ;; delete trailing whitespace from all files | ||
| 115 | (delete-trailing-whitespace))) | ||
| 116 | ;;;;;;;;;;;; | ||
| 117 | ;; Themes ;; | ||
| 118 | ;;;;;;;;;;;; | ||
| 119 | (use-package jbeans-theme | ||
| 120 | :ensure t | ||
| 121 | :config | ||
| 122 | (load-theme 'jbeans)) | ||
| 123 | ;;;;;;;;;;;;;; | ||
| 124 | ;; Packages ;; | ||
| 125 | ;;;;;;;;;;;;;; | ||
| 126 | ;; paradox - A better emacs package manager | ||
| 127 | (use-package paradox | ||
| 128 | :ensure t | ||
| 129 | :config | ||
| 130 | ;; Use paradox as the default package manager | ||
| 131 | (paradox-enable)) | ||
| 132 | ;; which-key - Displays a pop up with hints when pushing key bindings | ||
| 133 | (use-package which-key | ||
| 134 | :ensure t | ||
| 135 | :diminish which-key-mode | ||
| 136 | :init | ||
| 137 | (setq which-key-special-keys nil | ||
| 138 | which-key-use-C-h-commands t | ||
| 139 | which-key-echo-keystrokes 0.02 | ||
| 140 | which-key-max-description-length 32 | ||
| 141 | which-key-sort-order 'which-key-key-order-alpha) | ||
| 142 | :config | ||
| 143 | (which-key-mode)) | ||
| 144 | ;; Ivy, swiper, and counsel for autocompleting emacs things | ||
| 145 | (use-package ivy | ||
| 146 | :ensure t | ||
| 147 | :pin elpa | ||
| 148 | :diminish ivy-mode | ||
| 149 | :bind (("C-s" . swiper) | ||
| 150 | ("M-x" . counsel-M-x) | ||
| 151 | ("C-x C-f" . counsel-find-file)) | ||
| 152 | :init | ||
| 153 | ;; Remove the ^ prefix | ||
| 154 | (setq ivy-initial-inputs-alist nil | ||
| 155 | ;; Display recently opened files when switching buffers | ||
| 156 | ivy-use-virtual-buffers t | ||
| 157 | ;; Use ivy for magit | ||
| 158 | magit-completing-read-function 'ivy-completing-read | ||
| 159 | ;; Use ivy for projectile | ||
| 160 | projectile-completion-system 'ivy) | ||
| 161 | :config | ||
| 162 | (ivy-mode 1)) | ||
| 163 | ;; avy - A quick way to jump around buffers | ||
| 164 | (use-package avy | ||
| 165 | :ensure t | ||
| 166 | :bind (("C-:" . avy-goto-line))) | ||
| 167 | ;; Other packages | ||
| 168 | ;; persp - virtual workspaces | ||
| 169 | (require 'persp-conf) | ||
| 170 | ;; powerline - prettier modeline | ||
| 171 | (require 'powerline-conf) | ||
| 172 | ;; projectile - utilities for working with projects | ||
| 173 | (require 'projectile-conf) | ||
| 174 | |||
| 175 | (message "Emacs loaded in %.3fs" | ||
| 176 | (/ (- (zzq/time-to-msec (current-time)) (zzq/time-to-msec emacs-start-time)) 1000.0)) | ||
| 177 | ))) ;; End progn/lambda/add-hook after-init-hook | ||
| 178 | |||
| 179 | (custom-set-variables | ||
| 180 | ;; custom-set-variables was added by Custom. | ||
| 181 | ;; If you edit it by hand, you could mess it up, so be careful. | ||
| 182 | ;; Your init file should contain only one such instance. | ||
| 183 | ;; If there is more than one, they won't work right. | ||
| 184 | '(custom-safe-themes | ||
| 185 | (quote | ||
| 186 | ("64f2981274fd8740b794bce9feee7949ed87b88fc0b4654bd98594e1aa81abcd" default))) | ||
| 187 | '(package-selected-packages | ||
| 188 | (quote | ||
| 189 | (projectile persp-mode avy ivy powerline which-key paradox use-package jbeans-theme))) | ||
| 190 | '(paradox-github-token t)) | ||
| 191 | |||
| 192 | (custom-set-faces | ||
| 193 | ;; custom-set-faces was added by Custom. | ||
| 194 | ;; If you edit it by hand, you could mess it up, so be careful. | ||
| 195 | ;; Your init file should contain only one such instance. | ||
| 196 | ;; If there is more than one, they won't work right. | ||
| 197 | '(default ((t (:family "Inconsolata" :foundry "outline" :slant normal :weight normal :height 79 :width normal))))) | ||
diff --git a/local-lib/persp-conf.el b/local-lib/persp-conf.el new file mode 100644 index 0000000..f875440 --- /dev/null +++ b/local-lib/persp-conf.el | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | ;;; persp-conf.el --- configuration for persp-mode | ||
| 2 | ;; Author: jason <jason@zzq.org> | ||
| 3 | ;; Created: 16 Jun 2017 | ||
| 4 | ;; X-URL: https://github.com/Bad-ptr/persp-mode.el | ||
| 5 | ;;; Commentary: | ||
| 6 | ;; | ||
| 7 | ;; Enables different "workspaces" within Emacs. Similar to how a window manager | ||
| 8 | ;; might have several desktops | ||
| 9 | ;; | ||
| 10 | ;; Bindings: | ||
| 11 | ;; * <f8> - Switch between perspectives | ||
| 12 | ;; * <f9>, p - Manage perspectives | ||
| 13 | ;; | ||
| 14 | ;;; Code: | ||
| 15 | (use-package persp-mode | ||
| 16 | :ensure t | ||
| 17 | :bind (([f8] . persp-switch)) | ||
| 18 | :init | ||
| 19 | (setq persp-nil-name "Home" | ||
| 20 | persp-auto-resume-time 0) | ||
| 21 | ;; Adding this so that capturing process is not interrupted with annoying | ||
| 22 | ;; prompts "Kill and Close" etc. | ||
| 23 | (setq persp-kill-foreign-buffer-action nil | ||
| 24 | ;; increase the default name length | ||
| 25 | persp-lighter '(:eval (format (propertize " #%.10s" | ||
| 26 | 'face (let ((persp (get-current-persp))) | ||
| 27 | (if persp | ||
| 28 | (if (persp-contain-buffer-p (current-buffer) persp) | ||
| 29 | 'persp-face-lighter-default | ||
| 30 | 'persp-face-lighter-buffer-not-in-persp) | ||
| 31 | 'persp-face-lighter-nil-persp))) | ||
| 32 | (safe-persp-name (get-current-persp))))) | ||
| 33 | :config | ||
| 34 | ;; Set the persp-mode keymap prefix to <F9>, p | ||
| 35 | (persp-set-keymap-prefix (kbd "<f9> p")) | ||
| 36 | (persp-mode 1)) | ||
| 37 | |||
| 38 | (provide 'persp-conf) | ||
diff --git a/local-lib/powerline-conf.el b/local-lib/powerline-conf.el new file mode 100644 index 0000000..e994f8c --- /dev/null +++ b/local-lib/powerline-conf.el | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | ;;; powerline-conf.el --- configuration for powerline | ||
| 2 | ;; Author: jason <jason@zzq.org> | ||
| 3 | ;; Created: 16 Jun 2017 | ||
| 4 | ;; X-URL: https://github.com/milkypostman/powerline | ||
| 5 | ;;; Commentary: | ||
| 6 | ;; | ||
| 7 | ;; Styles the Emacs mode line | ||
| 8 | ;; | ||
| 9 | ;;; Code: | ||
| 10 | (defface my/modeline-narrow-face | ||
| 11 | '((t (:foreground "black" :background "yellow3"))) | ||
| 12 | "todo/fixme highlighting." | ||
| 13 | :group 'faces) | ||
| 14 | |||
| 15 | (defface my/modeline-read-only-face | ||
| 16 | '((t (:foreground "black" :background "orange4"))) | ||
| 17 | "Read-only buffer highlighting." | ||
| 18 | :group 'faces) | ||
| 19 | |||
| 20 | (defface my/modeline-modified-face | ||
| 21 | '((t (:foreground "gray80" :background "red4"))) | ||
| 22 | "Modified buffer highlighting." | ||
| 23 | :group 'faces) | ||
| 24 | |||
| 25 | (defun powerline-my-theme () | ||
| 26 | "Setup the default mode-line." | ||
| 27 | (interactive) | ||
| 28 | (setq-default mode-line-format | ||
| 29 | '("%e" | ||
| 30 | (:eval | ||
| 31 | (let* ((active (powerline-selected-window-active)) | ||
| 32 | (mode-line (if active 'mode-line 'mode-line-inactive)) | ||
| 33 | (face1 (if active 'powerline-active1 'powerline-inactive1)) | ||
| 34 | (face2 (if active 'powerline-active2 'powerline-inactive2)) | ||
| 35 | (separator-left (intern (format "powerline-%s-%s" | ||
| 36 | (powerline-current-separator) | ||
| 37 | (car powerline-default-separator-dir)))) | ||
| 38 | (separator-right (intern (format "powerline-%s-%s" | ||
| 39 | (powerline-current-separator) | ||
| 40 | (cdr powerline-default-separator-dir)))) | ||
| 41 | (lhs (append (list (powerline-raw " ")) | ||
| 42 | (let ((buffer-modified-str (if buffer-read-only | ||
| 43 | (if (buffer-modified-p) "%%*" "%%%%") | ||
| 44 | (if (buffer-modified-p) "**" "--")))) | ||
| 45 | (if buffer-read-only | ||
| 46 | (list (powerline-raw buffer-modified-str 'my/modeline-read-only-face)) | ||
| 47 | (if (buffer-modified-p) | ||
| 48 | (list (powerline-raw buffer-modified-str 'my/modeline-modified-face)) | ||
| 49 | (list (powerline-raw buffer-modified-str nil)))) | ||
| 50 | ) | ||
| 51 | (list | ||
| 52 | (when powerline-display-buffer-size | ||
| 53 | (powerline-buffer-size nil 'l)) | ||
| 54 | (when powerline-display-mule-info | ||
| 55 | (powerline-raw mode-line-mule-info nil 'l)) | ||
| 56 | (powerline-buffer-id nil 'l) | ||
| 57 | (when (and (boundp 'which-func-mode) which-func-mode) | ||
| 58 | (powerline-raw which-func-format nil 'l)) | ||
| 59 | (powerline-raw " ") | ||
| 60 | (funcall separator-left mode-line face1) | ||
| 61 | (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) | ||
| 62 | (powerline-raw erc-modified-channels-object face1 'l)) | ||
| 63 | (powerline-major-mode face1 'l) | ||
| 64 | (powerline-process face1) | ||
| 65 | (powerline-minor-modes face1 'l) | ||
| 66 | (powerline-narrow face1 'l) | ||
| 67 | (powerline-raw " " face1) | ||
| 68 | (funcall separator-left face1 face2) | ||
| 69 | (powerline-vc face2 'r) | ||
| 70 | (when (bound-and-true-p nyan-mode) | ||
| 71 | (powerline-raw (list (nyan-create)) face2 'l))))) | ||
| 72 | (rhs (list (powerline-raw global-mode-string face2 'r) | ||
| 73 | ;; (funcall separator-right face2 face1) | ||
| 74 | ;; (unless window-system | ||
| 75 | ;; (powerline-raw (char-to-string #xe0a1) face1 'l)) | ||
| 76 | (powerline-raw "%4l" face1 'l) | ||
| 77 | (powerline-raw ":" face1 'l) | ||
| 78 | (powerline-raw "%3c" face1 'r) | ||
| 79 | (funcall separator-right face1 mode-line) | ||
| 80 | (powerline-raw " ") | ||
| 81 | (powerline-raw "%6p" nil 'r) | ||
| 82 | (when powerline-display-hud | ||
| 83 | (powerline-hud face2 face1))))) | ||
| 84 | (concat (powerline-render lhs) | ||
| 85 | (powerline-fill face2 (powerline-width rhs)) | ||
| 86 | (powerline-render rhs))))))) | ||
| 87 | |||
| 88 | (use-package powerline | ||
| 89 | :config | ||
| 90 | (setq powerline-default-separator 'wave | ||
| 91 | powerline-display-mule-info nil) | ||
| 92 | |||
| 93 | (powerline-my-theme)) | ||
| 94 | |||
| 95 | (provide 'powerline-conf) | ||
diff --git a/local-lib/projectile-conf.el b/local-lib/projectile-conf.el new file mode 100644 index 0000000..0472af8 --- /dev/null +++ b/local-lib/projectile-conf.el | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | ;;; projectile-conf.el --- configuration for projectile-mode | ||
| 2 | ;; Author: jason <jason@zzq.org> | ||
| 3 | ;; Created: 16 Jun 2017 | ||
| 4 | ;; X-URL: https://github.com/bbatsov/projectile | ||
| 5 | ;;; Commentary: | ||
| 6 | ;; | ||
| 7 | ;; Useful functions for working within projects. | ||
| 8 | ;; | ||
| 9 | ;;; Code: | ||
| 10 | (use-package projectile | ||
| 11 | :ensure t | ||
| 12 | :diminish projectile-mode | ||
| 13 | :config | ||
| 14 | (projectile-global-mode)) | ||
| 15 | |||
| 16 | (provide 'projectile-conf) | ||
diff --git a/local-lib/zzq-funcs.el b/local-lib/zzq-funcs.el new file mode 100644 index 0000000..3d38b11 --- /dev/null +++ b/local-lib/zzq-funcs.el | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | ;;; zzq-funcs.el --- miscellaneous functions | ||
| 2 | ;; Author: jason <jason@zzq.org> | ||
| 3 | ;; Created: 15 Jun 2017 | ||
| 4 | ;; X-URL: https://beehive.io/jason/emacs.d/ | ||
| 5 | ;;; Commentary: | ||
| 6 | ;; | ||
| 7 | ;; Contains miscellaneous functions I've written or collected. | ||
| 8 | ;; | ||
| 9 | ;;; Code: | ||
| 10 | (defun zzq/time-to-sec (time) | ||
| 11 | "Convert the output of (current-time) to epoch in seconds" | ||
| 12 | (truncate (+ (+ (* (nth 0 time) (expt 2 16)) (nth 1 time)) (* (nth 2 time) (expt 10 -6))))) | ||
| 13 | (defun zzq/time-to-msec (time) | ||
| 14 | "Convert the output of (current-time) to epoch in milliseconds" | ||
| 15 | (truncate (* 1000 (+ (+ (* (nth 0 time) (expt 2 16)) (nth 1 time)) (* (nth 2 time) (expt 10 -6)))))) | ||
| 16 | |||
| 17 | (provide 'zzq-funcs) | ||