• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

我的EmacsC++编程环境的基本设置

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

;;透明
(setf (frame-parameter nil 'alpha) 99)

;;start Emacs server/client
(server-start)

;;Emacs进入shell模式时,解决乱码问题方法:
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

;;设制切换输入法时,默认切换为chinese-py


;;theme
(add-to-list 'load-path "/usr/share/emacs/site-lisp/color-theme-6.6.0")
(require 'color-theme)
(color-theme-initialize)
(color-theme-xemacs)



;;------------------ Anfang: ido ------------------
(ido-mode t)
(setq ido-enable-flex-matching t) ; fuzzy matching is a must have

;; This tab override shouldn't be necessary given ido's default
;; configuration, but minibuffer-complete otherwise dominates the
;; tab binding because of my custom tab-completion-everywhere
;; configuration.
(add-hook 'ido-setup-hook
          (lambda ()
            (define-key ido-completion-map [tab] 'ido-complete)))
;;------------------ Ende: ido ------------------


;;-----------------开始:基础Emacs配置---------------
;;设置个人信息
(setq user-full-name "Li Bo")
(setq user-mail-address "[email protected]")

;;禁用启动信息
(setq inhibit-startup-message t)

;;工具菜单栏消失
(tool-bar-mode nil)

;;设置全屏
(setq default-frame-alist
      '((height . 32) (width . 84) (menu-bar-lines . 20)))

;;在窗口的标题栏上显示文件名称
(setq frame-title-format "%n%F/%b")

;;显示光标位置
(setq line-number-mode t) ;;行
(setq column-number-mode t) ;;列
(put 'upcase-region 'disabled nil)

;;设置光标为竖线
(setq-default cursor-type 'bar)
;;设置光标为方块
;(setq-default cursor-type 'box)

;;光标靠近鼠标指针时,让鼠标指针自动让开
(mouse-avoidance-mode 'animate)

;;设置让光标指到与当前符号匹配的符号
(show-paren-mode t)
(setq show-paren-style 'parentheses)

;鼠标滚轮,默认的滚动太快,这里改为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)

;;不产生备份文件和临时文件
(setq make-backup-files nil)

;;显示行号
(require 'linum)
(global-linum-mode t)

;;段行,设置80列时换行
(setq default-fill-column 80)

;;设置tab为4个空格的宽度
(setq c-basic-offset 4)
(setq default-tab-width 4)
(setq-default indent-tabs-mode nil)

;;支持Emacs和外部程序的粘贴
(setq x-select-enable-clipboard t)

;;关闭出错提示音
(setq visible-bell t)

;;设置很大的kill ring
(setq kill-ring-max 120)

;;设置缺省模式为org-mode,并非fundamental-mode
(setq default-major-mode 'org-mode)

;;可以直接打开和显示图片
(auto-image-file-mode)

;;-----------------结束:基础Emacs配置---------------




;;-------------开始:C++相关配置-------------
;;使用desktop.el保存桌面环境
(desktop-save-mode 1)

;;hippie-expand自动补全
(global-set-key [(meta ?/)] 'hippie-expand)
(setq hippie-expand-try-functions-list
      '(try-expand-dabbrev
        try-expand-dabbrev-visible
        try-expand-dabbrev-all-buffers
        try-expand-dabbrev-from-kill
        try-complete-file-name-partially
        try-complete-file-name
        try-expand-all-abbrevs
        try-expand-list
        try-expand-line
        try-complete-lisp-symbol-partially
        try-complete-lisp-symbol))


;;打开c或c++文件时,加载xcscope
(load-file "/usr/share/emacs/site-lisp/xcscope.el")
(add-hook 'c-mode-commen-hook
          '(lambda()
             (require 'xcscope)))

;;加载 doxymacs
(require 'doxymacs)
(add-hook 'c-mode-common-hook 'doxymacs-mode)
(add-hook 'c++-mode-commen-hook 'doxymacs-mode)
;;注释高亮,针对C和C++程序
(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)

;命令                          英文解释                                  中文解释
;C-c d ?will look up documentation for the symbol under the point.查找当前鼠标点下的符号的文档
;C-c d rwill rescan your Doxygen tags file.                        重新扫描tags文件
;C-c d fwill insert a Doxygen comment for the next function.    为函数插入Doxygen注释
;C-c d iwill 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 mwill insert a blank multiline Doxygen comment.            插入多行注释
;C-c d swill insert a blank singleline Doxygen comment.         插入单行注释
;C-c d @will insert grouping comments around the current region.插入环绕当前区域的注释

(defconst doxymacs-C++-file-comment-template
 '(
   "/***********************************************************************" > n
   "*" > n
   "* " "FILE NAME   :"
   (if (buffer-file-name)
       (file-name-nondirectory (buffer-file-name))
     "") > n
   "*" > n
   "*" " DESCRIPTION :"> n
   "*" > n
   "*" "    "> n
   "*" > n
   "*" " HISTORY     :"> n
   "*" > n
   "*" "    See Log at end of file"> n
   "*" > n
   "*" "Copyright (c) 2006, VIA Technologies, Inc."> n
   "*" "*******************************************************************/"> n)
 "Default C++-style template for file documentation.")



;;CEDET
(load-file "/usr/share/emacs/site-lisp/cedet-1.0pre7/common/cedet.el")
(require 'cedet)
(semantic-load-enable-code-helpers)
;(semantic-load-enable-excessive-code-helpers)
(semantic-load-enable-semantic-debugging-helpers)

(setq semanticdb-project-roots (list (expand-file-name "/")))
(defconst cedet-user-include-dirs
  (list ".." "../include" "../inc" "../common" "../public"
        "../.." "http://www.cnblogs.com/include" "http://www.cnblogs.com/inc" "http://www.cnblogs.com/common" "http://www.cnblogs.com/public"))
(require 'semantic-c nil 'noerror)
(let ((include-dirs cedet-user-include-dirs))
  (mapc (lambda (dir)
          (semantic-add-system-include dir 'c++-mode)
          (semantic-add-system-include dir 'c-mode))
        include-dirs))

;;补全快捷键
(define-key c-mode-base-map (kbd "M-n") 'semantic-ia-complete-symbol-menu)





;;ECB
(add-to-list 'load-path "/usr/share/emacs/site-lisp/ecb-2.40")
(require 'ecb)
(require 'ecb-autoloads)
;;自动启动ECB,并且不显示每日提示
(setq ecb-auto-activate t)
(setq ecb-tip-of-the-day nil)


;;使用session.el来保存相关变量,且不多org-mode进行保存
(require 'session)
(add-hook 'after-init-hook
          'session-initialize)
(add-to-list 'session-globals-exclude
             'org-mark-ring)

;;-------------结束:C++相关配置-------------



;;---------------开始:快捷键设置---------------

;;F1 进入终端
(global-set-key [(f1)] 'shell)

;;F4 代码跳转
(global-set-key [(f4)] 'semantic-ia-fast-jump)

;;Shift+F4 代码反跳转
(global-set-key [S-f4]
                (lambda ()
                  (interactive)
                  (if (ring-empty-p (oref semantic-mru-bookmark-ring ring))
                      (error "Semantic Bookmark ring is currently empty"))
                  (let* ((ring (oref semantic-mru-bookmark-ring ring))
                         (alist (semantic-mrub-ring-to-assoc-list ring))
                         (first (cdr (car alist))))
                    (if (semantic-equivalent-tag-p (oref first tag)
                                                   (semantic-current-tag))
                        (setq first (cdr (car (cdr alist)))))
                    (semantic-mrub-switch-tags first))))


;;F5 调试程序
(global-set-key [(f5)] 'gdb)

;;;F11 打开ECB
;(global-set-key [(f11)] 'ecb-activate)
;
;;;F12 关闭ECB
;(global-set-key [(f12)] 'ecb-deactivate)

;;---------------结束:快捷键设置--------------


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#DevExpress下GridControl控件的增删查改发布时间:2022-07-14
下一篇:
C#字符串、数组和List的截取和转换发布时间:2022-07-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap