emacs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. ;; Disable beep & flash
  2. (setq ring-bell-function 'ignore)
  3. ;; All yes or no prompts are y or n
  4. (defalias 'yes-or-no-p 'y-or-n-p)
  5. ;; Never follow symlinks
  6. (setq vc-follow-symlinks nil)
  7. ;; Leave the OS clipboard alone (use evil's "+ and "* instead)
  8. (setq x-select-enable-clipboard nil)
  9. ;; Text and Notes
  10. (setq sentence-end-double-space nil)
  11. ;; Save minibar history
  12. (savehist-mode 1)
  13. (setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring))
  14. ;; system-specific configs
  15. (defun win-setup ()
  16. (add-to-list 'exec-path "C:/Program Files (x86)/Aspell/bin/")
  17. (setq ispell-program-name "aspell"))
  18. (defun linux-setup ()
  19. (message ""))
  20. (cond ((eq system-type 'windows-nt) (win-setup))
  21. ((eq system-type 'gnu/linux) (linux-setup))
  22. (t (message "")))
  23. ;;;; Packages
  24. ;; Package installation
  25. (require 'package)
  26. (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
  27. (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
  28. (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
  29. (setq package-enable-at-startup nil)
  30. (package-initialize)
  31. ;; Function to ensure every package in installed, and ask if it isn't.
  32. (defun ensure-package-installed (&rest packages)
  33. (mapcar
  34. (lambda (package)
  35. (if (package-installed-p package)
  36. nil
  37. (if (y-or-n-p (format "Package %s is missing. Install it? " package))
  38. (package-install package)
  39. package)))
  40. packages))
  41. ;; Make sure to have downloaded archive description.
  42. (or (file-exists-p package-user-dir)
  43. (package-refresh-contents))
  44. ;; Activate installed packages
  45. (package-initialize)
  46. ;; Check that all packages are installed
  47. (ensure-package-installed
  48. 'iedit
  49. 'magit
  50. 'undo-tree
  51. 'evil
  52. 'evil-leader
  53. 'evil-tabs
  54. 'powerline-evil
  55. 'zenburn-theme
  56. 'auto-complete
  57. 'fuzzy
  58. 'general
  59. 'relative-line-numbers
  60. )
  61. ;;;; Evil
  62. (setq evil-want-C-i-jump nil)
  63. ;; Evil leader is Space
  64. (global-evil-leader-mode)
  65. (evil-leader/set-leader "<SPC>")
  66. ;; Evil tabs
  67. (global-evil-tabs-mode t)
  68. ;; Default to evil mode
  69. (evil-mode t)
  70. ;; Leader keybinds
  71. (evil-leader/set-key
  72. "u" 'undo-tree-visualize
  73. "m" 'recentf-open-files
  74. "l" 'auto-fill-mode
  75. "s" 'flyspell-mode)
  76. ;; Move all elements of evil-emacs-state-modes to evil-motion-state-modes
  77. (setq evil-motion-state-modes (append evil-emacs-state-modes evil-motion-state-modes))
  78. (setq evil-emacs-state-modes nil)
  79. ;; Delete info bindings for evil to take over
  80. (define-key Info-mode-map "g" nil)
  81. (define-key Info-mode-map "n" nil)
  82. (define-key Info-mode-map "p" nil)
  83. ;;;; Files
  84. ;; Disable file backup
  85. (setq make-backup-files nil)
  86. ;; Instead save undo history under .emacs.d/undo
  87. (setq undo-tree-auto-save-history t
  88. undo-tree-history-directory-alist
  89. `(("." . ,(concat user-emacs-directory "undo"))))
  90. (unless (file-exists-p (concat user-emacs-directory "undo"))
  91. (make-directory (concat user-emacs-directory "undo")))
  92. ;; Powerline
  93. (require 'powerline)
  94. (powerline-vim-theme)
  95. ;; Recent Files
  96. (require 'recentf)
  97. (recentf-mode 1)
  98. (setq recentf-max-menu-items 25)
  99. ;; Autocomplete
  100. (require 'auto-complete)
  101. (ac-config-default)
  102. ;;(define-key ac-mode-map (kbd "TAB") 'auto-complete)
  103. (setq ac-auto-start nil)
  104. (global-set-key (kbd "<backtab>") 'ac-previous)
  105. (ac-set-trigger-key "TAB")
  106. ;; Spelling
  107. ;; TODO Mess with how I want spelling to be done. Maybe enable spelling on auto-fill mode?
  108. ;; map ]s and [s to next and previously wrong word
  109. (require 'general)
  110. (general-evil-setup)
  111. (general-nmap "]"
  112. (general-key-dispatch 'evil-change
  113. "s" 'flyspell-goto-next-error
  114. ))
  115. (general-vmap "]" 'evil-change)
  116. ;; move point to previous error
  117. ;; based on code by hatschipuh at
  118. ;; http://emacs.stackexchange.com/a/14912/2017
  119. (defun flyspell-goto-previous-error (arg)
  120. "Go to arg previous spelling error."
  121. (interactive "p")
  122. (while (not (= 0 arg))
  123. (let ((pos (point))
  124. (min (point-min)))
  125. (if (and (eq (current-buffer) flyspell-old-buffer-error)
  126. (eq pos flyspell-old-pos-error))
  127. (progn
  128. (if (= flyspell-old-pos-error min)
  129. ;; goto beginning of buffer
  130. (progn
  131. (message "Restarting from end of buffer")
  132. (goto-char (point-max)))
  133. (backward-word 1))
  134. (setq pos (point))))
  135. ;; seek the next error
  136. (while (and (> pos min)
  137. (let ((ovs (overlays-at pos))
  138. (r '()))
  139. (while (and (not r) (consp ovs))
  140. (if (flyspell-overlay-p (car ovs))
  141. (setq r t)
  142. (setq ovs (cdr ovs))))
  143. (not r)))
  144. (backward-word 1)
  145. (setq pos (point)))
  146. ;; save the current location for next invocation
  147. (setq arg (1- arg))
  148. (setq flyspell-old-pos-error pos)
  149. (setq flyspell-old-buffer-error (current-buffer))
  150. (goto-char pos)
  151. (if (= pos min)
  152. (progn
  153. (message "No more miss-spelled word!")
  154. (setq arg 0))
  155. (forward-word)))))
  156. (general-nmap "["
  157. (general-key-dispatch 'evil-change
  158. "s" 'flyspell-goto-previous-error
  159. ))
  160. (general-vmap "[" 'evil-change)
  161. ;; Relative line numbers
  162. (require 'relative-line-numbers)
  163. (global-relative-line-numbers-mode)
  164. ;; TODO:
  165. ;; Go through the tutorials, skim the manuals
  166. ;; learning elisp
  167. ;; Fuzzy
  168. ;; Evil leader mode
  169. ;; Hotkey for undo tree
  170. ;; autocomplete
  171. ;; recent files
  172. ;; magit bindings
  173. (custom-set-variables
  174. ;; custom-set-variables was added by Custom.
  175. ;; If you edit it by hand, you could mess it up, so be careful.
  176. ;; Your init file should contain only one such instance.
  177. ;; If there is more than one, they won't work right.
  178. '(custom-enabled-themes (quote (zenburn)))
  179. '(custom-safe-themes
  180. (quote
  181. ("14f0fbf6f7851bfa60bf1f30347003e2348bf7a1005570fd758133c87dafe08f" "4e753673a37c71b07e3026be75dc6af3efbac5ce335f3707b7d6a110ecb636a3" default)))
  182. '(inhibit-default-init t)
  183. '(inhibit-startup-buffer-menu nil)
  184. '(inhibit-startup-echo-area-message "josh")
  185. '(initial-buffer-choice t)
  186. '(initial-scratch-message "")
  187. '(package-selected-packages
  188. (quote
  189. (relative-line-numbers general fuzzy auto-complete evil-tabs powerline-evil zenburn-theme magit iedit evil-leader))))
  190. (custom-set-faces
  191. ;; custom-set-faces was added by Custom.
  192. ;; If you edit it by hand, you could mess it up, so be careful.
  193. ;; Your init file should contain only one such instance.
  194. ;; If there is more than one, they won't work right.
  195. )