emacs 配置
个人的Emacs配置,环境是archlinux,参考了不少网上资料,因为太多,就不一一列举了,在这里感谢那些作者的辛苦经验劳动。
(custom-set-variables ;; 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. '(column-number-mode t) '(ecb-options-version "2.40") '(size-indication-mode t)) (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. ) ;;按F11全屏 (global-set-key [f11] 'my-fullscreen) ;全屏 (defun my-fullscreen () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_FULLSCREEN" 0)) ) ;最大化 (defun my-maximized () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)) ) ;启动时最大化 (my-maximized) ;;cedet-1.1 配置 ;忽略目前cedet的一个issue (setq byte-compile-warnings nil) (load-file "~/.emacs.d/plugins/cedet-1.1/common/cedet.el") (semantic-load-enable-minimum-features) ; 自动分析buffer内容 保存分析后的内容 可以利用ebrowse的结果 (semantic-load-enable-code-helpers) ; 这个feature可以让imenu显示semantic分析出的类,函数等tags。 ;(semantic-load-enable-guady-code-helpers) ; 根据光标位置把当前函数名显示在buffer顶上 semantic会在类/函数等tag上方加一条蓝色的线 (semantic-load-enable-excessive-code-helpers) ; 其中包含上条被注释的功能 (global-ede-mode t) (require 'semantic) (require 'semantic-ia) (global-semantic-stickyfunc-mode 0) (require 'semantic-gcc) (require 'semanticdb) (global-srecode-minor-mode 1) ;;EAssist 配置 文件包含在cedet中 (add-to-list 'load-path "~/.emacs.d/plugins/cedet-1.1/contrib/") (defun my-c-mode-common-hook () (define-key c-mode-base-map (kbd "M-o") 'eassist-switch-h-cpp) (define-key c-mode-base-map (kbd "M-m") 'eassist-list-methods)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) ;;ecb-2.4 配置 (add-to-list 'load-path "~/.emacs.d/plugins/ecb-master/") (require 'ecb) (setq ecb-tip-of-the-day nil) ;启动ECB时不显示每日提示 (ecb-activate) ;;cscope 配置 (require 'xcscope) ;;color-theme-6.6.0 (add-to-list 'load-path "~/.emacs.d/plugins/color-theme-6.6.0/") (require 'color-theme) (color-theme-initialize) ;(color-theme-arjen) (color-theme-matrix) ;;YASnippet 配置 (add-to-list 'load-path "~/.emacs.d/plugins/yasnippet") (require 'yasnippet) (yas-global-mode 1) ;;switch-window 配置 (load-file "~/.emacs.d/plugins/switch-window.el") (require 'switch-window) (global-set-key (kbd "C-x o") 'switch-window) ;;auto-complete 配置 (add-to-list 'load-path "~/.emacs.d/plugins/auto-complete/lib/fuzzy/") (add-to-list 'load-path "~/.emacs.d/plugins/auto-complete/lib/popup/") (add-to-list 'load-path "~/.emacs.d/plugins/auto-complete/lib/ert/lisp/emacs-lisp/") (add-to-list 'load-path "~/.emacs.d/plugins/auto-complete/") (require 'auto-complete-config) (ac-config-default) (add-to-list 'ac-dictionary-directories "~/.emacs.d/plugins/auto-complete/dict") ;;highlight-symbol 配置 (add-to-list 'load-path "~/.emacs.d/plugins/highlight-symbol/") (require 'highlight-symbol) (global-set-key [(control f3)] 'highlight-symbol-at-point) (global-set-key [f3] 'highlight-symbol-next) (global-set-key [(shift f3)] 'highlight-symbol-prev) (global-set-key [(meta f3)] 'highlight-symbol-query-replace) ;;tabbar 配置 (add-to-list 'load-path "~/.emacs.d/plugins/tabbar/") (require 'tabbar) (tabbar-mode 1) ;;session 配置 (add-to-list 'load-path "~/.emacs.d/plugins/session/lisp/") (require 'session) (add-hook 'after-init-hook 'session-initialize) ;;desktop 配置 (require 'desktop) (desktop-save-mode 1) ;(setq-default desktop-load-locked-desktop t);;解决pid错误问题 ;;doxymacs 配置 (add-to-list 'load-path "~/.emacs.d/plugins/doxymacs-1.8.0/lisp/") (require 'doxymacs) (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) (setq doxymacs-doxygen-style "C++") (add-hook 'c++-mode-common-hook 'doxymacs-mode) (add-hook 'c++-mode-common-hook 'doxymacs-mode) ;;multi-term 配置 (add-to-list 'load-path "~/.emacs.d/plugins/multi-term/") (require 'multi-term) (setq multi-term-program "/bin/bash") (setq multi-term-buffer-name "term") ;for solve term-sned-raw: Wrong type arguement: charactor,tab (add-hook 'term-mode-hook (lambda() (yas-minor-mode -1))) (global-set-key "\C-x." 'multi-term) (global-set-key "\C-x," 'multi-term-dedicated-open) ;;sourcepair 配置 (add-to-list 'load-path "~/.emacs.d/plugins/sourcepair/") (require 'sourcepair) (define-key global-map "\C-xz" 'sourcepair-jump-to-headerfile) (setq sourcepair-source-path '( "." "../*" "../../*" )) (setq sourcepair-header-path '( "." "include" "../include" "../*" "../../*")) (setq sourcepair-recurse-ignore '( ".git" "Debug" "Release" )) ;;dired+ 配置 (add-to-list 'load-path "~/.emacs.d/plugins/diredPlus/") (require 'dired+) ;;[ 高亮当前行 ] ;;---------------------------------------------------------------------------- (require 'hl-line) (global-hl-line-mode t) ;;[ 其他基本配置 ] ;;---------------------------------------------------------------------------- (iswitchb-mode 1) ;;Buffer便捷提示 (setq-default cursor-type 'bar) ;;光标显示为一竖线 (set-default-font "-unknown-DejaVu Sans Mono-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1") (icomplete-mode t) (global-font-lock-mode t) (fset 'yes-or-no-p 'y-or-n-p) ;;'y'/'n'代替'yes'/'no' (setq x-select-enable-clipboard t) ;;支持emacs和外部程序的粘贴 (show-paren-mode t) ;;设置让光标指到某个括号与它匹配的括号 (setq show-paren-style 'parentheses) (tool-bar-mode nil) (scroll-bar-mode nil) (setq kill-ring-max 1024) (setq max-lisp-eval-depth 40000) ;;lisp最大执行深度 (setq max-specpdl-size 10000) ;;最大容量 (setq undo-outer-limit 5000000) ;;撤销限制 ;;[ 编码设置] ;;---------------------------------------------------------------------------- (setq default-buffer-file-coding-system 'utf-8-unix) ;缓存文件编码 (setq default-file-name-coding-system 'utf-8-unix) ;文件名编码 (setq default-keyboard-coding-system 'utf-8-unix) ;键盘输入编码 (setq default-process-coding-system '(utf-8-unix . utf-8-unix)) ;进程输出输入编 (setq default-sendmail-coding-system 'utf-8-unix) ;发送邮件编码 (setq default-terminal-coding-system 'utf-8-unix) ;终端编码 ;;[ 不产生备份、不自动保存 ] ;;---------------------------------------------------------------------------- (setq make-backup-files nil) (setq auto-save-default nil) (setq auto-save-mode nil) ;;[ 显示行号 ] ;;---------------------------------------------------------------------------- (setq linum-format "%4d ") (require 'linum) (global-linum-mode 1) ;;[ 设置缩进 ] ;;---------------------------------------------------------------------------- (setq indent-tabs-mode t) (setq default-tab-width 4) (setq tab-width 4) ;;隐藏tool bar (tool-bar-mode 0) ;;配置w3m 基础配置 (setq browse-url-browser-function 'w3m-browse-url) (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t) ; optional keyboard short-cut 全局快捷键 (global-set-key "\C-xm" 'browse-url-at-point) ;开启cookies (setq w3m-use-cookies t) ;;干死semantic-stickyfunc-mode 要卸载ecb后,因为ecb启动后才会加载想应功能,此mode与tabber冲突 (global-semantic-stickyfunc-mode nil)
其中需要注意的就是ecb和cedet的加载顺序,ecb必须要写在cedet后面,否则可能出现ecb无法检测到cedet而不能正常启动的问题,但是ecb写在后面会导致ecb加载后依然会加载semantic-stickyfunc-mode,此mode与tabber冲突,所以在最后禁用之,其实不一定要加在最后,主要是加载顺序问题,能解决就好,就这样~新手才用emacs半年左右,这里贴出来是为了帮助其他和我一样的新鸟们~~老鸟们别在意啦~~