本文主要討論以下幾方面的設定:
1.字型
2.cedet
3.ecb
4.cscope
4.gdb-many-window
環境:
openSUSE 10.2
預設裝的是Emacs 21,我從網上下了Emacs 22.1的tar包,編譯安裝。
1.字型
預設的字型非常之小,以下是一篇非常詳細的Emacs下設定字型的教程,可惜太長了,長到我實在是懶得看。我抄了個現成的:
(set-default-font "-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso10646-1")
2.cedet
下載cedet: http://cedet.sourceforge.net/
按照INSTALL安裝就行,然後設定.emacs。INSTALL裡有一段關於設定的,粘貼過來即可,另外最好設一個speedbar的快速鍵:
(global-set-key [(f4)] 'speedbar-get-focus)
這樣按一個F4,speedbar就出來了。
3.ecb
http://ecb.sourceforge.net/
.emacs裡:
(add-to-list 'load-path "~/software/ecb-2.32")
;;(require 'ecb)
(require 'ecb-autoloads)
開啟emacs,然後M-x ecb-activate即可開啟ecb。
4.cscope
這個應該和ecb的有些功能是重複的
先裝好cscope,再把/cscope-15.6/contrib/xcscope目錄下的xcscope.el載入到emacs中去:
(add-to-list 'load-path "~/software/cscope-15.6/contrib/xcscope")
(require 'xcscope)
這裡有篇講怎麼在emacs下安裝和使用cscope的:
http://ann77.stu.cdut.edu.cn/EmacsCscope.html
5.gdb-many-window
這個功能外掛程式可以使emacs的調試介面像VC一樣,有watch, stacktrace等視窗,真正實現圖形化gdb.
下載:
http://www.inet.net.nz/~nickrob/multi-gud.el
http://www.inet.net.nz/~nickrob/multi-gdb-ui.el
設定.emacs:
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")
還不行的看詳細官方教程:http://www.inet.net.nz/
一遍使用gdb-ui的教程:
http://blog.chinaunix.net/u/5958/showart_137996.html
另外:
Emacs安裝一個擴充包的方法
http://ann77.stu.cdut.edu.cn/EmacsInstallPackege.html
一個比較全的.emacs設定檔:
http://www.cppblog.com/guangping/archive/2006/08/25/11683.html
附件:
我的.emacs(還沒整理過,很亂,貌似還有快速鍵重複的-_-|||)
(if (string-match "XEmacs//|Lucid" emacs-version)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; XEmacs
;;; ------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(progn
(if (file-readable-p "~/.xemacs/init.el")
(load "~/.xemacs/init.el" nil t))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; GNU-Emacs
;;; ---------
;;; load ~/.gnu-emacs or, if not exists /etc/skel/.gnu-emacs
;;; For a description and the settings see /etc/skel/.gnu-emacs
;;; ... for your private ~/.gnu-emacs your are on your one.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(if (file-readable-p "~/.gnu-emacs")
(load "~/.gnu-emacs" nil t)
(if (file-readable-p "/etc/skel/.gnu-emacs")
(load "/etc/skel/.gnu-emacs" nil t)))
;; Custum Settings
;; ===============
;; To avoid any trouble with the customization system of GNU emacs
;; we set the default file ~/.gnu-emacs-custom
(setq custom-file "~/.gnu-emacs-custom")
(load "~/.gnu-emacs-custom" t t)
;;;
)
;;;
(column-number-mode t)
(transient-mark-mode t)
(setq line-number-mode t)
(setq default-tab-width 8)
(customize-set-variable 'scroll-bar-mode' right)
;;(setq default-directory "home/jzj/backup/emacs/")
(setq inhibit-startup-message t)
(setq line-number-mode t)
(setq global-font-lock-mode t)
(setq make-backup-files nil)
(setq auto-save-mode nil)
(setq x-select-enable-clipboard t)
(setq mouse-yank-at-point t)
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
;;(global-set-key [f4] 'other-window)
(global-set-key [f5] 'compile)
(setq-default compile-command "make")
;;(global-set-key [f7] 'du-onekey-compile)
(global-set-key [f6] 'gdb)
(global-set-key [C-f7] 'previous-error)
(global-set-key [f7] 'next-error)
;;(set-default-font "9x15")
(set-default-font "-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso10646-1")
;; Load CEDET
(load-file "~/software/cedet-1.0pre4/common/cedet.el")
;; Enabling various SEMANTIC minor modes. See semantic/INSTALL for more ideas.
;; Select one of the following:
;; * This enables the database and idle reparse engines
(semantic-load-enable-minimum-features)
;; * This enables some tools useful for coding, such as summary mode
;; imenu support, and the semantic navigator
(semantic-load-enable-code-helpers)
;; * This enables even more coding tools such as the nascent intellisense mode
;; decoration mode, and stickyfunc mode (plus regular code helpers)
(semantic-load-enable-guady-code-helpers)
;; * This turns on which-func support (Plus all other code helpers)
(semantic-load-enable-excessive-code-helpers)
;; This turns on modes that aid in grammar writing and semantic tool
;; development. It does not enable any other features such as code
;; helpers above.
(semantic-load-enable-semantic-debugging-helpers)
(global-set-key [(f4)] 'speedbar-get-focus)
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
(defun my-c-mode-common-hook()
(setq tab-width 4 indent-tabs-mode nil)
;;; hungry-delete and auto-newline
(c-toggle-auto-hungry-state 1)
(define-key c-mode-base-map [(control /`)] 'hs-toggle-hiding)
;; (define-key c-mode-base-map [(return)] 'newline-and-indent)
;; (define-key c-mode-base-map [(f6)] 'compile)
(define-key c-mode-base-map [(meta /`)] 'c-indent-command)
;; (define-key c-mode-base-map [(tab)] 'hippie-expand)
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "cpp")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq hs-minor-mode t)
(setq abbrev-mode t)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(defun my-c++-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
(c-set-style "stroustrup")
;; (define-key c++-mode-map [f3] 'replace-regexp)
)
(setq gdb-many-windows t)
(add-to-list 'load-path "~/backup/emacs")
(require 'gud)
(add-to-list 'load-path "~/software/ecb-2.32")
;;(require 'ecb)
(require 'ecb-autoloads)
;;for gdb-many-window mode
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")
;; cscope in emacs
(add-to-list 'load-path "~/software/cscope-15.6/contrib/xcscope")
(require 'xcscope)
;; hotkey for cscope
(define-key global-map [(control f3)] 'cscope-set-initial-directory)
(define-key global-map [(control f4)] 'cscope-unset-initial-directory)
(define-key global-map [(control f5)] 'cscope-find-this-symbol)
(define-key global-map [(control f6)] 'cscope-find-global-definition)
(define-key global-map [(control f7)]
'cscope-find-global-definition-no-prompting)
(define-key global-map [(control f8)] 'cscope-pop-mark)
(define-key global-map [(control f9)] 'cscope-next-symbol)
(define-key global-map [(control f10)] 'cscope-next-file)
(define-key global-map [(control f11)] 'cscope-prev-symbol)
(define-key global-map [(control f12)] 'cscope-prev-file)
(define-key global-map [(meta f9)] 'cscope-display-buffer)
(define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)