emacs-prelude/modules/prelude-editor.el

179 lines
6 KiB
EmacsLisp
Raw Normal View History

2011-10-08 23:05:06 +03:00
;;; prelude-editor.el --- Emacs Prelude: enhanced core editing experience.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude
;; Version: 1.0.0
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; Commentary:
;; Refinements of the core editing experience in Emacs.
;;; License:
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
2011-10-15 13:04:02 +03:00
;; customize
(defgroup editor nil
"Emacs Prelude Editor enhancements"
:group 'prelude)
2011-10-07 23:25:37 +03:00
;; Emacs users obviously have little need for Command and Option keys,
;; but they do need Meta and Super
2011-10-08 23:05:06 +03:00
(when (string= system-type "darwin")
2011-10-07 23:25:37 +03:00
(setq mac-command-modifier 'super)
(setq mac-option-modifier 'meta))
;; Death to the tabs!
(setq-default indent-tabs-mode nil)
;; delete the selection with a keypress
(delete-selection-mode t)
;; highlight when searching and replacing
2011-10-08 23:05:06 +03:00
(setq search-highlight t
2011-10-07 23:25:37 +03:00
query-replace-highlight t)
;; store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;; revert buffers automatically when underlying files are changed externally
(global-auto-revert-mode t)
;; hippie expand is dabbrev expand on steroids
(setq hippie-expand-try-functions-list '(try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
2011-10-09 00:24:41 +03:00
;; smart indenting and pairing for all
(electric-pair-mode t)
(electric-indent-mode t)
2011-10-09 11:21:57 +03:00
(electric-layout-mode t)
2011-10-09 00:24:41 +03:00
2011-10-07 23:25:37 +03:00
;; meaningful names for buffers with the same name
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(setq uniquify-separator "/")
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
;; saveplace: save location in file when saving files
(setq save-place-file "~/.emacs.d/saveplace")
(setq-default save-place t) ;; activate it for all buffers
(require 'saveplace) ;; get the package
;; savehist: save some history
(setq savehist-additional-variables ;; also save...
'(search ring regexp-search-ring) ;; ... my search entries
savehist-autosave-interval 60 ;; save every minute (default: 5 min)
savehist-file (concat "~/.emacs.d" "/savehist")) ;; keep my home clean
(savehist-mode t) ;; do customization before activation
;; save recent files
2011-10-11 21:24:22 +03:00
(setq recentf-save-file (concat user-emacs-directory "recentf") ;; keep ~/ clean
2011-10-07 23:25:37 +03:00
recentf-max-saved-items 100 ;; max save 100
recentf-max-menu-items 15) ;; max 15 in menu
(recentf-mode t) ;; turn it on
;; time-stamps
;; when there's "Time-stamp: <>" in the first 10 lines of the file
2011-10-08 23:05:06 +03:00
(setq time-stamp-active t
;; check first 10 buffer lines for Time-stamp: <>
time-stamp-line-limit 10
time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
2011-10-07 23:25:37 +03:00
(add-hook 'write-file-hooks 'time-stamp) ; update when saving
;; use shift + arrow keys to switch between visible buffers
(require 'windmove)
(windmove-default-keybindings 'super)
;; show-paren-mode: subtle highlighting of matching parens
(show-paren-mode t)
(setq show-paren-style 'parenthesis)
;; tramp, for sudo access
(require 'tramp)
;; keep in mind known issues with zsh - see emacs wiki
(setq tramp-default-method "ssh")
;; ido-mode
(ido-mode t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
ido-max-prospects 10
ido-default-file-method 'selected-window)
;; auto-completion in minibuffer
(icomplete-mode +1)
(set-default 'imenu-auto-rescan t)
;; flyspell-mode
(setq ispell-program-name "aspell" ; use aspell instead of ispell
ispell-extra-args '("--sug-mode=ultra"))
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
2011-10-08 23:05:06 +03:00
(defun prelude-turn-on-flyspell ()
2011-10-07 23:25:37 +03:00
"Force flyspell-mode on using a positive argument. For use in hooks."
(interactive)
(flyspell-mode 1))
2011-10-08 23:05:06 +03:00
(add-hook 'message-mode-hook 'prelude-turn-on-flyspell)
(add-hook 'text-mode-hook 'prelude-turn-on-flyspell)
2011-10-07 23:25:37 +03:00
;; enable narrow to region
(put 'narrow-to-region 'disabled nil)
;; bookmarks
2011-10-08 23:05:06 +03:00
(setq bookmark-default-file "~/.emacs.d/bookmarks"
bookmark-save-flag 1)
;; enabled auto-fill mode in text-mode and all related modes
(add-hook 'text-mode-hook 'turn-on-auto-fill)
2011-10-09 21:24:39 +03:00
;; load yasnippet
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
2011-10-15 13:04:02 +03:00
;; dispense of trailing whitespace once and for all
(add-hook 'before-save-hook
'delete-trailing-whitespace)
2011-10-10 12:27:17 +03:00
;; projectile is a project management mode
(require 'projectile)
(projectile-global-mode t)
2011-10-08 23:05:06 +03:00
(provide 'prelude-editor)
2011-10-07 23:25:37 +03:00
2011-10-08 23:05:06 +03:00
;;; prelude-editor.el ends here