;;运行环境ubuntu14.04&&emacs24.3
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#ad7fa8" "#8cc4ff" "#eeeeec"])
'(custom-enabled-themes (quote (tsdh-dark)))
'(ecb-options-version "2.40")
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;启动时最大化
(defun my-maximized ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(my-maximized)
;;marmalade & melpa
(require 'package)
;(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
;;自动安装插件包
(when (not package-archive-contents)
(package-refresh-contents)) ;;自动初始化源安装列表
(when (not (package-installed-p 'yasnippet))
(package-install 'yasnippet)) ;;自动安装YASnippet智能补全引擎
(when (not (package-installed-p 'auto-complete))
(package-install 'auto-complete)) ;;自动安装自动补全插件包
(when (not (package-installed-p 'smex))
(package-install 'smex)) ;;自动安装smex
(when (not (package-installed-p 'highlight-parentheses))
(package-install 'highlight-parentheses)) ;;自动安装highlight-parentheses
(when (not (package-installed-p 'ace-jump-mode))
(package-install 'ace-jump-mode)) ;;自动安装ace-jump-mode
(when (not (package-installed-p 'redo+))
(package-install 'redo+)) ;;自动安装redo+
(when (not (package-installed-p 'idle-highlight-mode))
(package-install 'idle-highlight-mode)) ;;自动安装idle-highlight-mode
(when (not (package-installed-p 'ecb))
(package-install 'ecb)) ;;自动安装ecb
;;;; ecb不显示每日提示
(require 'ecb)
(setq ecb-tip-of-the-day nil)
;;idle-highlight-mode
(defun my-coding-hook ()
(make-local-variable 'column-number-mode)
(column-number-mode t)
(if window-system (hl-line-mode t))
(idle-highlight-mode t))
(add-hook 'prog-mode-hook 'my-coding-hook)
;;redo
(require 'redo+)
;;括号匹配
(require 'highlight-parentheses)
(global-highlight-parentheses-mode 1)
;;yasnippet
(require 'yasnippet)
(yas-global-mode 1)
;;auto-complete
(require 'auto-complete-config)
(ac-config-default)
;;smex
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;;ace-jump-mode
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
(global-set-key (kbd "S-SPC") 'ace-jump-mode);; you can select the key you prefer to
;; (define-prefix-command 'SPC-map)
;; (global-set-key (kbd "SPC") 'SPC-map)
;; (global-set-key (kbd "SPC j") 'ace-jump-mode)
;; (define-key SPC-map (kbd "SPC") 'self-insert-command)
;; 设置光标为竖线
(setq-default cursor-type 'bar)
;鼠标滚轮,默认的滚动太快,这里改为3行
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
;;编辑时覆盖选中区域
(delete-selection-mode 1)
;;ido
(require 'ido)
(ido-mode t)
;;启东时打开shell
;(setq inhibit-startup-message t) ;关闭启动画面
;(shell)
;;cua
(cua-mode t)
(setq cua-keep-region-after-copy t) ;; Standard Windows behaviour
(setq select-active-regions nil)
(setq mouse-drag-copy-region t)
(setq x-select-enable-primary t)
;;alt切换window
(windmove-default-keybindings 'meta)
;;修改快捷键
(define-key global-map (kbd "<S-down-mouse-1>") 'mouse-save-then-kill)
;; (define-key key-translation-map [(control c)] [(meta w)])
;; (define-key key-translation-map [(control v)] [(control y)])
;; (global-set-key (kbd "C-x") 'kill-region)
;; (global-set-key (kbd "C-z") 'advertised-undo)
(global-set-key (kbd "C-S-z") 'redo) ;;反撤销
(global-set-key (kbd "C-/") 'comment-dwim)
(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key (kbd "C-o") 'find-file)
;; (global-set-key (kbd "C-d") 'kill-whole-line)
(define-key key-translation-map [(control d)] [(control shift backspace)])
(global-set-key (kbd "C-k") 'ido-kill-buffer)
(global-set-key (kbd "C-w") 'delete-window)
(global-set-key (kbd "C-S-w") 'delete-other-windows)
(global-set-key (kbd "C-a") 'mark-page)
;(global-set-key (kbd "C-b") 'list-buffers)
(global-set-key (kbd "C-b") 'ido-switch-buffer)
(global-set-key (kbd "C-f") 'isearch-forward)
(global-set-key (kbd "C-S-f") 'isearch-backward)
(define-key isearch-mode-map [down]
'isearch-repeat-forward)
(define-key isearch-mode-map [up]
'isearch-repeat-backward)
(define-key isearch-mode-map (kbd "C-v") 'isearch-yank-kill)
(global-set-key [C-tab] 'other-window)
(define-key minibuffer-local-map [C-tab] 'other-window)
(global-set-key [C-next] 'next-buffer)
(global-set-key [C-prior] 'previous-buffer)
(global-set-key (kbd "C-q") 'point-to-register)
(global-set-key (kbd "C-S-q") 'jump-to-register)
;;编辑时智能缩进,类似于C-j的效果
(electric-indent-mode t)
;;系统本身内置的智能自动补全括号
(electric-pair-mode t)
;;显示行号
(global-linum-mode 1)
;;;;;;;;;;;;;;;;;;;;;搜索选中start;;;;;;;;;;;;;;;;;;;
(defun wcy-define-key-in-transient-mode (global-p key cmd-mark-active cmd-mark-no-active)
(funcall (if global-p 'global-set-key 'local-set-key)
key
`(lambda ()
(interactive)
(if mark-active
(call-interactively ',cmd-mark-active)
(call-interactively ',cmd-mark-no-active)))))
;;;###autoload
(defun wcy-isearch-forward-on-selection (&optional regexp-p no-recursive-edit)
(interactive "P\np")
(let ((text (buffer-substring (point) (mark))))
(goto-char (min (point) (mark)))
(setq mark-active nil)
(isearch-mode t (not (null regexp-p)) nil (not no-recursive-edit))
(isearch-process-search-string text text)))
(wcy-define-key-in-transient-mode t (kbd "C-f")
'wcy-isearch-forward-on-selection
'isearch-forward)
;;;;;;;;;;;;;;;;;;;;;搜索选中end;;;;;;;;;;;;;;;;;;;