白天的小萤火虫

导航

我常用的一些emacs配置

看考http://docs.huihoo.com/homepage/shredderyin/emacs_elisp.html

 

以下是C++编码的一些必要设置,已经够用了

 

;;;; CC-mode配置 http://cc-mode.sourceforge.net/

(require 'cc-mode)

(c-set-offset 'inline-open 0)

(c-set-offset 'friend '-)

(c-set-offset 'substatement-open 0)

;;;;我的C/C++语言编辑策略

(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 [(f7)] 'compile)

(setq compile-command "make");默认的make -k命令,变为make命令

(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)

 

;;;;我的C++语言编辑策略

(defun my-c++-mode-hook()

(setq tab-width 4 indent-tabs-mode nil)

(c-set-style "stroustrup")

(define-key c++-mode-map [f3] 'replace-string)

)

 

 

安装doxygen,在终端apt-get install doxygen doxymacs,可以安装好需要的东西,并且在/usr/share/emacs23/site-lisp中生成需要的el文件,然后在.emacs中配置如下即可:

 

require 'doxymacs) ;; 启动doxymacs

;;注释高亮,针对CC++程序

(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)

(doxymacs-mode);doxymacs-modetrue

(add-hook 'c-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode

(add-hook 'c++-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode

 

 

;使用的命令:

| 命令    | 英文解释                                                   | 中文解释 |
| C-c d ? | will look up documentation for the symbol under the point. | 查找当前鼠标点下的符号的文档 |
| C-c d r | will rescan your Doxygen tags file. | 重新扫描tags文件 |
| C-c d f | will insert a Doxygen comment for the next function. | 为函数插入Doxygen注释 |
| C-c d i | will insert a Doxygen comment for the current file. | 为文件插入Doxygen注释 |
| C-c d ; | will insert a Doxygen comment for the current member. | 为当前成员插入Doxygen注释 |
| C-c d m | will insert a blank multiline Doxygen comment. | 插入多行注释 |
| C-c d s | will insert a blank singleline Doxygen comment. | 插入单行注释 |
| C-c d @ | will insert grouping comments around the current region. | 插入环绕当前区域的注释 |

 

 

posted on 2011-01-22 11:50  白天的小萤火虫  阅读(320)  评论(0编辑  收藏  举报