Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
5.9 KiB

14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. ;;; prelude-editor.el --- Emacs Prelude: enhanced core editing experience.
  2. ;;
  3. ;; Copyright (c) 2011 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
  6. ;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Refinements of the core editing experience in Emacs.
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. ;; customize
  29. (defgroup editor nil
  30. "Emacs Prelude Editor enhancements"
  31. :group 'prelude)
  32. ;; Emacs users obviously have little need for Command and Option keys,
  33. ;; but they do need Meta and Super
  34. (when (eq system-type 'darwin)
  35. (setq mac-command-modifier 'super)
  36. (setq mac-option-modifier 'meta))
  37. ;; Death to the tabs!
  38. (setq-default indent-tabs-mode nil)
  39. ;; delete the selection with a keypress
  40. (delete-selection-mode t)
  41. ;; store all backup and autosave files in the tmp dir
  42. (setq backup-directory-alist
  43. `((".*" . ,temporary-file-directory)))
  44. (setq auto-save-file-name-transforms
  45. `((".*" ,temporary-file-directory t)))
  46. ;; revert buffers automatically when underlying files are changed externally
  47. (global-auto-revert-mode t)
  48. ;; hippie expand is dabbrev expand on steroids
  49. (setq hippie-expand-try-functions-list '(try-expand-dabbrev
  50. try-expand-dabbrev-all-buffers
  51. try-expand-dabbrev-from-kill
  52. try-complete-file-name-partially
  53. try-complete-file-name
  54. try-expand-all-abbrevs
  55. try-expand-list
  56. try-expand-line
  57. try-complete-lisp-symbol-partially
  58. try-complete-lisp-symbol))
  59. ;; smart indenting and pairing for all
  60. (electric-pair-mode t)
  61. (electric-indent-mode t)
  62. (electric-layout-mode t)
  63. ;; meaningful names for buffers with the same name
  64. (require 'uniquify)
  65. (setq uniquify-buffer-name-style 'forward)
  66. (setq uniquify-separator "/")
  67. (setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
  68. (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
  69. ;; saveplace remembers your location in a file when saving files
  70. (setq save-place-file (concat user-emacs-directory "saveplace"))
  71. ;; activate it for all buffers
  72. (setq-default save-place t)
  73. (require 'saveplace)
  74. ;; savehist keeps track of some history
  75. (setq savehist-additional-variables
  76. ;; search entries
  77. '(search ring regexp-search-ring)
  78. ;; save every minute
  79. savehist-autosave-interval 60
  80. ;; keep the home clean
  81. savehist-file (concat user-emacs-directory "savehist"))
  82. (savehist-mode t)
  83. ;; save recent files
  84. (setq recentf-save-file (concat user-emacs-directory "recentf")
  85. recentf-max-saved-items 200
  86. recentf-max-menu-items 15)
  87. (recentf-mode t)
  88. ;; time-stamps
  89. ;; when there's "Time-stamp: <>" in the first 10 lines of the file
  90. (setq time-stamp-active t
  91. ;; check first 10 buffer lines for Time-stamp: <>
  92. time-stamp-line-limit 10
  93. time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
  94. (add-hook 'write-file-hooks 'time-stamp) ; update when saving
  95. ;; use shift + arrow keys to switch between visible buffers
  96. (require 'windmove)
  97. (windmove-default-keybindings 'super)
  98. ;; show-paren-mode: subtle highlighting of matching parens
  99. (show-paren-mode t)
  100. (setq show-paren-style 'parenthesis)
  101. ;; highlight the current line
  102. (global-hl-line-mode +1)
  103. ;; tramp, for sudo access
  104. (require 'tramp)
  105. ;; keep in mind known issues with zsh - see emacs wiki
  106. (setq tramp-default-method "ssh")
  107. ;; ido-mode
  108. (ido-mode t)
  109. (setq ido-enable-prefix nil
  110. ido-enable-flex-matching t
  111. ido-create-new-buffer 'always
  112. ido-use-filename-at-point 'guess
  113. ido-max-prospects 10
  114. ido-default-file-method 'selected-window)
  115. ;; auto-completion in minibuffer
  116. (icomplete-mode +1)
  117. (set-default 'imenu-auto-rescan t)
  118. ;; flyspell-mode does spell-checking on the fly as you type
  119. (setq ispell-program-name "aspell" ; use aspell instead of ispell
  120. ispell-extra-args '("--sug-mode=ultra"))
  121. (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
  122. (defun prelude-turn-on-flyspell ()
  123. "Force flyspell-mode on using a positive argument. For use in hooks."
  124. (interactive)
  125. (flyspell-mode +1))
  126. (add-hook 'message-mode-hook 'prelude-turn-on-flyspell)
  127. (add-hook 'text-mode-hook 'prelude-turn-on-flyspell)
  128. ;; enable narrow to region
  129. (put 'narrow-to-region 'disabled nil)
  130. ;; bookmarks
  131. (setq bookmark-default-file (concat user-emacs-directory "bookmarks")
  132. bookmark-save-flag 1)
  133. ;; enabled auto-fill mode in text-mode and all related modes
  134. (add-hook 'text-mode-hook 'turn-on-auto-fill)
  135. ;; load yasnippet
  136. (require 'yasnippet) ;; not yasnippet-bundle
  137. (yas/initialize)
  138. ;; dispense of trailing whitespace once and for all
  139. (add-hook 'before-save-hook
  140. 'delete-trailing-whitespace)
  141. ;; projectile is a project management mode
  142. (require 'projectile)
  143. (projectile-global-mode t)
  144. ;; dired - reuse current buffer by pressing 'a'
  145. (put 'dired-find-alternate-file 'disabled nil)
  146. (provide 'prelude-editor)
  147. ;;; prelude-editor.el ends here