init.el 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. ;;;; Startup
  2. ;(package-initialize)
  3. (setq inhibit-splash-screen t
  4. inhibit-startup-echo-area-message t
  5. initial-scratch-message "" ; I like things empty.
  6. initial-major-mode 'text-mode) ; I'm usually not writing elisp.
  7. ;; Base
  8. (setq ring-bell-function 'ignore) ; Disable beep & flash
  9. (blink-cursor-mode 0)
  10. ;; No scroll bar
  11. (when (boundp 'scroll-bar-mode)
  12. (scroll-bar-mode -1))
  13. ;; Disable toolbar
  14. (when (display-graphic-p)
  15. (tool-bar-mode -1))
  16. ;; smoother scrolling
  17. (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; one line at a time
  18. (setq mouse-wheel-progressive-speed nil) ; don't accelerate scrolling
  19. (setq scroll-margin 0
  20. scroll-conservatively 9999
  21. scroll-step 1)
  22. ;; Line settings and indicators
  23. (setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))
  24. (setq-default left-fringe-width nil)
  25. (setq-default indicate-empty-lines t)
  26. ;; All yes or no prompts are y or n
  27. (defalias 'yes-or-no-p 'y-or-n-p)
  28. ;; Never follow symlinks
  29. (setq vc-follow-symlinks nil)
  30. ;;; Leave the OS clipboard alone (use evil's "+ and "* instead)
  31. ; Don't copy and paste to the clipboard
  32. (setq select-enable-clipboard nil)
  33. (setq x-select-enable-clipboard nil)
  34. ; Don't save to the clipboard on exit
  35. (setq x-select-enable-clipboard-manager nil)
  36. ;; Text and Notes
  37. (setq sentence-end-double-space nil)
  38. ;; Save minibar history
  39. (savehist-mode 1)
  40. (setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring))
  41. ;; Always show matching parens
  42. (show-paren-mode t)
  43. ;; Save Window layout history
  44. (winner-mode)
  45. ;; Backups (from https://stackoverflow.com/questions/151945/how-do-i-control-how-emacs-makes-backup-files/20824625#20824625)
  46. (setq version-control t ;; Use version numbers for backups.
  47. kept-new-versions 10 ;; Number of newest versions to keep.
  48. kept-old-versions 0 ;; Number of oldest versions to keep.
  49. delete-old-versions t ;; Don't ask to delete excess backup versions.
  50. backup-by-copying t) ;; Copy all files, don't rename them.
  51. (setq vc-make-backup-files t) ;; Backup versioned files
  52. ;; Default and per-save backups go here:
  53. (setq backup-directory-alist '(("" . "~/.emacs.d/backups/per-save")))
  54. (defun force-backup-of-buffer ()
  55. ;; Make a special "per session" backup at the first save of each
  56. ;; emacs session.
  57. (when (not buffer-backed-up)
  58. ;; Override the default parameters for per-session backups.
  59. (let ((backup-directory-alist '(("" . "~/.emacs.d/backups/per-session")))
  60. (kept-new-versions 3))
  61. (backup-buffer)))
  62. ;; Make a "per save" backup on each save. The first save results in
  63. ;; both a per-session and a per-save backup, to keep the numbering
  64. ;; of per-save backups consistent.
  65. (let ((buffer-backed-up nil))
  66. (backup-buffer)))
  67. (add-hook 'before-save-hook 'force-backup-of-buffer)
  68. ;; Autosave files
  69. (setq auto-save-file-name-transforms
  70. `((".*" , "~/.emacs.d/backups/auto-saves" t)))
  71. ;; remember cursor position
  72. (toggle-save-place-globally)
  73. ;; Search all buffers
  74. (defun grep-search-all-buffers (regexp)
  75. (interactive "sRegexp: ")
  76. (multi-occur-in-matching-buffers "." regexp t))
  77. ;; Tags
  78. (defun create-tags (dir-name)
  79. "Create tags file."
  80. (interactive "DDirectory: ")
  81. (shell-command
  82. (format "\"%s\" -f TAGS -e -R %s" tags-generator (directory-file-name dir-name))))
  83. (add-to-list 'load-path (expand-file-name "packages" user-emacs-directory))
  84. (require 'packages)
  85. ;;;; System-specific configs
  86. (defun win-setup ()
  87. (add-to-list 'exec-path "C:/Program Files (x86)/Aspell/bin/")
  88. (setq ispell-program-name "aspell")
  89. ;; Add MinGW if it exists
  90. (if (file-directory-p "C:/MinGW/msys/1.0/bin")
  91. (setenv "PATH" (concat (getenv "PATH") "C:/MinGW/msys/1.0/bin")))
  92. ;; (add-to-list 'exec-path "C:/MinGW/msys/1.0/bin"))
  93. ;; Add tags
  94. (setq tags-generator (expand-file-name "ctags.exe" user-emacs-directory))
  95. (defun cmd ()
  96. (interactive)
  97. (make-comint-in-buffer "cmd" nil "cmd" nil)
  98. (switch-to-buffer "*cmd*")))
  99. (defun linux-setup ()
  100. (setq tage-generator "ctags"))
  101. (cond ((eq system-type 'windows-nt) (win-setup))
  102. ((eq system-type 'gnu/linux) (linux-setup))
  103. (t (message "")))
  104. ;;;; Custom
  105. (defconst custom-file (expand-file-name "custom.el" user-emacs-directory))
  106. ;; if no custom file exists, write a default one
  107. (unless (file-exists-p custom-file)
  108. (write-region "(custom-set-faces
  109. ;; custom-set-faces was added by Custom.
  110. ;; If you edit it by hand, you could mess it up, so be careful.
  111. ;; Your init file should contain only one such instance.
  112. ;; If there is more than one, they won't work right.
  113. '(powerline-evil-normal-face ((t (:background \"#859900\")))))
  114. (custom-set-variables
  115. ;; custom-set-variables was added by Custom.
  116. ;; If you edit it by hand, you could mess it up, so be careful.
  117. ;; Your init file should contain only one such instance.
  118. ;; If there is more than one, they won't work right.
  119. '(custom-enabled-themes (quote (monokai)))
  120. '(custom-safe-themes
  121. (quote
  122. (\"c7a9a68bd07e38620a5508fef62ec079d274475c8f92d75ed0c33c45fbe306bc\" default))))
  123. " nil custom-file))
  124. (load custom-file)