Refactor init.el. make it lazier.
This commit is contained in:
parent
beb7e30fad
commit
345364aa51
213
init.el
213
init.el
@ -6,6 +6,7 @@
|
|||||||
;; (_)___|_| |_| |_|\__,_|\___|___/
|
;; (_)___|_| |_| |_|\__,_|\___|___/
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
|
|
||||||
|
|
||||||
(setq user-full-name
|
(setq user-full-name
|
||||||
(replace-regexp-in-string "\n$" "" (shell-command-to-string
|
(replace-regexp-in-string "\n$" "" (shell-command-to-string
|
||||||
"git config --get user.email")))
|
"git config --get user.email")))
|
||||||
@ -27,6 +28,14 @@
|
|||||||
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
|
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
|
||||||
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
|
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
|
||||||
|
|
||||||
|
;; These silence the byte compiler.
|
||||||
|
(defvar ido-cur-item nil)
|
||||||
|
(defvar ido-default-item nil)
|
||||||
|
(defvar ido-context-switch-command nil)
|
||||||
|
(defvar ido-cur-list nil)
|
||||||
|
(defvar predicate nil)
|
||||||
|
(defvar inherit-input-method nil)
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; Load Path Configuration
|
;; Load Path Configuration
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
@ -61,7 +70,7 @@
|
|||||||
(package-initialize)
|
(package-initialize)
|
||||||
(ensure-packages-installed '(epl use-package))
|
(ensure-packages-installed '(epl use-package))
|
||||||
(require 'use-package)
|
(require 'use-package)
|
||||||
(put 'use-package 'lisp-indent-function 1) ;; reduce indentation for use-package
|
(use-package benchmark-init :ensure t)
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; Disables
|
;; Disables
|
||||||
@ -95,34 +104,42 @@
|
|||||||
(setq split-width-threshold 160)
|
(setq split-width-threshold 160)
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; Config Free Packages
|
;; Config Free Packages
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
|
|
||||||
(defvar packages-essential
|
(defun use-packages (packages)
|
||||||
'(popup auto-complete mo-git-blame multiple-cursors yasnippet cl-lib flx-ido))
|
(mapcar
|
||||||
|
(lambda (package)
|
||||||
|
(use-package package :ensure t)) packages))
|
||||||
|
|
||||||
(defvar packages-other
|
(defvar packages-eager
|
||||||
'(thingatpt+ latex-preview-pane paredit inf-ruby rust-mode paradox
|
'(popup auto-complete yasnippet cl-lib exec-path-from-shell paradox slime
|
||||||
exec-path-from-shell slime yaml-mode sgml-mode
|
xclip dired+ ctags ctags-update aggressive-indent imenu+ neotree diminish
|
||||||
dired+ ctags ctags-update helm-gtags hackernews gitconfig-mode
|
gist))
|
||||||
aggressive-indent imenu+ weechat evil helm-ag xclip neotree
|
|
||||||
magit-gh-pulls diminish gist spotify ghc))
|
|
||||||
|
|
||||||
(defvar packages-appearance
|
(use-packages packages-eager)
|
||||||
'(monokai-theme solarized-theme zenburn-theme base16-theme molokai-theme
|
|
||||||
tango-2-theme gotham-theme sublime-themes ansi-color rainbow-delimiters
|
|
||||||
smart-mode-line powerline))
|
|
||||||
|
|
||||||
(ensure-packages-installed packages-essential)
|
|
||||||
(ensure-packages-installed packages-other)
|
|
||||||
(ensure-packages-installed packages-appearance)
|
|
||||||
|
|
||||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; functions
|
;; functions
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
|
|
||||||
|
(defun unfill-paragraph (&optional region)
|
||||||
|
"Takes a multi-line paragraph and makes it into a single line of text."
|
||||||
|
(interactive (progn
|
||||||
|
(barf-if-buffer-read-only)
|
||||||
|
(list t)))
|
||||||
|
(let ((fill-column (point-max)))
|
||||||
|
(fill-paragraph nil region)))
|
||||||
|
|
||||||
|
(defun fill-or-unfill-paragraph (&optional unfill region)
|
||||||
|
"Fill paragraph (or REGION).
|
||||||
|
With the prefix argument UNFILL, unfill it instead."
|
||||||
|
(interactive (progn
|
||||||
|
(barf-if-buffer-read-only)
|
||||||
|
(list (if current-prefix-arg 'unfill) t)))
|
||||||
|
(let ((fill-column (if unfill (point-max) fill-column)))
|
||||||
|
(fill-paragraph nil region)))
|
||||||
|
|
||||||
(defun sudo-edit (&optional arg)
|
(defun sudo-edit (&optional arg)
|
||||||
"Edit currently visited file as root.
|
"Edit currently visited file as root.
|
||||||
|
|
||||||
@ -235,10 +252,8 @@ buffer is not visiting a file."
|
|||||||
|
|
||||||
;; Make forward word understand camel and snake case.
|
;; Make forward word understand camel and snake case.
|
||||||
(setq c-subword-mode t)
|
(setq c-subword-mode t)
|
||||||
(setq sentence-end-double-space nil)
|
|
||||||
|
|
||||||
(add-hook 'after-init-hook '(lambda () (setq debug-on-error t)))
|
(add-hook 'after-init-hook '(lambda () (setq debug-on-error t)))
|
||||||
(add-hook 'after-init-hook #'flycheck-mode)
|
|
||||||
|
|
||||||
;; Don't popup frames in OSX.
|
;; Don't popup frames in OSX.
|
||||||
(setq ns-pop-up-frames nil)
|
(setq ns-pop-up-frames nil)
|
||||||
@ -249,6 +264,14 @@ buffer is not visiting a file."
|
|||||||
(require 'tramp)
|
(require 'tramp)
|
||||||
(setq tramp-default-method "ssh")
|
(setq tramp-default-method "ssh")
|
||||||
|
|
||||||
|
;; text mode stuff:
|
||||||
|
(remove-hook 'text-mode-hook #'turn-on-auto-fill)
|
||||||
|
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
|
||||||
|
(setq sentence-end-double-space nil)
|
||||||
|
|
||||||
|
;; y and n instead of yes and no
|
||||||
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||||
|
|
||||||
(use-package guide-key
|
(use-package guide-key
|
||||||
:ensure t
|
:ensure t
|
||||||
:config
|
:config
|
||||||
@ -276,6 +299,8 @@ buffer is not visiting a file."
|
|||||||
|
|
||||||
(use-package flycheck
|
(use-package flycheck
|
||||||
:ensure t
|
:ensure t
|
||||||
|
:commands (flycheck-mode)
|
||||||
|
:init (add-hook 'after-init-hook #'flycheck-mode)
|
||||||
:config
|
:config
|
||||||
(progn
|
(progn
|
||||||
(setq flycheck-checkers (delq 'emacs-lisp-checkdoc flycheck-checkers))
|
(setq flycheck-checkers (delq 'emacs-lisp-checkdoc flycheck-checkers))
|
||||||
@ -300,13 +325,14 @@ buffer is not visiting a file."
|
|||||||
:ensure t
|
:ensure t
|
||||||
:commands magit-status
|
:commands magit-status
|
||||||
:bind (("C-x g" . magit-status))
|
:bind (("C-x g" . magit-status))
|
||||||
:init
|
|
||||||
(progn
|
|
||||||
(if (emacs24_4-p)
|
|
||||||
(use-package magit-filenotify :ensure t))
|
|
||||||
(add-hook 'magit-status-mode-hook 'magit-filenotify-mode))
|
|
||||||
:config
|
:config
|
||||||
(diminish 'magit-auto-revert-mode))
|
(progn
|
||||||
|
(diminish 'magit-auto-revert-mode)
|
||||||
|
(use-package magit-filenotify
|
||||||
|
:ensure t
|
||||||
|
:if (emacs24_4-p)
|
||||||
|
:config
|
||||||
|
:init (add-hook 'magit-status-mode-hook 'magit-filenotify-mode))))
|
||||||
|
|
||||||
(use-package auto-complete
|
(use-package auto-complete
|
||||||
:ensure t
|
:ensure t
|
||||||
@ -353,6 +379,9 @@ buffer is not visiting a file."
|
|||||||
|
|
||||||
(use-package org
|
(use-package org
|
||||||
:ensure t
|
:ensure t
|
||||||
|
:defer t
|
||||||
|
:commands org
|
||||||
|
:mode "\\.org\\'"
|
||||||
:init
|
:init
|
||||||
(progn
|
(progn
|
||||||
(defun guide-key/my-hook-function-for-org-mode ()
|
(defun guide-key/my-hook-function-for-org-mode ()
|
||||||
@ -368,6 +397,17 @@ buffer is not visiting a file."
|
|||||||
:config
|
:config
|
||||||
(epa-file-enable))
|
(epa-file-enable))
|
||||||
|
|
||||||
|
(use-package erc
|
||||||
|
:config
|
||||||
|
(setq erc-autojoin-channels-alist
|
||||||
|
'(("freenode.net"
|
||||||
|
"#emacs"
|
||||||
|
"#scala"
|
||||||
|
"#python"
|
||||||
|
"#rust"))
|
||||||
|
erc-server "irc.freenode.net"
|
||||||
|
erc-nick "imalison"))
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; Programming Mode Hooks
|
;; Programming Mode Hooks
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
@ -384,6 +424,9 @@ buffer is not visiting a file."
|
|||||||
(use-package helm
|
(use-package helm
|
||||||
:ensure t
|
:ensure t
|
||||||
:bind (("M-y" . helm-show-kill-ring))
|
:bind (("M-y" . helm-show-kill-ring))
|
||||||
|
:init
|
||||||
|
(progn
|
||||||
|
(use-package helm-ag :ensure t :defer t))
|
||||||
:config
|
:config
|
||||||
(progn
|
(progn
|
||||||
(helm-mode 1)
|
(helm-mode 1)
|
||||||
@ -391,6 +434,7 @@ buffer is not visiting a file."
|
|||||||
|
|
||||||
(use-package projectile
|
(use-package projectile
|
||||||
:ensure t
|
:ensure t
|
||||||
|
:defer t
|
||||||
:config
|
:config
|
||||||
(progn
|
(progn
|
||||||
(setq projectile-enable-caching t)
|
(setq projectile-enable-caching t)
|
||||||
@ -398,8 +442,7 @@ buffer is not visiting a file."
|
|||||||
(setq projectile-completion-system 'helm)
|
(setq projectile-completion-system 'helm)
|
||||||
(helm-projectile-on)
|
(helm-projectile-on)
|
||||||
(diminish 'projectile-mode))
|
(diminish 'projectile-mode))
|
||||||
:bind (
|
:bind (("C-x f" . projectile-find-file-in-known-projects))
|
||||||
("C-x f" . projectile-find-file-in-known-projects))
|
|
||||||
:init
|
:init
|
||||||
(progn
|
(progn
|
||||||
(use-package persp-projectile
|
(use-package persp-projectile
|
||||||
@ -423,20 +466,24 @@ buffer is not visiting a file."
|
|||||||
:ensure t)))
|
:ensure t)))
|
||||||
(use-package helm-projectile
|
(use-package helm-projectile
|
||||||
:ensure t
|
:ensure t
|
||||||
:config
|
:commands (helm-projectile-on)
|
||||||
(progn (helm-projectile-on)))))
|
:defer t)))
|
||||||
|
|
||||||
(ido-mode t)
|
(ido-mode t)
|
||||||
(ido-ubiquitous-mode)
|
(ido-ubiquitous-mode)
|
||||||
(ido-everywhere 1)
|
(ido-everywhere 1)
|
||||||
(setq ido-enable-flex-matching t)
|
(setq ido-enable-flex-matching t)
|
||||||
|
|
||||||
(use-package smex :ensure t)
|
(use-package smex
|
||||||
|
:ensure t
|
||||||
|
:bind ("M-x" . smex))
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; elisp
|
;; elisp
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
|
|
||||||
|
(setq edebug-trace t)
|
||||||
|
|
||||||
(use-package elisp-slime-nav
|
(use-package elisp-slime-nav
|
||||||
:ensure t
|
:ensure t
|
||||||
:commands elisp-slime-nav-mode
|
:commands elisp-slime-nav-mode
|
||||||
@ -457,6 +504,7 @@ buffer is not visiting a file."
|
|||||||
,(concat ";\\{1,4\\} =\\{10,80\\}\n;\\{1,4\\} \\{10,80\\}"
|
,(concat ";\\{1,4\\} =\\{10,80\\}\n;\\{1,4\\} \\{10,80\\}"
|
||||||
"\\(.+\\)$") 1) t))
|
"\\(.+\\)$") 1) t))
|
||||||
|
|
||||||
|
(put 'use-package 'lisp-indent-function 1) ;; reduce indentation for use-package
|
||||||
(add-hook 'emacs-lisp-mode-hook 'imenu-elisp-sections)
|
(add-hook 'emacs-lisp-mode-hook 'imenu-elisp-sections)
|
||||||
(add-hook 'emacs-lisp-mode-hook 'flatten-current-imenu-index-function)
|
(add-hook 'emacs-lisp-mode-hook 'flatten-current-imenu-index-function)
|
||||||
(add-hook 'emacs-lisp-mode-hook (lambda () (setq indent-tabs-mode nil)))
|
(add-hook 'emacs-lisp-mode-hook (lambda () (setq indent-tabs-mode nil)))
|
||||||
@ -605,6 +653,17 @@ buffer is not visiting a file."
|
|||||||
(eval-after-load 'css-mode
|
(eval-after-load 'css-mode
|
||||||
'(define-key css-mode-map (kbd "C-c b") 'web-beautify-css))
|
'(define-key css-mode-map (kbd "C-c b") 'web-beautify-css))
|
||||||
|
|
||||||
|
;; =============================================================================
|
||||||
|
;; Ruby
|
||||||
|
;; =============================================================================
|
||||||
|
|
||||||
|
(use-package robe
|
||||||
|
:ensure t
|
||||||
|
:init
|
||||||
|
(progn (add-hook 'ruby-mode-hook 'robe-mode)
|
||||||
|
(add-hook 'robe-mode-hook 'ac-robe-setup)
|
||||||
|
(add-hook 'ruby-mode-hook 'auto-complete-mode)))
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; C/C++
|
;; C/C++
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
@ -643,38 +702,67 @@ buffer is not visiting a file."
|
|||||||
(setq TeX-save-query nil)
|
(setq TeX-save-query nil)
|
||||||
(setq-default TeX-master nil)))
|
(setq-default TeX-master nil)))
|
||||||
|
|
||||||
|
;; =============================================================================
|
||||||
|
;; other modes
|
||||||
|
;; =============================================================================
|
||||||
|
|
||||||
|
(use-package rust-mode :ensure t
|
||||||
|
:mode (("\\.rs\\'" . rust-mode)))
|
||||||
|
|
||||||
|
(use-package yaml-mode :ensure t
|
||||||
|
:mode (("\\.yaml\\'" . yaml-mode)
|
||||||
|
("\\.yml\\'" . yaml-mode)))
|
||||||
|
|
||||||
|
(use-package sgml-mode :ensure t)
|
||||||
|
(use-package gitconfig-mode :ensure t :mode "\\.gitconfig\\'")
|
||||||
|
|
||||||
|
(use-package evil :ensure t :commands (evil-mode))
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; Custom Key Bindings
|
;; Custom Key Bindings
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
|
|
||||||
(use-package multiple-cursors
|
(use-package multiple-cursors
|
||||||
|
:bind
|
||||||
|
(("C-c m a" . mc/mark-all-like-this)
|
||||||
|
("C-c m m" . mc/mark-all-like-this-dwim)
|
||||||
|
("C-c m l" . mc/edit-lines)
|
||||||
|
("C-c m n" . mc/mark-next-like-this)
|
||||||
|
("C-c m p" . mc/mark-previous-like-this)
|
||||||
|
("C-c m s" . mc/mark-sgml-tag-pair)
|
||||||
|
("C-c m d" . mc/mark-all-like-this-in-defun)))
|
||||||
|
|
||||||
|
(use-package phi-search-mc
|
||||||
:ensure t
|
:ensure t
|
||||||
:bind (("C-<" . mc/mark-previous-like-t)
|
:config
|
||||||
("C->" . mc/mark-next-like-this)
|
(phi-search-mc/setup-keys))
|
||||||
("C->" . mc/mark-next-like-this)
|
(use-package mc-extras
|
||||||
("C-c <" . mc/mark-all-like-this)
|
:ensure t
|
||||||
("C-x r t" . mc/edit-lines)))
|
:config
|
||||||
|
(define-key mc/keymap (kbd "C-. =") 'mc/compare-chars))
|
||||||
|
|
||||||
;; Miscellaneous
|
;; Miscellaneous
|
||||||
(global-unset-key (kbd "C-o")) ;; Avoid collision with tmux binding.
|
(global-unset-key (kbd "C-o")) ;; Avoid collision with tmux binding.
|
||||||
(global-set-key (kbd "C--") 'undo)
|
(bind-key "M-q" 'fill-or-unfill-paragraph)
|
||||||
(global-set-key (kbd "C-c +") 'message-buffer-name)
|
(bind-key "C--" 'undo)
|
||||||
|
(bind-key "C-c +" 'message-buffer-name)
|
||||||
(global-set-key (kbd "C-c C-s") 'sudo-edit)
|
(bind-key "C-c C-s" 'sudo-edit)
|
||||||
(global-set-key (kbd "C-c SPC") (lambda () (interactive)
|
(bind-key "C-c SPC"
|
||||||
(if current-prefix-arg (helm-global-mark-ring)
|
(lambda () (interactive)
|
||||||
(helm-mark-ring))))
|
(if current-prefix-arg (helm-global-mark-ring) (helm-mark-ring))))
|
||||||
(global-set-key (kbd "C-c e") 'os-copy)
|
(bind-key "C-c e" 'os-copy)
|
||||||
(global-set-key (kbd "C-x C-b") 'buffer-menu)
|
(bind-key "C-x p" 'pop-to-mark-command)
|
||||||
(global-set-key (kbd "C-x C-c") 'kill-emacs)
|
(setq set-mark-command-repeat-pop t)
|
||||||
(global-set-key (kbd "C-x C-i") 'imenu)
|
(bind-key "C-x C-b" 'buffer-menu)
|
||||||
(global-set-key (kbd "C-x C-r") (lambda () (interactive) (revert-buffer t t)))
|
(bind-key "C-x C-c" 'kill-emacs)
|
||||||
(global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1)))
|
(bind-key "C-x C-i" 'imenu)
|
||||||
(global-set-key (kbd "C-x w") 'whitespace-mode)
|
(bind-key "C-x C-r" (lambda () (interactive) (revert-buffer t t)))
|
||||||
(global-set-key (kbd "M-g") 'goto-line)
|
(bind-key "C-x O" (lambda () (interactive) (other-window -1)))
|
||||||
(global-set-key (kbd "M-n") 'forward-paragraph)
|
(bind-key "C-x w" 'whitespace-mode)
|
||||||
(global-set-key (kbd "M-p") 'backward-paragraph)
|
(bind-key "M-g" 'goto-line)
|
||||||
(global-set-key (kbd "M-z") 'zap-to-char)
|
(bind-key "M-n" 'forward-paragraph)
|
||||||
|
(bind-key "M-p" 'backward-paragraph)
|
||||||
|
(bind-key "M-z" 'zap-to-char)
|
||||||
|
|
||||||
(fset 'global-set-key-to-use-package
|
(fset 'global-set-key-to-use-package
|
||||||
(lambda (&optional arg) "Keyboard macro." (interactive "p")
|
(lambda (&optional arg) "Keyboard macro." (interactive "p")
|
||||||
@ -682,10 +770,23 @@ buffer is not visiting a file."
|
|||||||
(quote ([1 67108896 19 100 6 23 40 19 41 return
|
(quote ([1 67108896 19 100 6 23 40 19 41 return
|
||||||
backspace 32 46 6 4] 0 "%d")) arg)))
|
backspace 32 46 6 4] 0 "%d")) arg)))
|
||||||
|
|
||||||
|
;; =============================================================================
|
||||||
|
;; toys
|
||||||
|
;; =============================================================================
|
||||||
|
|
||||||
|
(use-package hackernews :ensure t :commands hackernews)
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; Appearance
|
;; Appearance
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
|
|
||||||
|
(defvar packages-appearance
|
||||||
|
'(monokai-theme solarized-theme zenburn-theme base16-theme molokai-theme
|
||||||
|
tango-2-theme gotham-theme sublime-themes ansi-color rainbow-delimiters
|
||||||
|
smart-mode-line))
|
||||||
|
|
||||||
|
(ensure-packages-installed packages-appearance)
|
||||||
|
|
||||||
;; No splash screen please... jeez
|
;; No splash screen please... jeez
|
||||||
(setq inhibit-startup-screen t)
|
(setq inhibit-startup-screen t)
|
||||||
(blink-cursor-mode -1)
|
(blink-cursor-mode -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user