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.

158 lines
5.5 KiB

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