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.

178 lines
6.0 KiB

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 (string= 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. ;; highlight when searching and replacing
  42. (setq search-highlight t
  43. query-replace-highlight t)
  44. ;; store all backup and autosave files in the tmp dir
  45. (setq backup-directory-alist
  46. `((".*" . ,temporary-file-directory)))
  47. (setq auto-save-file-name-transforms
  48. `((".*" ,temporary-file-directory t)))
  49. ;; revert buffers automatically when underlying files are changed externally
  50. (global-auto-revert-mode t)
  51. ;; hippie expand is dabbrev expand on steroids
  52. (setq hippie-expand-try-functions-list '(try-expand-dabbrev
  53. try-expand-dabbrev-all-buffers
  54. try-expand-dabbrev-from-kill
  55. try-complete-file-name-partially
  56. try-complete-file-name
  57. try-expand-all-abbrevs
  58. try-expand-list
  59. try-expand-line
  60. try-complete-lisp-symbol-partially
  61. try-complete-lisp-symbol))
  62. ;; smart indenting and pairing for all
  63. (electric-pair-mode t)
  64. (electric-indent-mode t)
  65. (electric-layout-mode t)
  66. ;; meaningful names for buffers with the same name
  67. (require 'uniquify)
  68. (setq uniquify-buffer-name-style 'forward)
  69. (setq uniquify-separator "/")
  70. (setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
  71. (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
  72. ;; saveplace: save location in file when saving files
  73. (setq save-place-file "~/.emacs.d/saveplace")
  74. (setq-default save-place t) ;; activate it for all buffers
  75. (require 'saveplace) ;; get the package
  76. ;; savehist: save some history
  77. (setq savehist-additional-variables ;; also save...
  78. '(search ring regexp-search-ring) ;; ... my search entries
  79. savehist-autosave-interval 60 ;; save every minute (default: 5 min)
  80. savehist-file (concat "~/.emacs.d" "/savehist")) ;; keep my home clean
  81. (savehist-mode t) ;; do customization before activation
  82. ;; save recent files
  83. (setq recentf-save-file (concat user-emacs-directory "recentf") ;; keep ~/ clean
  84. recentf-max-saved-items 100 ;; max save 100
  85. recentf-max-menu-items 15) ;; max 15 in menu
  86. (recentf-mode t) ;; turn it on
  87. ;; time-stamps
  88. ;; when there's "Time-stamp: <>" in the first 10 lines of the file
  89. (setq time-stamp-active t
  90. ;; check first 10 buffer lines for Time-stamp: <>
  91. time-stamp-line-limit 10
  92. time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
  93. (add-hook 'write-file-hooks 'time-stamp) ; update when saving
  94. ;; use shift + arrow keys to switch between visible buffers
  95. (require 'windmove)
  96. (windmove-default-keybindings 'super)
  97. ;; show-paren-mode: subtle highlighting of matching parens
  98. (show-paren-mode t)
  99. (setq show-paren-style 'parenthesis)
  100. ;; tramp, for sudo access
  101. (require 'tramp)
  102. ;; keep in mind known issues with zsh - see emacs wiki
  103. (setq tramp-default-method "ssh")
  104. ;; ido-mode
  105. (ido-mode t)
  106. (setq ido-enable-prefix nil
  107. ido-enable-flex-matching t
  108. ido-create-new-buffer 'always
  109. ido-use-filename-at-point 'guess
  110. ido-max-prospects 10
  111. ido-default-file-method 'selected-window)
  112. ;; auto-completion in minibuffer
  113. (icomplete-mode +1)
  114. (set-default 'imenu-auto-rescan t)
  115. ;; flyspell-mode
  116. (setq ispell-program-name "aspell" ; use aspell instead of ispell
  117. ispell-extra-args '("--sug-mode=ultra"))
  118. (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
  119. (defun prelude-turn-on-flyspell ()
  120. "Force flyspell-mode on using a positive argument. For use in hooks."
  121. (interactive)
  122. (flyspell-mode 1))
  123. (add-hook 'message-mode-hook 'prelude-turn-on-flyspell)
  124. (add-hook 'text-mode-hook 'prelude-turn-on-flyspell)
  125. ;; enable narrow to region
  126. (put 'narrow-to-region 'disabled nil)
  127. ;; bookmarks
  128. (setq bookmark-default-file "~/.emacs.d/bookmarks"
  129. bookmark-save-flag 1)
  130. ;; enabled auto-fill mode in text-mode and all related modes
  131. (add-hook 'text-mode-hook 'turn-on-auto-fill)
  132. ;; load yasnippet
  133. (require 'yasnippet) ;; not yasnippet-bundle
  134. (yas/initialize)
  135. ;; dispense of trailing whitespace once and for all
  136. (add-hook 'before-save-hook
  137. 'delete-trailing-whitespace)
  138. ;; projectile is a project management mode
  139. (require 'projectile)
  140. (projectile-global-mode t)
  141. (provide 'prelude-editor)
  142. ;;; prelude-editor.el ends here