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.

153 lines
5.4 KiB

  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. ;; meaningful names for buffers with the same name
  59. (require 'uniquify)
  60. (setq uniquify-buffer-name-style 'forward)
  61. (setq uniquify-separator "/")
  62. (setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
  63. (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
  64. ;; saveplace: save location in file when saving files
  65. (setq save-place-file "~/.emacs.d/saveplace")
  66. (setq-default save-place t) ;; activate it for all buffers
  67. (require 'saveplace) ;; get the package
  68. ;; savehist: save some history
  69. (setq savehist-additional-variables ;; also save...
  70. '(search ring regexp-search-ring) ;; ... my search entries
  71. savehist-autosave-interval 60 ;; save every minute (default: 5 min)
  72. savehist-file (concat "~/.emacs.d" "/savehist")) ;; keep my home clean
  73. (savehist-mode t) ;; do customization before activation
  74. ;; save recent files
  75. (setq recentf-save-file (concat prelude-dir "recentf") ;; keep ~/ clean
  76. recentf-max-saved-items 100 ;; max save 100
  77. recentf-max-menu-items 15) ;; max 15 in menu
  78. (recentf-mode t) ;; turn it on
  79. ;; time-stamps
  80. ;; when there's "Time-stamp: <>" in the first 10 lines of the file
  81. (setq time-stamp-active t
  82. ;; check first 10 buffer lines for Time-stamp: <>
  83. time-stamp-line-limit 10
  84. time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
  85. (add-hook 'write-file-hooks 'time-stamp) ; update when saving
  86. ;; use shift + arrow keys to switch between visible buffers
  87. (require 'windmove)
  88. (windmove-default-keybindings 'super)
  89. ;; show-paren-mode: subtle highlighting of matching parens
  90. (show-paren-mode t)
  91. (setq show-paren-style 'parenthesis)
  92. ;; tramp, for sudo access
  93. (require 'tramp)
  94. ;; keep in mind known issues with zsh - see emacs wiki
  95. (setq tramp-default-method "ssh")
  96. ;; ido-mode
  97. (ido-mode t)
  98. (setq ido-enable-prefix nil
  99. ido-enable-flex-matching t
  100. ido-create-new-buffer 'always
  101. ido-use-filename-at-point 'guess
  102. ido-max-prospects 10
  103. ido-default-file-method 'selected-window)
  104. ;; auto-completion in minibuffer
  105. (icomplete-mode +1)
  106. (set-default 'imenu-auto-rescan t)
  107. ;; flyspell-mode
  108. (setq ispell-program-name "aspell" ; use aspell instead of ispell
  109. ispell-extra-args '("--sug-mode=ultra"))
  110. (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
  111. (defun prelude-turn-on-flyspell ()
  112. "Force flyspell-mode on using a positive argument. For use in hooks."
  113. (interactive)
  114. (flyspell-mode 1))
  115. (add-hook 'message-mode-hook 'prelude-turn-on-flyspell)
  116. (add-hook 'text-mode-hook 'prelude-turn-on-flyspell)
  117. ;; enable narrow to region
  118. (put 'narrow-to-region 'disabled nil)
  119. ;; bookmarks
  120. (setq bookmark-default-file "~/.emacs.d/bookmarks"
  121. bookmark-save-flag 1)
  122. (provide 'prelude-editor)
  123. ;;; prelude-editor.el ends here