天天看点

emacs在windowxp下的一些配置

需要搞一个什么as3的相关,

懒的去找新的Text Editor了,索性用emacs来弄拉到了。

因为,在win下,所以原先的那个配置,不能用了。

重新弄了一份。

如下:

;----------在window下使用emac弄中文--------------

(set-language-environment 'Chinese-GB)

(set-keyboard-coding-system 'euc-cn)

(set-clipboard-coding-system 'euc-cn)

(set-terminal-coding-system 'euc-cn)

(set-buffer-file-coding-system 'euc-cn)

(set-selection-coding-system 'euc-cn)

(modify-coding-system-alist 'process "*" 'euc-cn)

(setq default-process-coding-system '(euc-cn . euc-cn) )

;----------在window下使用emac弄中文--------------

;---------------自己定义的光标移动---------------

;特别说明一下:单词的搞法有比较浓重的英文色彩,在实际的应用中,比较适合老外,

;天朝就不用了

(global-set-key (kbd "C-j") 'backward-char);//往上一个字符移动,就是左边移动

(global-set-key (kbd "C-l") 'forward-char);//往下一个字符移动,就是右边移动

(global-set-key (kbd "C-u") 'beginning-of-line);//到行头部,就是左边

(global-set-key (kbd "C-o") 'end-of-line);//到行尾部,就是右边

(global-set-key (kbd "M-j") 'backward-word);//往上一个单词移动

(global-set-key (kbd "M-l") 'forward-word);//往下一个单词移动

(global-set-key (kbd "C-e") 'backward-delete-char);删除光标前面的一个字符

(global-set-key (kbd "C-d") 'delete-char);//删除光标后面的一个字符

;---------------自己定义的光标移动--------------

;---------------------删除相关------------------

;特意说明一下,在emacs中,是没有往前删除一个词,和往后删除一个词的。

;默认提供的其实都是,“剪切”功能的

;所以弄了一个

(defun delete-word (arg)

  "Delete characters forward until encountering the end of a word. With argument, do this that many times."

  (interactive "p")

  (delete-region (point) (progn (forward-word arg) (point))

  )

)

(defun backward-delete-word (arg)

  "Delete characters backward until encountering the end of a word. With argument, do this that many times."

  (interactive "p")

  (delete-word (- arg))

)

(global-set-key (kbd "M-e") 'backward-delete-word);删除前一个词

(global-set-key (kbd "M-d") 'delete-word);删除后一个词

;---------------------删除相关------------------

;-------------标记开始和关闭---主要用于拷贝,粘贴等----------

(global-set-key (kbd "M-b") 'set-mark-command)

;-------------标记开始和关闭---主要用于拷贝,粘贴等----------

;-------------------buffer控制-----------------

(global-set-key (kbd "C-x C-j") 'next-buffer)

(global-set-key (kbd "C-x C-l") 'previous-buffer)

;-------------------buffer控制-----------------

;-----------------自己定义的拷贝粘贴-----------------

(global-set-key (kbd "C-c C-c") 'kill-ring-save);copy

(global-set-key (kbd "C-v") 'yank);paste

(global-set-key (kbd "C-c C-x") 'kill-region);cut

(global-set-key (kbd "C-z") 'undo);udo

(global-set-key (kbd "C-f") 'isearch-backward);查找,用了双f,统一快捷

;-----------------自己定义的拷贝粘贴-----------------

;--------------------保存所有的buffer----------------

(global-set-key (kbd "C-x C-z") 'save-some-buffers);save all buffer

;--------------------保存所有的buffer----------------

;-------------------------关闭当前的buffer-------------------------

(global-set-key (kbd "M-c") 'kill-this-buffer)

;M-c关闭当前buffer,有时候,用Alt+Enter不是很合适,所以增加一个

;-------------------------关闭当前的buffer-------------------------

;--------------窗口跳转--------------

(global-set-key (kbd "C-x C-o") 'other-window);窗口间跳转

;--------------窗口跳转--------------

;----------------------------------------有错误时,后面的不会被执行 ----------------------------------------

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

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

;----------------------------------------有错误时,后面的不会被执行 ----------------------------------------

;-------------------------------------一些其他的功能 -----------------------------------------

(auto-image-file-mode t);打开图片显示功能

(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no,可能你觉得不需要,呵呵。

(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线。很好玩阿,这个功能

(setq frame-title-format "hjz@%b");在标题栏提示你目前在什么位置。你要把hjz改成自己的用户名

(setq default-fill-column 256);默认显示 256列就换行

;-------------------------------------一些其他的功能 -----------------------------------------

;------------------------外观设置------------------------------

(tool-bar-mode nil);;去掉工具栏

;(menu-bar-mode nil);;去掉菜单栏

;(scroll-bar-mode nil);;不要滚动栏,现在都用滚轴鼠标了,可以不用滚动栏了

;------------------------外观设置------------------------------

;----------------设置时间显示为24小时制,否则为12小时制----------------

(setq display-time-24hr-format 't)

;; 显示时间

(setq display-time-day-and-date t)

(display-time)

;----------------设置时间显示为24小时制,否则为12小时制----------------

;---------------------------------------不折行显示 ---------------------------------------

;; dired-mode 下不折行显示

;(defun my-dired-long-lines ()

  (setq truncate-lines t);)

;(add-hook 'dired-after-readin-hook 'my-dired-long-lines)

;---------------------------------------不折行显示 ---------------------------------------

;----------------------------------鼠标滚轮 --------------------------------------------

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

;-----------------------------------不要生成临时文件 -------------------------------------------

;---------------------------------用y/n代替yes /no---------------------------------------------

(fset 'yes-or-no-p 'y-or-n-p)

;---------------------------------用y/n代替yes /no---------------------------------------------

;-------------------------语法加亮--------------------------

(global-font-lock-mode 't)

;-------------------------语法加亮--------------------------

;-------------------------关闭错误提示的Beep音--------------

(setq visible-bell t)

;-------------------------关闭错误提示的Beep音--------------

;-------------------------关闭启动时的`开机画面'------------

(setq inhibit-startup-message t)

;-------------------------关闭启动时的`开机画面'------------

;-------------------------显示列号--------------------------

(setq column-number-mode t)

;-------------------------显示列号--------------------------

;-------------------------括号匹配--------------------------

;括号匹配时显示另一端的括号,而不是跳过去

;(show-paren-mode t)

;(setq show-paren-style 'parentheses)

;-------------------------括号匹配--------------------------

;-------------------------Shell 使用 ansi color-------------

(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

;-------------------------Shell 使用 ansi color-------------

;-------------------------使用Win下的选择习惯---------------

;用shift+方向键进行选择

(pc-selection-mode)

;-------------------------使用Win下的选择习惯---------------

;-------------------------标题拦显示buffer的名字------------

(setq frame-title-format "emacs@%b")

(setq user-full-name "Huang Jing Ze")

;-------------------------标题拦显示buffer的名字------------

;------------------------------------tab设置 -----------------------------------

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

;------------------------------------tab设置 -----------------------------------

;---------------------------文字间距,行距等---------------------------

;;设定行距

(setq default-line-spacing 0)

;;页宽

(setq default-fill-column 256)

;;缺省模式 text-mode

(setq default-major-mode 'text-mode)

;;锁定行高

(setq resize-mini-windows nil)

;---------------------------文字间距,行距等---------------------------

(setq kill-ring-max 512)

;用一个很大的 kill ring. 这样防止我不小心删掉重要的东西。防止额外的错误

;========================================下面是相关的额外加载========================================

;========================================下面是相关的额外加载========================================

;-------------------------------设定加载路径---------------------------------

(setq load-path (cons "D:/emacs/emacs-22.3/other_el/" load-path))

;-----------------------------------------平滑滚动---------------------------------------

;VC下有两种滚动模式,一种叫做up up/down,使移动光标,当光标到达页面顶端的时候,滚动页面;

;一种是Scroll line up/down,光标所在的绝对行和列不变,滚动页面。

;Emacs下有第一种滚动方式,但是第二种滚动方式一直没有找到。于是自己写了两个函数,来实现这个功能,以方便边浏览边编辑代码的操作。

(defun hold-line-scroll-up()

  "Scroll the page with the cursor in the same line"

  (interactive)

  (let ((next-screen-context-lines

        (count-lines

         (window-start) (window-end)

         )

        ))

    (scroll-up)

    ))

(defun hold-line-scroll-down()

  "Scroll the page with the cursor in the same line"

  (interactive)

  (let ((next-screen-context-lines

        (count-lines

         (window-start) (window-end)

         )

        ))

    (scroll-down)

    ))

; define the key binding

;(global-set-key (kbd "M-n") 'hold-line-scroll-up)

;(global-set-key (kbd "M-p") 'hold-line-scroll-down)

(global-set-key (kbd "M-n") 'scroll-up);//page down

(global-set-key (kbd "M-p") 'scroll-down);//page up

;-----------------------------------------平滑滚动---------------------------------------

;-----------加载平滑移动-----------

(require 'smooth-scrolling)

;----------------------------------------颜色主题 ----------------------------------------

(setq load-path (cons "D:\\emacs\\emacs-22.3\\other_el\\color-theme-6.6.0" load-path))

(require 'color-theme)

(color-theme-initialize)

(color-theme-subtle-hacker)

;----------------------------------------颜色主题 ----------------------------------------

;---------------高亮-------------

(require 'highlight)

(require 'col-highlight)

(require 'actionscript-mode)

;---------------高亮-------------

;------------------------------------自定义的F快捷键 ------------------------------------------

;自定义按键

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

;F2被书签占用了,F2设定取消书签,C-F2在书签中跳转

(global-set-key [f3] 'speedbar-get-focus);F3打开speedbar

;F4是 .h文件 和 .cpp文件的切换

;(global-set-key [f6] 'other-window);F6窗口间跳转

;(global-set-key [f7] 'compile);F7编译文件

;F10是emacs菜单

;F12是 智能跳转

;Shift F12 是跳转回来

;------------------------------------自定义的F快捷键 ------------------------------------------

;--------------------custom face--------------------

(load-file "D:\\emacs\\emacs-22.3\\other_el\\customface.el")

;--------------------custom face--------------------

;-------------------------------------加在emacs自己带的行号工具 -----------------------------------------

;(add-to-list 'load-path "/home/hjz/software/emacs/linum.el")

;(require 'linum)

;(global-linum-mode 1)

;-------------------------------------加在emacs自己带的行号工具 -----------------------------------------

;---------------------------这个svn被我修改了,由svn-status修改为 ---svn---------------------------

;(load-file "/home/hjz/software/emacs/psvn.el")

;(require 'psvn)

;(define-prefix-command 'svn-map)

;(global-set-key (kbd "M-x M-c") 'svn-map)

;(define-key svn-map (kbd "c") 'svn-status-commit)

;(global-set-key (kbd "M-x 'svn commit'") 'svn-status-commit)

;顺便说几句,这个集成在emacs中的svn,不是很好用,估计要么用外部的。

;要么,找个时间,自己弄一下。

;---------------------------这个svn被我修改了,由svn-status修改为 ---svn---------------------------

;-----------------------------------tabbar-----------------------------------

(require 'tabbar)

(tabbar-mode t)

(global-set-key [(control tab)]       'tabbar-backward-tab)

(global-set-key [S-tab]       'tabbar-forward-tab)

;(global-set-key (kbd "<left>") 'tabbar-backward-tab)

;(global-set-key (kbd "<right>") 'tabbar-forward-tab)

;(global-set-key (kbd "<up>") 'tabbar-forward-group)

;(global-set-key (kbd "<down>") 'tabbar-backward-group)

;就弄一个分组

(setq tabbar-buffer-groups-function

          (lambda ()

            (list "All"))) ;; code by Peter Barabas

;-----------------------------------tabbar-----------------------------------

;-----------------------------大名鼎鼎的cedet-----------------------------

(load-file "D:\\emacs\\emacs-22.3\\other_el\\cedet-1.1\\common\\cedet.el")

;版本千万不要用错了,否则会很恶心

(require 'cedet)

(require 'semantic)

(require 'semantic-ia)

(require 'semanticdb)

(global-ede-mode t)

;(require 'semantic-gcc)

(global-srecode-minor-mode 1)

(semantic-load-enable-minimum-features)

(semantic-load-enable-code-helpers)

(semantic-load-enable-guady-code-helpers)

(semantic-load-enable-excessive-code-helpers)

(semantic-load-enable-semantic-debugging-helpers)

(global-semantic-stickyfunc-mode -1);关掉,免得替代tabbar

(which-function-mode nil)

;-----------------------

(setq semanticdb-project-roots (list (expand-file-name "/")))

(defconst cedet-user-include-dirs

  (list "/" "./"))

(defconst cedet-win32-include-dirs

  (list "../"))

(require 'semantic-c nil 'noerror)

(let ((include-dirs cedet-user-include-dirs))

  (when (eq system-type 'windows-nt)

    (setq include-dirs (append include-dirs cedet-win32-include-dirs)))

  (mapc (lambda (dir)

          (semantic-add-system-include dir 'c++-mode)

          (semantic-add-system-include dir 'c-mode))

        include-dirs))

;-----------------------

(global-set-key [f12] 'semantic-ia-fast-jump);F12跳转

;Shift F12跳转回来

(global-set-key [S-f12]

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

(global-set-key (kbd "C-/") 'semantic-ia-complete-symbol-menu)

;(global-set-key (kbd "C-.") 'semantic-ia-complete-symbol-menu)

;(global-set-key (kbd "C-,") 'semantic-ia-complete-symbol-menu)

;(global-set-key (kbd "M-.") 'semantic-ia-complete-symbol-menu)

;(global-set-key (kbd ":") 'semantic-ia-complete-symbol-menu)

;(global-set-key (kbd ">") 'semantic-ia-complete-symbol-menu)

;-----------------------------大名鼎鼎的cedet-----------------------------

;-----------------F4.h.cpp切换------------

(load-file "D:\\emacs\\emacs-22.3\\other_el\\cedet-1.1\\contrib\\eassist.el")

(require 'eassist nil 'noerror)

(global-set-key [f4] 'eassist-switch-h-cpp);修改为F4切换.h和.cpp

;设定.h .cpp 的格式

(setq eassist-header-switches

      '(("h" . ("cpp" "cxx" "c++" "CC" "cc" "C" "c" "mm" "m"))

        ("hh" . ("cc" "CC" "cpp" "cxx" "c++" "C"))

        ("hpp" . ("cpp" "cxx" "c++" "cc" "CC" "C"))

        ("hxx" . ("cxx" "cpp" "c++" "cc" "CC" "C"))

        ("h++" . ("c++" "cpp" "cxx" "cc" "CC" "C"))

        ("H" . ("C" "CC" "cc" "cpp" "cxx" "c++" "mm" "m"))

        ("HH" . ("CC" "cc" "C" "cpp" "cxx" "c++"))

        ("cpp" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))

        ("cxx" . ("hxx" "hpp" "h++" "HH" "hh" "H" "h"))

        ("c++" . ("h++" "hpp" "hxx" "HH" "hh" "H" "h"))

        ("CC" . ("HH" "hh" "hpp" "hxx" "h++" "H" "h"))

        ("cc" . ("hh" "HH" "hpp" "hxx" "h++" "H" "h"))

        ("C" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))

        ("c" . ("h"))

        ("m" . ("h"))

        ("mm" . ("h"))))

;-----------------F4.h.cpp切换------------

;----------------代码折叠----------------

(load-file "D:\\emacs\\emacs-22.3\\other_el\\cedet-1.1\\contrib\\semantic-tag-folding.el")

(require 'semantic-tag-folding nil 'noerror)

(global-semantic-tag-folding-mode 1)

(global-set-key (kbd "C-c -") 'semantic-tag-folding-fold-block)

(global-set-key (kbd "C-c +") 'semantic-tag-folding-show-block)

;----------------代码折叠----------------

;-----------------项目工程文件------------------

(global-ede-mode t)

;-----------------项目工程文件------------------

;--------------------------ecb-----------------------

;这个配置只能用ecb-2.40,用错了版本会很恶心的。

(add-to-list 'load-path "D:\\emacs\\emacs-22.3\\other_el\\ecb-snap")

(require 'ecb)

;(ecb-activate)

;-------------------------------------cscope-------------------------------------

;(load-file "/usr/share/emacs23/site-lisp/cscope/xcscope.elc")

;(require 'xcscope)

;-------------------------------------cscope-------------------------------------

;---------------为不同的后缀名类型的文件指定打开方式---------------

(setq auto-mode-alist

      (append '(("\\.[CH]$"  . c++-mode)

  ("\\.as$" . c++-mode) ;as3

  ("\\.el$" . emacs-lisp-mode);.el

;                    ("\\.cc$" . c++-mode)

;                    ("\\.[ch]xx$" . c++-mode)

;                    ("\\.sc$" . c++-mode)

;                    ("\\.[ch]$"  . c-mode)        ; to edit C code

;                    ("\\.tex$" . TeX-mode)

;                    ("\\.txi$" . Texinfo-mode)

;                    ("\\.a$" . c-mode)

;                    ("\\.[Ss]$" . asm-mode)

;                    ("[Mm]akefile.*$" . makefile-mode)   ; to edit Makefiles

;                    ("\\.Z$" . uncompress-while-visiting)

;                    ("\\.gz$" . uncompress-while-visiting)

;                    ("\\.html$" . html-helper-mode)

  ) auto-mode-alist)

)

;---------------为不同的后缀名类型的文件指定打开方式---------------

;--------------------------------传说中的施特劳斯特卢普的C++代码风格 ---------------------------------------

(add-to-list 'auto-mode-alist '("//.h//'" . c++-mode))

(require 'cl)

(defun file-in-directory-list-p (file dirlist)

  "Returns true if the file specified is contained within one of the directories in the list. The directories must also exist."

  (let ((dirs (mapcar 'expand-file-name dirlist))

        (filedir (expand-file-name (file-name-directory file))))

    (and

     (file-directory-p filedir)

     (member-if (lambda (x) ; Check directory prefix matches

                  (string-match (substring x 0 (min(length filedir) (length x))) filedir))

                dirs)))

)

(defun buffer-standard-include-p ()

  "Returns true if the current buffer is contained within one of the directories in the INCLUDE environment variable."

  (and (getenv "INCLUDE")

       (file-in-directory-list-p buffer-file-name (split-string (getenv "INCLUDE") path-separator)))

)

(add-to-list 'magic-fallback-mode-alist '(buffer-standard-include-p . c++-mode))

(c-add-style "my-style"

             '("stroustrup"

               (indent-tabs-mode . nil)        ; use spaces rather than tabs

               (c-basic-offset . 8)            ; indent by four spaces

               (c-offsets-alist .

    (

     (inline-open . 0)  ; custom indentation rules

     (brace-list-open . 0)

     (statement-case-open . +)

     )

                                )

               )

)

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

    (c-set-style "my-style")        ; use my-style defined above

          (auto-fill-mode)       

         ;(c-toggle-auto-hungry-state 1)

        (c-toggle-electric-state 1)

        ;(c-toggle-auto-newline 1);这个就是遇到了{};之后,自己开新行的

        (c-toggle-hungry-state 1)

        ;(c-toggle-syntactic-indentation 1)

    ;(define-key c++-mode-map (kbd ":") 'semantic-ia-complete-symbol-menu)

    ;(define-key c++-mode-map (kbd ".") 'semantic-ia-complete-symbol-menu)

    (define-key c++-mode-map (kbd "C-c C-c") 'kill-ring-save);copy

    (define-key c++-mode-map (kbd "C-v") 'yank);paste

    (define-key c++-mode-map (kbd "C-x x") 'kill-region);cut

    ;(define-key c++-mode-map (kbd "C-c C-c") 'kill-ring-save);copy

    ;(define-key c++-mode-map (kbd "C-v") 'yank);paste

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

)

(add-hook 'c++-mode-hook 'my-c++-mode-hook)

(add-hook 'objc-mode-hook 'my-c++-mode-hook)

;--------------------------------传说中的施特劳斯特卢普的C++代码风格 ---------------------------------------

;----------------------------------C风格的对齐-----------------------------

(defconst my-c-style

  '((c-tab-always-indent        . t)

    (c-comment-only-line-offset . 4)

    (c-hanging-braces-alist     . ((substatement-open after)

       (brace-list-open)))

    (c-hanging-colons-alist     . ((member-init-intro before)

       (inher-intro)

       (case-label after)

       (label after)

       (access-label after)))

    (c-cleanup-list             . (scope-operator

       empty-defun-braces

       defun-close-semi))

    (c-offsets-alist            . ((arglist-close . c-lineup-arglist)

       (substatement-open . 0)

       (case-label        . 4)

       (block-open        . 0);

       (defun-block-intro . 0)

       (statement-block-intro . 8)

       (substatement . 8)

       (knr-argdecl-intro . -)))

    (c-echo-syntactic-information-p . t)

    )

  "My C Programming Style"

)

;; Customizations for all of c-mode, c++-mode, and objc-mode

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

  ;; add my personal style and set it for the current buffer

  (c-add-style "PERSONAL" my-c-style t)

  ;; offset customizations not in my-c-style

  (c-set-offset 'defun-block-intro' +)

  ;; other customizations

  (setq tab-width 8

 ;; this will make sure spaces are used instead of tabs

 indent-tabs-mode nil)

  ;; we like auto-newline and hungry-delete

  (c-toggle-hungry-state 1)

  ;; keybindings for all supported languages.  We can put these in

  ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,

  ;; java-mode-map, and idl-mode-map inherit from it.

  ;(define-key c-mode-base-map "/C-m" 'newline-and-indent)

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

)

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;----------------------------------C风格的对齐-----------------------------

;--------------------

;(load-file "/home/hjz/software/emacs/multi-gdb-ui.el")

(require 'gdb-ui)

(defun gdb-or-gud-go ()

  "If gdb isn't running; run gdb, else call gud-go."

  (interactive)

  (if (and gud-comint-buffer

           (buffer-name gud-comint-buffer)

           (get-buffer-process gud-comint-buffer)

           (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)))

      (gud-call (if gdb-active-process "continue" "run") "")

    (gdb (gud-query-cmdline 'gdb))))

(defun gud-break-remove ()

  "Set/clear breakpoin."

  (interactive)

  (save-excursion

    (if (eq (car (fringe-bitmaps-at-pos (point))) 'breakpoint)

        (gud-remove nil)

      (gud-break nil))))

(defun gud-kill ()

  "Kill gdb process."

  (interactive)

  (with-current-buffer gud-comint-buffer (comint-skip-input))

  (kill-process (get-buffer-process gud-comint-buffer)))

(setq gdb-many-windows t)

(global-set-key [f5] 'gdb-or-gud-go);F5启动gdb或gdb运行

(global-set-key [S-f5] '(lambda () (interactive) (gud-call "quit" nil)))

;(global-set-key [S-f5] 'gud-kill);shift+F5关闭gdb,实际意义不大,屏蔽了

;(global-set-key [f7] '(lambda () (interactive) (compile compile-command)));编译命令,已经有了

(global-set-key [f8] 'gud-print);打印当前光标所在的变量,比较省心的好东东

(global-set-key [C-f8] 'gud-pstar);打印指针所指向的值,也是好东东

(global-set-key [f9] 'gud-break-remove);设定或取消断点

;; (global-set-key [f9] 'gud-break)

;; (global-set-key [C-f9] 'gud-remove)

(global-set-key [f10] 'gud-next)

(global-set-key [C-f10] 'gud-until)

(global-set-key [S-f10] 'gud-jump)

(global-set-key [f11] 'gud-step)

(global-set-key [C-f11] 'gud-finish)

;在c/c++-mode中按f7,就会调用make编译程序。

;在c/c++-mode中按f5,就会进入gdb调试。

;打开gdb后在源代码buffer中按f9设置断点,相当于gdb中的break。

;按Ctrl+f9就可以删除断点,相当于gdb中的delete。

;在gdb buffer中,按Ctrl+f5就开始执行程序,相当于gdb中的run。

;断点之后,可以按f10单步执行,相当于gdb中的next。

;把光标移动到某处按Ctrl+f10,会一直执行光标位置,相当于gdb的until。

;把光标移动到某处按Shift+f10,会jump到光标位置,下一次会从光标处执行。

;也可以按f11单步执行,不过f11会进入函数内部,相当于gdb中的step。

;按Ctrl+f11可以跳出当前函数,相当于gdb中的finish。

;在断点处按Shift+f5继续执行程序,相当于gdb中的continue。

;在变量上按f8会输出变量的值,相当于gdb的print。

;在变量上按Ctrl+f8会打印出指针对应的值。

;--------------------

;--------------------------------------shell,gdb退出后,自动关闭该 buffer----------------------------------------

(add-hook 'shell-mode-hook 'mode-hook-func)

(add-hook 'gdb-mode-hook 'mode-hook-func)

(defun mode-hook-func  ()

  (set-process-sentinel (get-buffer-process (current-buffer))

         #'kill-buffer-on-exit))

(defun kill-buffer-on-exit (process state)

  (message "%s" state)

  (if (or

       (string-match "exited abnormally with code.*" state)

       (string-match "finished" state))

      (kill-buffer (current-buffer))))

;--------------------------------------shell,gdb退出后,自动关闭该 buffer----------------------------------------

;;cscope 没有

;--------------------------------------windows下的启动最大化----------------------------------------

(defun maximize-frame ()

   "Maximizes the active frame in Windows"

   (interactive)

   ;; Send a `WM_SYSCOMMAND' message to the active frame with the

   ;; `SC_MAXIMIZE' parameter.

   (when (eq system-type 'windows-nt)

     (w32-send-sys-command 61488)))

(add-hook 'window-setup-hook 'maximize-frame t)

;--------------------------------------windows下的启动最大化----------------------------------------

;----------------------------------------这个是emacs的字体 ----------------------------------------

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

 '(delete-selection-mode nil)

 '(ecb-options-version "2.40")

 '(mark-even-if-inactive t)

 '(scroll-bar-mode (quote right))

 '(show-paren-mode t)

 '(transient-mark-mode 1))

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

 '(default ((t (:inherit nil :stipple nil :background "darkslategrey" :foreground "wheat" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 106 :width normal :foundry "unknown" :family "新宋体")))))

;----------------------------------------这个是emacs的字体 ----------------------------------------

;----------------------------书签,有点像win下的书签----------------------------

;(enable-visual-studio-bookmarks);开启书签

;  * F2 在当前行设置或取消书签

;  * C-F2 查找下一个书签

;  * S-F2 查找上一个书签

;  * C-S-F2 清空当前文件的所有书签

;那个书签刚好是反的,可能是设计者比较烦微软吧。但是,由于emacs远远的诞生于微软之前,所以,

;基本可以判定,是微软的方式和emacs的行为,是反的。根据分析,我个人还是比较赞同微软的方式

;更加的人性化,毕竟,单独F2确实容易 误按,而增加的Ctrl-F2在设定上确实是人性化。

(load-file "D:\\emacs\\emacs-22.3\\other_el\\bm.el")

;(load-file "D:\\emacs\\emacs-22.3\\other_el\\bookmark+.el")

;(load-file "D:\\emacs\\emacs-22.3\\other_el\\bookmark_hjz.el")

;(require 'hjz-bookmark)

(require 'bm)

(global-set-key [f2] 'undo);udo

(global-set-key [C-f2] 'bm-toggle);设定书签

(global-set-key [f2] 'bm-next);下一个书签

;----------------------------书签,有点像win下的书签----------------------------

;---------------------auto complete-------------------

(add-to-list 'load-path "D:\\emacs\\emacs-22.3\\.emacs.d\\")

(require 'auto-complete-config)

(add-to-list 'ac-dictionary-directories "d:\\emacs\\emacs-22.3\\.emacs.d\\ac-dict")

(ac-config-default)

;; Show 0.8 second later

(setq ac-auto-show-menu 0.1)

;; 20 lines

(setq ac-menu-height 20)

;; Examples

(set-face-background 'ac-candidate-face "lightgray")

(set-face-underline 'ac-candidate-face "darkgray")

(set-face-background 'ac-selection-face "steelblue")

(add-hook 'c++-mode (lambda () (add-to-list 'ac-sources 'ac-source-semantic)))

;; Complete member name by C-c . for C++ mode.

;(add-hook 'c++-mode-hook

;          (lambda ()

;            (local-set-key (kbd "C-c .") 'ac-complete-semantic)))

;; Complete file name by C-c /

;(global-set-key (kbd "C-c /") 'ac-complete-filename)

(defun semantic-and-gtags-complete ()

  (interactive)

  (auto-complete '(ac-source-semantic ac-source-gtags)))

(defun auto-complete-settings ()

  "Settings for `auto-complete'."

  ;; After do this, isearch any string, M-: (match-data) always

  ;; return the list whose elements is integer

  (global-auto-complete-mode 1)

  ;; 不让回车的时候执行`ac-complete', 因为当你输入完一个

  ;; 单词的时候, 很有可能补全菜单还在, 这时候你要回车的话,

  ;; 必须要干掉补全菜单, 很麻烦, 用M-j来执行`ac-complete'

  (define-key ac-complete-mode-map "/C-i"   'nil)

  ;(define-key ac-complete-mode-map "RET"        'nil)

  ;(define-key ac-complete-mode-map "M-j"        'ac-complete)

  ;(define-key ac-complete-mode-map "<C-return>" 'ac-complete)

  (define-key ac-complete-mode-map "/C-n"        'ac-next)

  (define-key ac-complete-mode-map "/C-p"        'ac-previous)

  (setq ac-dwim t)

  (setq ac-candidate-max ac-candidate-menu-height)

  (set-default 'ac-sources

               '(ac-source-semantic

                 ac-source-yasnippet

                 ac-source-abbrev

                 ac-source-words-in-buffer

                 ac-source-words-in-all-buffer

                 ac-source-imenu

                 ac-source-files-in-current-dir

                 ac-source-filename))

  ;(setq ac-modes ac+-modes)

  (dolist (command `(backward-delete-char-untabify delete-backward-char))

    (add-to-list 'ac-trigger-commands command))

  (defun ac-start-use-sources (sources)

    (interactive)

    (let ((ac-sources sources))

      (call-interactively 'ac-start)))

  (defvar ac-trigger-edit-commands

    `(self-insert-command

      delete-backward-char

      backward-delete-char

      backward-delete-char-untabify)

    "*Trigger edit commands that specify whether `auto-complete' should start or not when `ac-completing'."))

(eval-after-load "auto-complete"

  '(auto-complete-settings))

(eval-after-load "cc-mode"

  '(progn

     (dolist (command `(c-electric-backspace

                        c-electric-backspace-kill))

       (add-to-list 'ac-trigger-commands command)

       (add-to-list 'ac-trigger-edit-commands command))))

(eval-after-load "autopair"

  '(progn

     (dolist (command `(autopair-insert-or-skip-quote

                        autopair-backspace

                        autopair-extra-skip-close-maybe))

       (add-to-list 'ac-trigger-commands command))

     (defun ac-trigger-command-p ()

       "Return non-nil if `this-command' is a trigger command."

       (or

        (and

         (memq this-command ac-trigger-commands)

         (let* ((autopair-emulation-alist nil)

                (key (this-single-command-keys))

                (beyond-autopair (or (key-binding key)

                                     (key-binding (lookup-key local-function-key-map key)))))

           (memq beyond-autopair ac-trigger-edit-commands)))

        (and ac-completing

             (memq this-command ac-trigger-edit-commands))))))

(defun ac-settings-4-lisp ()

  "Auto complete settings for lisp mode."

  (setq ac-omni-completion-sources '(("//<featurep/s+'" ac+-source-elisp-features)

                                     ("//<require/s+'"  ac+-source-elisp-features)

                                     ("//<load/s+/""    ac-source-emacs-lisp-features)))

  (ac+-apply-source-elisp-faces)

  (setq ac-sources

        '(ac-source-yasnippet

          ac-source-symbols

          ;; ac-source-semantic

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ;; ac-source-imenu

          ac-source-files-in-current-dir

          ac-source-filename)))

(defun ac-settings-4-java ()

  (setq ac-omni-completion-sources (list (cons "//." '(ac-source-semantic))

                                         (cons "->" '(ac-source-semantic))))

  (setq ac-sources

        '(;;ac-source-semantic

          ac-source-yasnippet

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-files-in-current-dir

          ac-source-filename)))

(defun ac-settings-4-c ()

  (setq ac-omni-completion-sources (list (cons "//." '(ac-source-semantic))

                                         (cons "->" '(ac-source-semantic))))

  (setq ac-sources

        '(ac-source-yasnippet

          ac-source-c-keywords

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-files-in-current-dir

          ac-source-filename)))

(defun ac-settings-4-cpp ()

  (setq ac-omni-completion-sources

        (list (cons "//." '(ac-source-semantic))

              (cons "->" '(ac-source-semantic))))

  (setq ac-sources

        '(ac-source-yasnippet

          ac-source-c++-keywords

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-files-in-current-dir

          ac-source-filename)))

(defun ac-settings-4-text ()

  (setq ac-sources

        '(;;ac-source-semantic

          ac-source-yasnippet

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-imenu)))

(defun ac-settings-4-eshell ()

  (setq ac-sources

        '(;;ac-source-semantic

          ac-source-yasnippet

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-files-in-current-dir

          ac-source-filename

          ac-source-symbols

          ac-source-imenu)))

(defun ac-settings-4-ruby ()

  (require 'rcodetools-settings)

  (setq ac-omni-completion-sources

        (list (cons "//." '(ac-source-rcodetools))

              (cons "::" '(ac-source-rcodetools)))))

(defun ac-settings-4-html ()

  (setq ac-sources

        '(;;ac-source-semantic

          ac-source-yasnippet

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-files-in-current-dir

          ac-source-filename)))

(defun ac-settings-4-tcl ()

  (setq ac-sources

        '(;;ac-source-semantic

          ac-source-yasnippet

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-files-in-current-dir

          ac-source-filename)))

(defun ac-settings-4-awk ()

  (setq ac-sources

        '(;;ac-source-semantic

          ac-source-yasnippet

          ac-source-abbrev

          ac-source-words-in-buffer

          ac-source-words-in-all-buffer

          ac-source-files-in-current-dir

          ac-source-filename)))

;(am-add-hooks

; `(lisp-mode-hook emacs-lisp-mode-hook lisp-interaction-mode-hook

;                  svn-log-edit-mode-hook change-log-mode-hook)

; 'ac-settings-4-lisp)

;(apply-args-list-to-fun

; (lambda (hook fun)

;   (am-add-hooks hook fun))

; `(('java-mode-hook   'ac-settings-4-java)

;   ('c-mode-hook      'ac-settings-4-c)

;   ('c++-mode-hook    'ac-settings-4-cpp)

;   ('text-mode-hook   'ac-settings-4-text)

;   ('eshell-mode-hook 'ac-settings-4-eshell)

;   ('ruby-mode-hook   'ac-settings-4-ruby)

;   ('html-mode-hook   'ac-settings-4-html)

;   ('java-mode-hook   'ac-settings-4-java)

;   ('awk-mode-hook    'ac-settings-4-awk)

;   ('tcl-mode-hook    'ac-settings-4-tcl)))

;(eal-eval-by-modes

; ac-modes

; (lambda (mode)

;   (let ((mode-name (symbol-name mode)))

;     (when (and (intern-soft mode-name) (intern-soft (concat mode-name "-map")))

;       (define-key (symbol-value (am-intern mode-name "-map")) (kbd "C-c a") 'ac-start)))))

(provide 'auto-complete-settings)

(require 'auto-complete-settings)

;---------------------auto complete-------------------

;------------------------------------as3模式下的相关的关键字-------------------------------------

(font-lock-add-keywords

; 'actionscript-mode

 'c++-mode

 '(

   ("\\<\\(phjz\\)\\>" 1 cus-face-test t)

     ;   ("\\<\\(public\\)\\>" 1 which-func t)

     ;   ("\\<\\(protected\\)\\>" 1 which-func t)

     ;   ("\\<\\(import\\)\\>" 1 which-func t)

     ;   ("\\<\\(new\\)\\>" 1 which-func t)

     ;   ("\\<\\(var\\)\\>" 1 which-func t)

     ;   ("\\<\\(function\\)\\>" 1 which-func t)

     ;   ("\\<\\(override\\)\\>" 1 which-func t)

     ;   ("\\<\\(void\\)\\>" 1 which-func t)

     ;   ("\\<\\(null\\)\\>" 1 widget-button-pressed t)

     ;   ("\\<\\(DEBUG_PRINT\\)\\>" 1 font-lock-keyward-face t)

   )

 )

;------------------------------------as3模式下的相关的关键字-------------------------------------