just save my emacs configuration

(add-to-list 'load-path user-emacs-directory)


(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)


;;; elpa
(package-initialize)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages"))


;;; theme
(load-theme 'wheatgrass)


;;; env
(setq exec-path (cons "/usr/local/bin" exec-path))
(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))


;;; global
(dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
  (when (fboundp mode) (funcall mode -1)))


(setq scroll-margin 3
      scroll-conservatively 10000)


;; see matching parens
(show-paren-mode t)


;; Small fringes
;;(set-fringe-mode '(1 . 1))


;; Line-wrapping
;;(set-default 'fill-column 78)


;; Modeline info
(display-time-mode 1)


;; Display line and column numbers
;;(setq global-linum-mode t)
;;(setq line-number-mode t)
;;(setq column-number-mode t)
(global-linum-mode 1)
(column-number-mode 1)


;; Let's see what we're running on
;;(setq on-console (null window-system))
;;(setq linum-format (if on-console "%4d " "%4d"))


;; Highlight regions and add special behaviors to regions.
(setq transient-mark-mode t)
(pending-delete-mode t)
(delete-selection-mode t)


(auto-image-file-mode)
(global-font-lock-mode t)


;; Don't show the startup screen
(setq inhibit-startup-message t)


;; kill ring max size
(setq kill-ring-max 200)


;; tab
(setq default-tab-width 4)
(setq-default indent-tabs-mode nil)


;; "y or n" instead of "yes or no"
(fset 'yes-or-no-p 'y-or-n-p)


;; Explicitly show the end of a buffer
(set-default 'indicate-empty-lines t)


;; Don't truncate lines
(setq truncate-lines t)
(setq truncate-partial-width-windows nil)


;; Trash can support
(setq delete-by-moving-to-trash t)


;; enable functions that are disabled by default
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)


;; set default working directory
(setq default-directory "~/")


;; user info configuration
(setq user-full-name "Robert Sun")
(setq user-mail-address "[email protected]")
(setq frame-title-format "emacs@%b")


;; Make sure all backup files only live in one place
(setq version-control t)
(setq kept-new-versions 3)
(setq delete-old-versions t)
(setq kept-old-versions 2)
(setq dired-kept-versions 1)
(setq backup-by-copying t)
(setq backup-directory-alist '(("." . "~/.emacs.d/backup")))
(setq auto-save-file-name-transforms '(("\\`/?\\([^/]*/\\)*\\([^/]*\\)\\'" "~/.emacs.d/backup/\\2" t)))


;; stop asking "Active Process Exists;; kill them and exit anyway"
;;(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
;;  "Prevent annoying \"Active processes exist\" query when you quit Emacs."
;;  (flet ((process-list ())) ad-do-it))


;; show extra whitespace
(setq show-trailing-whitespace t)
;; trailing whitespace is unnecessary
(add-hook 'before-save-hook 'whitespace-cleanup)


;; `brew install aspell --lang=en` (instead of ispell)
(setq-default ispell-program-name "aspell")
(setq ispell-list-command "list")
(setq ispell-extra-args '("--sug-mode=ultra"))


;; alias
(defalias 'rs 'replace-string)
(defalias 'qr 'query-replace-regexp)
(defalias 'sl 'sort-lines)
(defalias 'rr 'reverse-region)
(defalias 'lml 'list-matching-lines)
(defalias 'dml 'delete-matching-lines)
(defalias 'dnml 'delete-non-matching-lines)
(defalias 'dtw 'delete-trailing-whitespace)
(defalias 'rb 'revert-buffer)
(defalias 'eb 'eval-buffer)
(defalias 'er 'eval-region)
(defalias 'ed 'eval-defun)
(defalias 'eis 'elisp-index-search)
(defalias 'lf 'load-file)
(defalias 'wd 'wdired-change-to-wdired-mode)
(defalias 'sh 'shell-script-mode)


;; fonts
(when (eq system-type 'darwin)
  (set-face-attribute 'default nil :family "Monaco" :height 150 :weight 'normal))


;; encodings
(require 'un-define "un-define" t)
(set-buffer-file-coding-system 'utf-8 'utf-8-unix)
(set-default buffer-file-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(set-terminal-coding-system 'utf-8-unix)
(set-keyboard-coding-system 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(set-default default-buffer-file-coding-system 'utf-8-unix)


;; For emacsclient
(require 'server)
(unless (server-running-p)
  (server-start))


;;; custom functions


;; rectangle
;; http://www.emacsblog.org/2007/03/17/quick-tip-set-goal-column/#comment-183
(defun kill-save-rectangle (start end &optional fill)
  "Save the rectangle as if killed, but don't kill it.  See `kill-rectangle' for more information."
  (interactive "r\nP")
  (kill-rectangle start end fill)
  (goto-char start)
  (yank-rectangle))


(global-set-key [remap goto-line] 'goto-line-with-feedback)
(global-set-key (kbd "C-x r M-k") 'kill-save-rectangle)


;;; custom key bindings
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)


(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)


;;; org-mode
(setq org-startup-indented t)


;;; ediff
(setq ediff-split-window-function 'split-window-horizontally)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)


(defface diff-added '((t (:inherit diff-changed :background "#70FB67" :foreground "black"))) nil)
(defface diff-file-header '((((class color) (min-colors 88) (background dark)) (:background "#5686E2" :weight bold))) nil)
(defface diff-header '((((class color) (min-colors 88) (background dark)) (:background "#3469D0"))) nil)
(defface diff-hunk-header '((t (:inherit diff-header :background "#3469D0"))) nil)
(defface diff-index '((t (:inherit diff-file-header :background "#5686E2"))) nil)
(defface diff-removed '((t (:inherit diff-changed :background "#FF453C"))) nil)


;;; iswitchb-mode
(iswitchb-mode 1)


(add-to-list 'iswitchb-buffer-ignore "^ ")
(add-to-list 'iswitchb-buffer-ignore "*ECB")
(add-to-list 'iswitchb-buffer-ignore "*Messages")
(add-to-list 'iswitchb-buffer-ignore "*Buffer")
(add-to-list 'iswitchb-buffer-ignore "*Completions")
(add-to-list 'iswitchb-buffer-ignore "*ftp ")
(add-to-list 'iswitchb-buffer-ignore "*bsh")
(add-to-list 'iswitchb-buffer-ignore "^[tT][aA][gG][sS]$")
(add-to-list 'iswitchb-buffer-ignore "*ediff")
(add-to-list 'iswitchb-buffer-ignore "*vc#")
(add-to-list 'iswitchb-buffer-ignore "*cvs-commit*")
(setq iswitchb-case nil)


;;; ido-mode
(ido-mode t)
(ido-everywhere t)


(setq ido-enable-flex-matching t)
(setq ido-enable-last-directory-history nil)
(setq ido-use-filename-at-point nil)
(setq ido-auto-merge-work-directories-length 0)
(setq ido-use-virtual-buffers t)


;;; maxframe plugin
(require 'maxframe)
(add-hook 'window-setup-hook 'maximize-frame t)


;;; smex plugin
(require 'smex)
(smex-initialize)


(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "C-x C-m") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)


;;(load "init/auto-complete")


你可能感兴趣的:(emacs)