目的: 配置emacs 24 適合編程開發php
主要參考JerryZhang的配置(Emacs 簡易教程)css
http://www.perfect-is-shit.com/emacs-simple-tutorial.html#tocAnchor-1-16-5html
https://gitcafe.com/JerryZhang/Emacs-Configjava
優勢: 插件少 基本功能都比較全,emacs 配置後啓動比較快速python
安裝過程以下:c++
git clone https://gitcafe.com/JerryZhang/emacs-config.git ~/.emacs.d (後面的地址可更換,下載後複製到~/.emacs.d目錄下)
cd ~/.emacs.d/lisp/helm && make
安裝完成後git
init.el更改內容 github
顯示行號.去掉(global-linum-mode 1)前的分號(;)
;;------------------------------------------------------------------------------ ;; 快速切換至上個buffer ;; Shift+TAB切換至上個buffer ;;------------------------------------------------------------------------------ (global-set-key (kbd "<backtab>") #'(lambda () (interactive) (switch-to-buffer (other-buffer (current-buffer) 1))))
下載 sr-speedbar.el 至.emacs.d/lisp目錄下web
init.el 添加代碼shell
;;------------------------------------------------------------------------------ ;; 使用speedbar <F6>切換speedbar的開啓狀態 ;; s鍵在speedbar中搜索 u鍵回到上一個目錄 ;;------------------------------------------------------------------------------ (require 'sr-speedbar) (global-set-key (kbd "<f6>") (lambda() (interactive) (sr-speedbar-refresh) (sr-speedbar-toggle) (unless (sr-speedbar-exist-p) (kill-buffer "*SPEEDBAR*")))) (require 'speedbar) (define-key speedbar-mode-map (kbd "s") #'(lambda () (interactive) (beginning-of-buffer) (isearch-forward))) (define-key speedbar-mode-map (kbd "u") #'(lambda () (interactive) (speedbar-up-directory)))
開啓ido支持
;;------------------------------------------------------------------------------ ;; 開啓ido 支持 ;;------------------------------------------------------------------------------ (require 'ido) (ido-mode t) ;;ido模式中不保存目錄列表,解決退出Emacs時ido要詢問編碼的問題。 (setq ido-save-directory-list-file nil)
tabbar設置 參考 http://blog.csdn.net/CherylNatsu/article/details/6204737
代碼摺疊 參考 Distopico Vegan / Distopico .emacs.d · Files
下載 hideshow.el 至.emacs.d/lisp目錄下
;;------------------------------------------------------------------------------ ;;代碼摺疊 ;;------------------------------------------------------------------------------ ;(autoload 'hideshowvis-enable "hideshowvis" "Highlight foldable regions") ;(autoload 'hideshowvis-symbols "hideshowvis" "Highlight foldable regions") (require 'hideshowvis) (hideshowvis-symbols) (autoload 'hideshowvis-minor-mode "hideshowvis" "Will indicate regions foldable with hideshow in the fringe." 'interactive) (add-to-list 'hs-special-modes-alist '(ruby-mode "\\(def\\|do\\|{\\)" "\\(end\\|end\\|}\\)" "#" (lambda (arg) (ruby-end-of-block)) nil)) (dolist (hook (list 'emacs-lisp-mode-hook 'lisp-mode-hook 'ruby-mode-hook 'perl-mode-hook 'php-mode-hook 'html-mode-hook ;'web-mode-hook 'sh-mode-hook 'multi-web-mode-hook 'python-mode-hook 'lua-mode-hook 'c-mode-hook 'java-mode-hook 'js-mode-hook 'css-mode-hook 'c++-mode-hook)) (add-hook hook 'hideshowvis-enable)) ;change -/+ to ▼/▶ ;(define-fringe-bitmap 'hideshowvis-hideable-marker [0 0 254 124 56 16 0 0]) ;(define-fringe-bitmap 'hs-marker [0 32 48 56 60 56 48 32]) (custom-set-faces '(hs-fringe-face ((t (:foreground "#afeeee" :box (:line-width 2 :color "grey75" :style released-button))))) '(hs-face ((t (:background "#444" :box t)))) '(hideshowvis-hidable-face ((t (:foreground "#2f4f4f")))) ) (provide 'conf-hideshowvis)
提供的F*快捷鍵
F2 grep
F3 eshell
F4 插入當前時間
F5 compile
F6 speedbar
安裝cscope
sudo apt-get install cscope
xcscope.el 使用:
cscope-indexer -r
: 在根目錄下遞歸生成數據庫C-c s a
: Set initial directory;C-c s A
: Unset initial directory;C-c s I
: create list of files to index;C-c s s
: Find symbol;C-c s d
: Find global definition;C-c s c
: Find functions calling a function;C-c s C
: Find called functions (list functions called from a function);C-c s t
: Find text string;C-c s e
: Find egrep pattern;C-c s f
: Find a file;C-c s i
: Find files #including a file;C-c s b
: Display cscope buffer;C-c s u
: back
其餘可供參考的配置:
C/C++ Development Environment for Emacs
http://tuhdo.github.io/c-ide.html
一年成爲Emacs高手(像神同樣使用編輯器)
http://blog.csdn.net/redguardtoo/article/details/7222501
在使用gdb調試程序時
先M-x gdb 打開gdb調試
而後M-x gdb-many-windows 使用多窗口查看調試過程