我的Emacs 配置文件, 在此留作备份吧
;; .emacs --- my Emacs Init File
;; Copyright (C) 2009-2011 zou zhongyu
;; Email: superzuzhy@gmail.com
;; This file is free software licensed under the terms of the
;; GNU General Public License, version 3 or later.
;; basic setting
(setq custom-file "~/.emacs.d/.emacs_custom.el")
(setq bookmark-default-file "~/.emacs.d/.emacs.bmk")
(setq gnus-init-file "~/.emacs.d/.gnus.el")
(setq abbrev-file-name "~/.emacs.d/.abbrev_defs")
(setq user-full-name "zou.zhongyu")
(setq user-mail-address "superzouzhy@gmail.com")
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode nil))
(if (fboundp 'tool-bar-mode) (tool-bar-mode nil))
(if (fboundp 'menu-bar-mode) (menu-bar-mode nil))
(global-set-key [f10] 'view-mode)
(global-set-key [f3] 'menu-bar-mode)
(global-set-key [f4] 'eshell)
(defun fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen) nil 'fullboth)))
(global-set-key [f11] 'fullscreen)
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)
(defalias 'qrr 'query-replace-regexp)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key "\C-xk" 'kill-this-buffer)
(global-set-key "\M-/" 'hippie-expand)
(global-set-key "\M-g" 'goto-line)
(global-set-key (kbd "C-2") 'set-mark-command)
(local-set-key (kbd "<SPC>") 'just-one-space)
(set-default-font "10*10")
;; general settings
(fset 'yes-or-no-p 'y-or-n-p) ; enable y/n answers to yes/no
(setq inhibit-startup-message t ; don't show ...
inhibit-startup-echo-area-message t) ; ... startup message
(setq ring-bell-function 'ignore)
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ; no scroll-bar
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) ; no tool-bar
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) ; no menu-bar
;; setup window frame size
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 120 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 120))
(add-to-list 'default-frame-alist (cons 'width 80)))
;; for the height, subtract a couple hundred pixels
;; from the screen height (for panels, menubars and
;; whatnot), then divide by the height of a char to
;; get the height we want
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 200)
(frame-char-height)))))))
(set-frame-size-according-to-resolution)
(global-font-lock-mode 1) ; always do syntax highlighting
(icomplete-mode t) ; completion in minibuffer
;; (partial-completion-mode t) ; be smart with completion
(setq scroll-margin 1 ; do smooth scrolling, ...
scroll-conservatively 100000 ; ... the defaults ...
scroll-up-aggressively 0.01 ; ... are very ...
scroll-down-aggressively 0.01) ; ... annoying
(setq transient-mark-mode t) ; make the current 'selection' visible
(setq delete-selection-mode t) ; delete the selection with a keypress
(setq require-final-newline t) ; end files with a newline
(auto-compression-mode 1)
(ido-mode 1)
(blink-cursor-mode nil)
(show-paren-mode 1)
(column-number-mode 1)
(mouse-avoidance-mode 'animate)
(setq suggest-key-bindings t)
(setq resize-mini-windows nil)
(setq track-eol t)
(setq Man-notify-method 'pushy)
(setq uniquify-buffer-name-style 'forward)
(setq kill-ring-max 200)
(setq x-select-enable-clipboard t)
(setq bookmark-save-flag t)
(setq default-major-mode 'text-mode)
(minibuffer-electric-default-mode 1)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(setq default-fill-column 80)
(setq-default indent-tabs-mode nil)
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
;; time formart
(display-time-mode t)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-use-mail-icon t)
(setq display-time-interval 10)
;; dird
(setq dired-listing-switches "-avl")
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
;; (add-hook 'dired-mode-hook
;; (lambda ()
;; (setq dired-omit-files "^#\\|^\\..*")
;; (dired-omit-mode t)))
;; view-mode
(setq view-mode-hook
'((lambda ()
(define-key view-mode-map "h" 'backward-char)
(define-key view-mode-map "l" 'forward-char)
(define-key view-mode-map "j" 'next-line)
(define-key view-mode-map "k" 'previous-line))))
;; time-stamps
(setq ;; when there's "Time-stamp: <>" in the first 10 lines of the file
time-stamp-active t
time-stamp-line-limit 10
time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)")
(add-hook 'write-file-hooks 'time-stamp)
;; backup version control
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/.emacs.d/backup")))
(setq backup-by-copying t)
;; hippie-expand
(setq hippie-expand-try-functions-list
'(try-expand-line
try-expand-line-all-buffers
try-expand-list
try-expand-list-all-buffers
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name
try-complete-file-name-partially
try-complete-lisp-symbol
try-complete-lisp-symbol-partially
try-expand-whole-kill))
;; tramp for remote access
(require 'tramp)
(setq tramp-default-user "root")
(setq tramp-default-method "scp")
;; color-theme
;; (require 'color-theme)
;; (color-theme-initialize)
;; (color-theme-emacs-21)
;; (color-theme-vim-colors)
;; (color-theme-xp)
;; (color-theme-classic)
;; (color-theme-xemacs)
;; (color-theme-dark-blue2)
;; (color-theme-charcoal-black)
;; desktop-save session(require 'session)
(add-hook 'after-init-hook
'session-initialize)
(setq desktop-save 'if-exists)
(desktop-save-mode 1)
(setq desktop-globals-to-save
(append '((extended-command-history . 30)
(file-name-history . 100)
(grep-history . 30)
(compile-history . 30)
(minibuffer-history . 50)
(query-replace-history . 60)
(read-expression-history . 60)
(regexp-history . 60)
(regexp-search-ring . 20)
(search-ring . 20)
(shell-command-history . 50)
tags-file-name
register-alist)))
;; c/c++ programming
(defun my-mode-common-hook ()
(setq tab-width 4)
(set (make-local-variable 'tab-stop-list) (number-sequence tab-width 80 tab-width))
(abbrev-mode t)
(setq c-basic-offset tab-width))
(autoload 'cc-mode "cc-mode" "c & c++ mode" t)
(defun my-c-mode-common-hook ()
(c-set-style "k&r")
(setq c-basic-offset tab-width)
(my-mode-common-hook)
(c-toggle-auto-hungry-state t)
(c-toggle-hungry-state t)
(c-toggle-auto-state t)
(setq local-abbrev-table c-mode-abbrev-table))
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c++-mode-hook 'my-c-mode-common-hook)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c++-mode-hook 'my-c-mode-common-hook)
(add-hook 'c-mode-common-hook
'(lambda ()
(require 'xcscope)))
(require 'doxymacs)
(add-hook 'c-mode-common-hook 'doxymacs-mode)
(defun my-doxymacs-font-lock-hook ()
(if (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode))
(doxymacs-font-lock)))
(add-hook 'font-lock-mode-hook 'my-doxymacs-font-lock-hook)
;; (semantic-load-enable-minimum-features)
;; (semantic-load-enable-code-helpers)
;; (semantic-load-enable-guady-code-helpers)
;; (semantic-load-enable-excessive-code-helpers)
;; (semantic-load-enable-semantic-debugging-helpers)
(setq semanticdb-default-save-directory "~/.emacs.d/semanticdb/")
(require 'ecb)
(setq ecb-layout-name "right2")