(xterm-mouse-mode)
(setq zch-name
"何清龙")
(setq user-full-name
"He Qinglong")
(setq user-mail-address
"731458742@qq.com")
;; 邮件设置
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq
send-mail-function
'smtpmail-send-it)
(setq smtpmail-smtp-server "smtp.qq.com")
(setq smtpmail-auth-credentials
'((
"smtp.qq.com" 25 "731458742@qq.com" "666666")))
;;(setenv
"MAILHOST" "ynsjzch@163.com")
(setq rmail-primary-inbox-list
"ynsjzch")
(setq rmail-
pop-password-required t)
;; 使用mew收发电子邮件
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(
if nil
(progn
(autoload
'mew "mew" nil t)
(autoload 'mew-
send "mew" nil t)
(
if (boundp
'read-mail-command)
(setq read-mail-command 'mew))
(autoload
'mew-user-agent-compose "mew" nil t)
(if (boundp 'mail-user-agent)
(setq mail-user-agent
'mew-user-agent))
(if (fboundp 'define-mail-user-agent)
(define-mail-user-agent
'mew-user-agent
'mew-user-agent-compose
'mew-draft-send-message
'mew-draft-
kill 'mew-send-hook))
(setq mew-pop-size 0)
(setq mew-smtp-auth-list nil)
(setq toolbar-mail-reader 'Mew)
(set-default
'mew-decode-quoted 't)
(setq mew-config-alist
'(("default"
("name" . "He Qinglong")
("user" . "731458742")
("mail-domain" . "qq.com")
("pop-server" . "pop.qq.com")
("pop-port" . "110")
("pop-user" . "731458742")
("pop-auth" . pass)
("smtp-server" . "smtp.qq.com")
("smtp-port" . "25")
("smtp-user" . "731458742")
("smtp-auth-list" . ("PLAIN" "LOGIN" "CRAM-MD5")))
))
))
;;(setq mew-icon-directory (expand-file-name "mew/etc" dtsite-dir))
(when (boundp 'utf-translate-cjk)
(setq utf-translate-cjk t)
(custom-set-variables
'(utf-translate-cjk t)))
(if (fboundp 'utf-translate-cjk-mode)
(utf-translate-cjk-mode
1))
(
require 'flyspell)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; C++ 设置
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst c++-keywords
(cons
(regexp-opt
(list "struct" "class" "public" "private" "interface" "virtual" "if" "for" "while" "protected" "static" "inline" "int"
) 'words)
font-
lock-keyword-face))
;;(font-
lock-add-keywords
'c++-mode (list c++-keywords) 'set)
(defface c++-type-face
'(
(((class color) (min-colors 88) (background dark)) :foreground "#bb88ff"))
"dnc begin end" :group 'c++-mode)
;;(add-hook
;;
'c++-mode-hook
;;(setq font-lock-type-face 'c++-type-face)
;;(setq font-
lock-variable-name-face
'c++-type-face)
;;(setq font-lock-keyword-face 'c++-type-face)
;; )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;header
(
require 'header)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dnc
(load "dnc")
;;dnc扩展的C++关键字
(defconst c++-dnc-keywords
(cons
(regexp-opt
(list
"foreach" "foreach_r" "interface" "null" "foreign" "dself" "dthis" "dsuper"
"dtypeof" "decltype" "dcnew" "dcdel" "dtypename" "dcdel_array" "dpnew"
"dpdel" "thread_value" "dnc_property_begin" "dnc_property_end" "dnc_property"
"dnc_property_set" "dnc_property_get" "dnc_event" "dref" "dnew" "dnc_property2"
"dnc_property_set2" "dnc_property_get2" "dnc_class" "dnc_interface"
"dnc_struct" "true" "false" "static_assert"
) 'words)
font-
lock-keyword-face
))
(font-
lock-add-keywords
'c++-mode (list c++-dnc-keywords))
(defface dnc-begin-end-face
'((((class color) (min-colors
88) (background dark))
:foreground
"#bb88ff"))
"dnc begin end" :group
'c++-mode)
(defface dnc-begin-end-entry-face
'((((class color) (min-colors
88) (background dark))
:foreground
"#7788bb"))
"dnc begin end" :group
'c++-mode)
(defface c++-operator-face
'((((class color) (min-colors
88) (background dark))
:foreground
"DeepSkyBlue1" ))
;;:foreground
"gold" ))
"" :group
'c++-mode)
(defface c++-number-face
'((((class color) (min-colors
88) (background dark))
:foreground
"PaleVioletRed3"))
"" :group
'c++-mode)
(defface c++-include-face
'((((class color) (min-colors
88) (background dark))
:foreground
"#a88b17"))
"" :group
'c++-mode)
(defface c++-lisp-face
'((((class color) (min-colors
88) (background dark))
:foreground
"#ff5500"))
"" :group
'c++-mode)
(defface c++-define-face
'((((class color) (min-colors
88) (background dark))
:foreground
"#9955ff"))
"" :group
'c++-mode)
(defface c++-keyword-face
'((((class color) (min-colors
88) (background dark))
:foreground
"DodgerBlue1" :weight bold))
"" :group
'c++-mode)
(add-hook 'c++-mode-hook
(lambda ()
(font-
lock-add-keywords
nil
'(("\\(dnc_[A-Za-z_]+_begin\\|dnc_[A-Za-z_]+_end\\)"
(1 'dnc-begin-end-face))
(
"\\(dnc_cxxon_item_.*\\)(" (
1 'dnc-begin-end-entry-face))
("#include +\\(\<.*\>\\|\".*\"\\)"
;;("#include +\\(\<[a-z_.]+\>\\)"
(0 'c++-include-face))
(
"\\(dnc_class\\|dnc_interface\\|dnc_struct\\)" (
1 'c++-define-face))
("([ \n]*\\(\$[a-zA-Z_]+\\),"
(1 'c++-lisp-face))
(
"\\b\\([.]*[0-9]+[.a-zA-Z_]*\\)\\b" (
1 'c++-number-face))
("\\(\+\\|\-\\|\[\\|\]\\|\*\\|==\\|!=\\|[.,!~:\{\}\(\);=%|&?\+\-\*/\>\<^]\\)"
(1 'c++-operator-face))
)
)))
(defun dnc-cxxon-get-keyword(arg)
(let ((ret))
(message
"--%s--" arg)
(setq ret (+ arg
1))
(setq ret nil)
))
;;(font-
lock-add-keywords
'c++-mode (list 'dnc-cxxon-get-keyword))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; javascript
;;(autoload
'javascript-mode "javascript" nil t)
;;(add-to-list 'auto-mode-alist
'("\\.js\\'" . javascript-mode))
;;ecmascript-mode
;;(add-to-list 'auto-mode-alist '("\\.js\\
'" . ecmascript-mode))
;;(autoload 'ecmascript-mode
"ecmascript-mode" nil t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; doxymacs
(
require 'doxymacs)
(add-hook 'php-mode-user-hook
'doxymacs-mode)
(add-hook 'c-mode-common-hook
'doxymacs-mode)
(add-hook 'c++-mode-common-hook
'doxymacs-mode)
(defun zch-doxymacs-font-lock-hook ()
(if (or (eq major-mode 'c-mode)
(eq major-mode
'c++-mode)
(eq major-mode 'php-mode)
(eq major-mode
'idl-mode))
(doxymacs-font-lock)))
(add-hook 'font-
lock-mode-hook
'zch-doxymacs-font-lock-hook)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; others
;(setq display-time-24hr-format t)
;(setq display-time-day-and-date t)
;(display-time)
(setq inhibit-startup-message t)
;;syntax Highlighting
(global-font-lock-mode t)
;;auto indent
;;'(font-
lock-comment-face
;; ((((class color) (background light))
;; (:foreground
"Firebrick" :slant italic))))
(fset
'yes-or-no-p 'y-or-n-p)
(transient-mark-mode t)
(setq column-number-mode t)
(setq line-number-mode t)
(setq-default make-backup-files nil)
(setq w32-
use-w32-font-dialog nil)
(scroll-bar-mode nil);
(setq-default indent-tabs-mode nil)
(setq scroll-margin
3 scroll-conservatively
10000)
(setq frame-title-
format "%b %f")
(put
'set-goal-column 'disabled nil)
(put
'narrow-to-region 'disabled nil)
(put
'upcase-region 'disabled nil)
(put
'downcase-region 'disabled nil)
(put
'LaTeX-hide-environment 'disabled nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dired
(
require 'dired-x)
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes
'top)
(setq dired-guess-shell-alist-user
(list
(list "\\.chm$" "xchm")
(list "\\.rm$" "gmplayer")
(list "\\.rmvb$" "gmplayer")
(list "\\.mkv$" "gmplayer")
(list "\\.avi$" "gmplayer * &")
(list "\\.asf$" "gmplayer")
(list "\\.wmv$" "gmplayer")
(list "\\.mpg$" "gmplayer")
(list "\\.htm$" "firefox")
(list "\\.html$" "firefox")
(list "\\.pdf$" "evince")
(list "\\.doc$" "soffice")
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; project
(load "project")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; can open zip file
(auto-compression-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; the mouse cursor will dodge
(mouse-avoidance-mode 'animate) ;;
(show-paren-mode
1) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Makefile
(setq auto-mode-alist (append auto-mode-alist
'( ("\\.ma?k\\'" . makefile-mode)
("\\(M\\|m\\|GNUm\\)akefile\\(\\.in\\)?
" . makefile-mode)
("\\.cfg\\
'" . makefile-mode)
)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Function keys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mouse keys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tab keys
(setq backup-by-copying-when-mismatch t)
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
;(load-file "/usr/local/share/emacs/site-lisp/cedet/common/cedet.el")
(require 'cedet)
(
require 'eieio-opt)
(global-ede-mode 1) ; Enable the Project management system
(semantic-load-enable-code-helpers) ; Enable prototype help and smart completion
;; Enable source code folding
(semantic-load-enable-code-helpers)
;; Key bindings
(defun zch-cedet-hook ()
(local-set-key [(control return)] 'semantic-ia-complete-symbol)
(
local-set-key
"\C-c?" 'semantic-ia-complete-symbol-menu)
(local-set-key "\C-cd" 'semantic-ia-fast-jump)
(
local-set-key
"\C-cr" 'semantic-symref-symbol)
(local-set-key "\C-cR" 'semantic-symref))
(add-hook
'c-mode-common-hook 'zch-cedet-hook)
;;;; 当输入
"."或
">"时,在另一个窗口中列出结构体或类的成员
(defun zch-c-mode-cedet-hook ()
(
local-set-key
"." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert))
(add-hook
'c-mode-common-hook 'zch-c-mode-cedet-hook)
(
require 'ecb)
(setq stack-trace-on-error t)
(setq ecb-auto-activate t
ecb-tip-of-the-day nil)
;(ecb-hide-ecb-windows)
;;;; 各窗口间切换
(global-set-key [M-left] 'windmove-left)
(global-set-key [M-right]
'windmove-right)
(global-set-key [M-up] 'windmove-up)
(global-set-key [M-down]
'windmove-down)
;;;; 隐藏和显示ecb窗口
(define-key global-map [(control f1)] 'ecb-hide-ecb-windows)
(define-key global-
map [(control f2)]
'ecb-show-ecb-windows)
;(load "idb")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; svn
;;use
;;M-x svn-status 启动psvn
;;psvn 比emacs的pcl-cvs提供更加完整的svn操作支持
;;;;;;;;;;;;;;;;;;;;;;;;;;
;;(require 'psvn)
(defconst header-copyright-notice
"Copyright (C) 2012 He Qinglong (731458742@qq.com).")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; flex
(autoload
'bison-mode "bison-mode.el")
(autoload 'flex-mode
"flex-mode")
(add-to-list
'auto-mode-alist '(
"\\.y\\'" . bison-mode))
(add-to-list
'auto-mode-alist '(
"\\.l\\'" . bison-mode)) ;;flex-mode is bad
;;剪贴板
;;解决其他程序粘贴到emacs是乱码的问题
;;(set-clipboard-coding-
system 'utf-8)
;;(set-clipboard-coding-system 'ctext)
;;允许emacs与外部程序粘贴
(setq x-
select-enable-clipboard t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; font
;;字 体 设 置
;;X 下的字体
;;(
if (string= window-
system "x")
;; (progn
(set-default-font
"-*-Liberation Mono-normal-r-normal--12-*-*-*-*-*-iso8859-1")
;;(set-fontset-font
"fontset-default" 'gb18030'(
"Microsoft YaHei" .
"unicode-bmp"))
;; ))
;;Windows 下的字体
(
if (string= window-
system "w32")
(progn
(set-language-environment
'utf-8)
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; frame font cursor
;;(set-language-environment 'chinese-gb2312)
;;(setq default-frame-alist
;;
'((width . 120) (height . 50)
;; (cursor-color . "white")
;; (cursor-type . box)
;;(font . "-*-Courier-bold-r-*-12-*-*-*-*-*-*-iso8859-2")))
;;设置字体为新宋体 ( Only for windows )
;;(set-face-font 'default
"-outline-新宋体-normal-r-normal-normal-*-*-96-96-c-*-iso8859-1")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; c/c++
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 定位:窗口切换,翻页,文件切换
;; 源代码文件跳转
(setq ff-other-file-alist
'((".h" (".cpp" ".c" ".cpt" ".cc"))
(".cpp" (".h"))
(".cc" (".h"))
(".c" (".h"))
(".cpt" (".h"))
(".ct" (".h"))))
;;头文件
(if (string= window-system "w32")
(progn
(setq cc-search-directories
(list "."
"d:/dev/include"
"d:/gnu-win32/mingw/include"
"d:/gnu-win32/mingw/lib/gcc/mingw32/4.5.2/include/c++"
)))
(progn
(setq cc-search-directories
(list
"."
"/usr/local/share/emacs/dev/include"
"/usr/local/share/emacs/mark/work/linux-2.6.23.1/include"
"/usr/include"
"/usr/include/c++/4.5.1"
"/usr/include/wine/windows"
))))
(if (eq window-system nil)
()
(progn
(require 'color-theme)
(color-theme-gnome2)
;;下面的命令可以列出系统颜色
;;M
-x list-colors-display
))
;;c
(defun zch-c-mode-common-hook()
(setq tab-width
4 indent-tabs-mode nil)
(c-set-style
"stroustrup")
(c-toggle-auto-hungry-state
1);Backspace
(c-toggle-auto-state
0)
(c-set-offset
'member-init-intro '++)
(c-set-offset
'innamespace 0)) ;;名字空间里2个缩进
(add-hook 'c-mode-common-hook
'zch-c-mode-common-hook)
;;auto indent 很奇怪,设置自动缩进需要用global-set-key
(global-set-key "\C-m" 'reindent-then-newline-and-indent)
;;C/C++语法检查
;;(global-cwarn-mode
1)
(add-to-list
'auto-mode-alist '(
"\\.dnc\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.h\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.cpt\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.c\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.hi\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.ct\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.dox\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.ce\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.tpl\\'" . php-mode))
(add-to-list
'auto-mode-alist '(
"\\.php\\'" . c++-mode))
(add-to-list
'auto-mode-alist '(
"\\.js\\'" . c++-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ajax
;;(load
"ajax.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; svn
;;(load
"psvn")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; cimpile
;; 编译定制
(setq zch-compile-test-file
"")
(setq zch-compile-test-args
"")
(setq compile-command
"make -j 3 cd=true d=true")
(defun zch-file-name (name)
"获得文件名,返回结果不包括路径和扩展名" (setq fields (
split-string name
"/"))
(setq name (elt fields (- (
length fields)
1)))
(setq len (
length name))
(setq i len)
(setq ch
"")
(
while (and (> i
0) (not (string= ch
".")))
(progn
(setq ch (substring name (- i
1) i))
(setq i (- i
1))))
(setq name (substring name
0 i)))
(defun zch-file-extension (name)
"获取文件扩展名,如果文件没有扩展名返回空字符串" (setq len (
length name))
(setq i len)
(setq ch
"")
(
while (and (> i
0) (not (string= ch
".")))
(progn
(setq ch (substring name (- i
1) i))
(setq i (- i
1))))
(
if (> i
0)
(setq name (substring name (+ i
1)))
(setq name
"")))
(defun zch-onekey-compile ()
"先保存所有文件,然后编译程序,不包括测试程序" (interactive)
(save-some-buffers t)
(compile compile-command))
(defun zch-onekey-compile-test()
"先保存所有文件,然后编译程序,包括当前的测试程序" (interactive)
(save-some-buffers t)
(setq temp compile-command)
(setq command compile-command)
(setq extension (zch-file-extension buffer-file-name))
(setq test-name nil)
(setq type nil)
(
if (or (string= extension
"ct") (string= extension
"ce"))
(setq zch-compile-test-file buffer-file-name))
(
if (not (string= zch-compile-test-file
""))
(setq extension (file-name-extension zch-compile-test-file)))
;;如果是.ct或者.ce文件,修改测试名字
(cond
((string= extension
"ct") (setq type
" t="))
((string= extension
"ce") (setq type
" e=")))
(
if (string= zch-compile-test-file
"")
(setq command compile-command)
(progn
(setq test-name (zch-file-name zch-compile-test-file))
(setq command (concat compile-command type test-name))))
(compile command)
(setq compile-command temp))
(defun zch-compile-clean ()
"在编译命令之后加上clean,清除完了再恢复原来的编译命令" (interactive)
(save-some-buffers t)
(setq temp compile-command)
(compile (concat compile-command
" clean"))
(setq compile-command temp))
(defun zch-compile-get-param(name)
"获得编译命令里的参数值" (let ((fields)(ret))
(setq fields (
split-string compile-command
" "))
(
while fields
(setq param (car fields))
(setq pair (
split-string param
"="))
(setq key (car pair))
(
if (and (eq (
length pair)
2) (string= key name))
(progn
(setq val (cdr pair))
(setq ret (car val))
(setq fields nil))
(setq fields (cdr fields)))
)
(
if (and (string= window-
system "w32") (string= name
"p"))
(setq ret
"msw")
(setq ret ret))))
(defun zch-compile-test-prefix()
"获得工程的测试目录,这个目录根据编译参数产生" (let ((p)(ret))
(setq p (zch-compile-get-param
"p"))
(
if (not p)
(setq p
"linux"))
(setq d (zch-compile-get-param
"d"))
(
if (and d (string= d
"true"))
(setq ret (concat (dnc-project-name)
"-d." p))
(setq ret (concat (dnc-project-name)
"." p)))
))
(defun zch-compile-run-command()
"获得测试程序的路径和名称,使用这个名称可以直接运行" (let ((p)(ret)(dir-spliter))
(setq p (zch-compile-get-param
"p"))
(
if (string= window-
system "w32")
(setq dir-spliter
"\\")
(setq dir-spliter
"/"))
(
if (string=
"ct" (file-name-extension zch-compile-test-file))
(setq ret (concat
".."dir-spliter
"test"dir-spliter (zch-compile-test-prefix)
"." (zch-file-name zch-compile-test-file)
".ct"))
(setq ret (concat
".."dir-spliter
"bin"dir-spliter (zch-file-name zch-compile-test-file))))
(
if (string=
"msw" p)
(setq ret (concat ret
".exe")))
(setq ret ret)
))
(defun zch-compile-run ()
"编译并运行编译好的程序" (interactive)
(save-some-buffers t)
(setq temp compile-command)
(setq extension (zch-file-extension buffer-file-name))
(setq test-name nil)
(setq type nil)
(
if (or (string= extension
"ct") (string= extension
"ce"))
(setq zch-compile-test-file buffer-file-name))
(
if (not (string= zch-compile-test-file
""))
(setq extension (file-name-extension zch-compile-test-file)))
;;如果是.ct或者.ce文件,修改测试名字
(cond
((string= extension
"ct") (setq type
" t="))
((string= extension
"ce") (setq type
" e=")))
(
if (string= zch-compile-test-file
"")
(setq command compile-command)
(progn
(setq test-name (zch-file-name zch-compile-test-file))
(setq command (concat compile-command type test-name))
(setq command (concat command
" && " (zch-compile-run-command)))
(setq command (concat command
" " zch-compile-test-args))))
(compile command)
(setq compile-command temp))
(setq zch-compile-run-any-command
"gcc")
(defun zch-compile-run-any ()
"编译任意的单个文件并运行编译好的程序" (interactive)
(save-some-buffers t)
(setq temp compile-command)
(setq test-name nil)
(setq type nil)
(setq extension (file-name-extension buffer-file-name))
(setq run-name (zch-file-name buffer-file-name))
(setq run-file (concat run-name
"." extension))
(setq command (concat zch-compile-run-any-command
" -o " run-name
" " run-file))
(setq command (concat command
" && ./" run-name))
(setq command (concat command
" " zch-compile-test-args))
(compile command)
(setq compile-command temp))
(defun zch-compile-gccsense ()
"使用gccsense编译所有文件,然后使得成员提示会起作用" (interactive)
(save-some-buffers t)
(setq temp compile-command)
(compile
"make gccsense")
(setq compile-command temp))
(defun zch-modify-compile-run-any-command(command)
"修改zch-compile-run-any命令所使用的编译命令" (interactive
(list (
read-from-minibuffer
"Modify compile run any command: " (
eval zch-compile-run-any-command) nil nil))
(list (
eval zch-compile-run-any-command)))
(setq zch-compile-run-any-command command))
(defun zch-compile-test-all()
"编译所有测试程序并且运行它们" (interactive)
(save-some-buffers t)
(setq temp compile-command)
(compile (concat compile-command
" args=\"" zch-compile-test-args "\
" test"))
(setq compile-command temp))
(defun zch-compile-exe-all()
"编译所有可执行程序" (interactive)
(save-some-buffers t)
(setq temp compile-command)
(compile (concat compile-command
" exe"))
(setq compile-command temp))
(defun zch-compile-modify-test-args(args)
"修改测试程序的参数" (interactive
(list (
read-from-minibuffer
"Modify test arguments: " (
eval zch-compile-test-args) nil nil))
(list (
eval zch-compile-test-args)))
(setq zch-compile-test-args args))
(defun zch-modify-compile-command(command)
"修改编译命令compile-command,并且执行编译" (interactive
(list (
read-from-minibuffer
"Modify compile command: " (
eval compile-command) nil nil
'(compile-history . 1)))
(list (eval compile-command)))
(save-some-buffers t)
(compile command))
(defun zch-compile-modify-test (command)
"修改测试单元zch-compile-test-file,并且执行编译和程序"
(interactive
(list (read-from-minibuffer "Modify test unit: "
(eval zch-compile-test-file) nil nil))
(list (eval zch-compile-test-file)))
(setq zch-compile-test-file command)
(zch-compile-run))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; debug
;;调试定制
(defun zch-gdb-get-file ()
"获得正在调试的可执行文件名"
(setq file (buffer-name gud-comint-buffer))
(setq len (length file))
(setq file (substring file 5 (- len 1))))
(defun zch-gdb-onekey-debug (command)
"一键调试"
(let ((old-buffer)(window))
(interactive)
(setq old-buffer (window-buffer))
(setq window (selected-window))
(gdb (concat "gdb --annotate=3 -windows" command))
(set-window-buffer (selected-window) old-buffer)
(other-window 1)
(set-window-buffer (selected-window) gud-comint-buffer)
(select-window window)))
(defun zch-gdb-ptype()
"打印光标所在处的标识符的类型"
(interactive)
(setq symbol (sbw-get-symbol-at-cursor))
(if symbol
(gud-call (concat "ptype " symbol))))
(defun zch-gdb-ptype-dcptr()
"打印光标所在处的标识符的类型"
(interactive)
(setq symbol (sbw-get-symbol-at-cursor))
(if symbol
(gud-call (concat "ptype " symbol ".m_p"))))
(defun zch-gdb-print-dcptr()
"打印光标所在处的智能指针的对象"
(interactive)
(setq symbol (sbw-get-symbol-at-cursor))
(if symbol
(gud-call (concat "print " symbol ".m_p"))))
(defun zch-gdb-pstar-dcptr()
"打印光标所在处的智能指针的对象"
(interactive)
(setq symbol (sbw-get-symbol-at-cursor))
(if symbol
(gud-call (concat "print *" symbol ".m_p"))))
(setq zch-gdb-source-window nil)
(defun zch-gdb-switch-window()
"在源代码窗口和调试窗口之间进行切换"
(interactive)
(if (eq (window-buffer) gud-comint-buffer)
(select-window zch-gdb-source-window)
(progn
(setq zch-gdb-source-window (selected-window))
(setq gdb-window (get-buffer-window gud-comint-buffer))
(if gdb-window
(select-window gdb-window)
(progn
(other-window 1)
(set-window-buffer (selected-window) gud-comint-buffer))))))
(defun zch-gdb-frame-buffer(name)
"打开指定调试frame窗口,name 可以是任何gdb-buffer-rules-assoc变量列出的名字"
(setq window (selected-window))
(other-window 1)
(if (eq (window-buffer) gud-comint-buffer)
(other-window 1))
(if (eq (gdb-get-buffer name) nil)
(set-window-buffer (selected-window) (gdb-get-buffer-create name)))
(if (eq (get-buffer-window (gdb-get-buffer name)) nil)
(set-window-buffer (selected-window) (gdb-get-buffer name)))
(select-window window))
(defun zch-gdb-assembler-buffer()
"在另外一个窗口打开assembler frame"
(interactive)
(zch-gdb-frame-buffer 'gdb-assembler-buffer))
(defun zch-gdb-locals-buffer()
"在另外一个窗口打开locals frame" (interactive)
(zch-gdb-frame-buffer
'gdb-locals-buffer))
(defun zch-gdb-memory-buffer()
"在另外一个窗口打开memory frame"
(interactive)
(zch-gdb-frame-buffer 'gdb-memory-buffer))
(defun zch-gdb-registers-buffer()
"在另外一个窗口打开registers frame" (interactive)
(zch-gdb-frame-buffer
'gdb-registers-buffer))
(defun zch-gdb-threads-buffer()
"在另外一个窗口打开threads frame"
(interactive)
(zch-gdb-frame-buffer 'gdb-threads-buffer))
(defun zch-gdb-stack-buffer()
"在另外一个窗口打开stack frame" (interactive)
(zch-gdb-frame-buffer
'gdb-stack-buffer))
(defun zch-gdb-breakpoints-buffer()
"在另外一个窗口打开breakpoints frame"
(interactive)
(zch-gdb-frame-buffer 'gdb-breakpoints-buffer))
(defun zch-gdb-inferior-io()
"在另外一个窗口打开inferior frame" (interactive)
(zch-gdb-frame-buffer
'gdb-inferior-io))
(defun zch-gdb-partial-output-buffer()
"在另外一个窗口打开partial output frame"
(interactive)
(zch-gdb-frame-buffer 'gdb-partial-output-buffer))
(defun zch-gdb-
print-object()
"打开打印对象状态,打开后能通过C++的虚拟机制打印一个对象的最终类的信息" (interactive)
(gud-call
"set print object on"))
;;调试环境
;;(setq gud-tooltip-mode t)
;;(setq gdb-many-windows t)
(
require 'gdb-mi)
;;gdb正在调试的文件
(setq zch-gdb-file "")
(defun zch-gdb-test-debug-or-go ()
"调试测试文件。这个函数的行为是这样的:
*. 如果当前buffer是一个.ct或者.ce文件,并且gdb没有启动,那么启动一个gdb,并且装载当前的测试文件
*. 如果当前buffer不是一个.ct或者.ce文件,并且gdb没有启动,那么启动一个gdb,并且装载当前的测试文件
*. 如果gdb已经启动,那么继续进测试或者开始运行测试
*. 如果当前buffer是一个.ct或者.ce文件,那么这个函数会把zch-compile-test-file变量改成当前buffer里的测试名称
"
(interactive)
(if (string= (zch-file-extension buffer-file-name) "ct")
(setq zch-compile-test-file buffer-file-name))
(if (string= zch-compile-test-file "")
(setq command "")
(setq command (zch-compile-run-command)))
;;判断是否有gdb在运行
(setq has-gdb nil)
(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)))
(setq has-gdb
"true"))
(
if has-gdb
(progn
(
if (eq (get-buffer-window gud-comint-buffer) nil)
(progn
(other-window
1)
(set-window-buffer (selected-window) gud-comint-buffer)))
(setq window (selected-window))
(gud-call (
if gdb-active-process
"continue" "run")
"")
(
select-window window))
(progn
(setq zch-gdb-source-window (selected-window))
(zch-gdb-onekey-debug command)
(setq zch-gdb-file command))))
(defun zch-gdb-debug-or-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)))
(progn
(setq window (selected-window))
(gud-call (if gdb-active-process "continue" "run") "")
(select-window window))
(zch-gdb-onekey-debug "")))
(defun zch-gdb-break-remove ()
"Set/clear breakpoin."
(interactive)
(save-excursion
(if (eq (car (fringe-bitmaps-at-pos (point))) 'breakpoint)
(gud-remove nil)
(gud-break nil))))
(defun zch-gdb-break-watch()
"对光标当前的变量设置内存断点" (interactive)
(setq symbol (sbw-get-symbol-at-cursor))
(
if symbol
(gud-call (concat
"watch " symbol))))
(defun zch-gdb-break-rwatch()
"对光标当前的变量设置内存断点" (interactive)
(setq symbol (sbw-get-symbol-at-cursor))
(
if symbol
(gud-call (concat
"rwatch " symbol))))
(defun zch-gdb-break-awatch()
"对光标当前的变量设置内存断点" (interactive)
(setq symbol (sbw-get-symbol-at-cursor))
(
if symbol
(gud-call (concat
"awatch " symbol))))
(defun zch-gdb-
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)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;符号查找
(load
"sourcebrowser")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;窗口,文件切换
(defun switch-buffer()
(interactive)
(set-window-buffer (selected-window) (other-buffer)))
(defun onekey-
kill-buffer()
(interactive)
(
kill-buffer (current-buffer)))
(setq g-switch-ecb-flag nil)
(defun switch-ecb-activate()
(interactive)
(
if g-switch-ecb-flag
(progn
(setq g-switch-ecb-flag nil)
(ecb-activate))
(progn
(setq g-switch-ecb-flag t)
(ecb-deactivate)) ))
(defun insert-zch-copyright()
(interactive)
(insert zch-name (
format-
time-string
" %Y-%m-%d")
"731458742@qq.com"))
(defun insert-date()
(interactive)
(insert (
format-
time-string
"%Y-%m-%d")))
(defun replace-word()
"替换一个单词,并且查找时区分大小写" (interactive) )
;;全屏
(defun zch-fullscreen ()
(interactive)
(
if (string= window-
system "w32")
(shell-command
"msw-fullscreen.exe")
(x-
send-client-message
nil
0 nil
"_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_FULLSCREEN" 0))))
;;最大化
(defun zch-maximized-horz ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(
1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
(defun zch-maximized-vert ()
(interactive)
(x-
send-client-message
nil
0 nil
"_NET_WM_STATE" 32 '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(defun zch-maximized ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(
1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(interactive)
(x-
send-client-message
nil
0 nil
"_NET_WM_STATE" 32 '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; buffer 操作
(defun zch-revert-buffer()
"刷新buffer,当文件在外部被修改时有用"
(interactive)
(revert-buffer nil t))
(defun zch-revert-buffer-all()
"重新装载所有buffer中的文件"
(interactive)
(let ((buffers (buffer-list))
(old-buffer (current-buffer)
))
(while buffers
(setq buffer (car buffers))
(set-buffer buffer)
(if (buffer-file-name)
(revert-buffer nil t))
(pop buffers))
(set-buffer old-buffer)
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 查找替换
(setq zch-replace-files-regexp-command "perl -p -i -e 's///g
' *")
(defun zch-replace-files-regexp(command)
"使用正则表达式替换多个文件中的字符串"
(interactive
(list (read-from-minibuffer "replace files: "
(eval zch-replace-files-regexp-command) nil nil))
(list (eval zch-replace-files-regexp-command)))
(save-some-buffers)
(shell-command command)
(zch-revert-buffer-all)
(setq zch-replace-files-regexp-command command))
(setq zch-replace-files-regexp-command-r "perl -p -i -e 's///g
' `find . -name \"*\"`")
(defun zch-replace-files-regexp-r(command)
"使用正则表达式递归的替换多个文件中的字符串"
(interactive
(list (read-from-minibuffer "replace files: "
(eval zch-replace-files-regexp-command-r) nil nil))
(list (eval zch-replace-files-regexp-command-r)))
(save-some-buffers)
(shell-command command)
(zch-revert-buffer-all)
(setq zch-replace-files-regexp-command-r command))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 特殊编辑
(defun zch-insert-pointer-access()
(interactive)
(insert-string "->"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; window
;;为支持高清显示器
;;水平拆分成3个窗口
(defun split-window-horizontally3()
"把窗口拆分成水平的3个,适合高清显示器"
(interactive)
(setq width (+ (/ (window-width) 3) 1))
(split-window nil (* width 2) t)
(split-window nil width t)
)
(defun split-window5-and-fullscreen()
"把窗口拆分成水平的5个,并且全屏显示emacs"
(interactive)
(zch-fullscreen)
(split-window5))
;;拆分成6个窗口
(defun split-window6()
"把窗口拆分成6个,适合高清显示器"
(interactive)
(setq width (+ (/ (window-width) 3) 1))
(setq height (/ (window-height) 2))
(setq w (split-window nil (* width 2) t))
(split-window w height)
(setq w (split-window nil width t))
(split-window w height)
(split-window nil height) )
(defun split-window5()
"把窗口拆分成5个,中间一个很高的窗口,它的两边一边两个,适合高清显示器"
(interactive)
(setq width (+ (/ (window-width) 3) 1))
(setq height (/ (window-height) 2))
(setq w (split-window nil (* width 2) t))
(split-window w height)
(setq w (split-window nil width t))
(split-window nil height))
;;窗口,文件切换
(defun zch-previous-window()
(interactive)
(select-window (previous-window)))
(defun zch-next-window()
(interactive)
(select-window (next-window)))
(defun onekey-kill-buffer()
(interactive)
(kill-buffer (current-buffer)))
;;全屏
(defun zch-fullscreen ()
(interactive)
(if (string= window-system "w32")
(shell-command "msw-fullscreen.exe")
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(
2 "_NET_WM_STATE_FULLSCREEN" 0))))
;;最大化
(defun zch-maximized-horz ()
(interactive)
(x-
send-client-message
nil
0 nil
"_NET_WM_STATE" 32 '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
(defun zch-maximized-vert ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(
1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(defun zch-maximized ()
(interactive)
(x-
send-client-message
nil
0 nil
"_NET_WM_STATE" 32 '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(
1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq g-previous-buffer-name nil)
(defun switch-ecb-edit-window()
"在ECB窗口和编辑窗口之间进行切换" (interactive)
(let ((current-buffer-name (buffer-name)))
(
if (or (string= current-buffer-name
" *ECB Directories*")
(string= current-buffer-name
" *ECB Sources*")
(string= current-buffer-name
" *ECB Methods*")
(string= current-buffer-name
" *ECB History*"))
(ecb-
goto-window-edit-
last)
(progn
(
if (string= g-previous-buffer-name
" *ECB Directories*")
(ecb-
goto-window-directories)()
(
if (string= g-previous-buffer-name
" *ECB Sources*")
(ecb-
goto-window-sources)()
(
if (string= g-previous-buffer-name
" *ECB Methods*")
(ecb-
goto-window-methods)()
(
if (string= g-previous-buffer-name
" *ECB History*")
(ecb-
goto-window-history)()
(ecb-
goto-window-methods)))))))
(setq g-previous-buffer-name current-buffer-name)
))
(defun insert-zch-copyright()
(interactive)
(insert zch-name (
format-
time-string
" %Y-%m-%d")
"731458742@qq.com"))
(defun insert-date()
(interactive)
(insert (
format-
time-string
"%Y-%m-%d")))
(defun replace-word()
"替换一个单词,并且查找时区分大小写" (interactive)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 自定义选择功能
;;矩形区域选择使用ctrl+enter键
(setq cua-enable-cua-
keys nil)
(cua-mode t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; auto-complete
;; 自动补全
;;http://cx4a.org
(add-to-list
'load-path "/usr/local/share/emacs/site-lisp/auto-complete")
(require 'auto-complete-config)
(add-to-list
'ac-dictionary-directories "/usr/local/share/emacs/site-lisp/auto-complete/ac-dict")
(ac-config-default)
;;http://cx4a.org
(require 'gccsense)
(set-face-background
'ac-candidate-face "#66bb00")
(set-face-underline 'ac-candidate-face
"#448800")
(set-face-background
'ac-selection-face "#eeee00")
(set-face-foreground 'ac-selection-face
"#ff0000")
;;由于gccsense是用的gcc4.
4,而我的代码是用gcc4.5编译的,这检查会出现很多语法错误,因此暂时不用语法检测
;;等gccsense用gcc4.5再说
;;(add-hook
'c-mode-common-hook
;; (lambda ()
;; (flymake-mode)
;; (gccsense-flymake-setup)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;在退出后保存会话,启动时自动回复,包括输入命令等的历史
(require 'session)
(add-hook
'after-init-hook
'session-initialize)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; word operation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun zch-copy-word()
"复制光标所在处的单词" (interactive)
(setq old-
pos (point))
(forward-word)
(backward-word)
(setq pos1 (point))
(forward-word)
(setq pos2 (point))
(
kill-ring-save pos1 pos2)
(
goto-char old-
pos)
(message
"copy word %i %i" pos1 pos2))
(defun zch-copy-identifier()
"复制光标所在处的标识符" (interactive)
(setq old-
pos (point))
(c-beginning-of-current-token)
(setq pos1 (point))
(
goto-char (+ (point)
1))
(c-end-of-current-token)
(setq pos2 (point))
(
kill-ring-save pos1 pos2)
(
goto-char old-
pos)
(message
"copy identifier %i %i" pos1 pos2))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 自 定 义 快 捷 键
(global-set-key [(control *)]
'zch-copy-word)
(global-set-key [(meta *)] 'zch-copy-identifier)
;;(global-set-key [(control meta *)]
'zch-copy)
;;f1-f12的功能
(global-set-key [f1] 'switch-ecb-edit-window)
(global-set-key [f4]
'kill-this-buffer)
(global-set-key [f11] 'zch-fullscreen)
;;emacs选项
(global-set-key
"\C-cot" 'tool-bar-mode)
(global-set-key "\C-com" 'menu-bar-mode)
(global-set-key
"\C-cos" 'scroll-bar-mode)
;;插入文本
(global-set-key "\C-cic" 'insert-zch-copyright)
(global-set-key
"\C-cid" 'insert-date)
(global-set-key [C-tab] 'buffer-menu)
(global-set-key
"\M- " 'set-mark-command)
(global-set-key "\M-3" 'replace-string)
(global-set-key
"\M-#" 'replace-regexp)
(global-set-key "\C-xct" 'zch-onekey-compile-test)
(global-set-key
"\C-xco" 'zch-compile-run)
(global-set-key "\C-xcu" 'zch-compile-run-any)
(global-set-key
"\C-xcc" 'zch-onekey-compile)
(global-set-key "\C-xca" 'zch-compile-test-all)
(global-set-key
"\C-xcl" 'zch-compile-clean)
(global-set-key "\C-xcm" 'zch-modify-compile-command)
(global-set-key
"\C-xcw" 'zch-modify-compile-run-any-command)
(global-set-key "\C-xcj" 'sC-czch-compile-modify-test)
(global-set-key
"\C-xci" 'zch-compile-modify-test-args)
(global-set-key "\C-xce" 'zch-compile-exe-all)
(global-set-key
"\C-xcg" 'zch-compile-gccsense)
(global-set-key "\C-xch" 'sbw-switch-to-h)
(global-set-key
"\C-xcp" 'sbw-switch-to-cpp)
(global-set-key "\C-xcn" 'sbw-switch-to-ct)
(global-set-key [(meta h)]
'next-error)
(global-set-key "\C-cg" 'goto-line)
(global-set-key
"\C-ch" 'help-command)
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-
5]
'up-slightly)
(global-set-key "\C-cw3" 'split-window-horizontally3)
(global-set-key
"\C-cw6" 'split-window6)
(global-set-key "\C-cw5" 'split-window5)
(global-set-key
"\C-cwf" 'zch-fullscreen)
(global-set-key "\C-cwu" 'split-window5-and-fullscreen)
;;窗口切换
(global-set-key [(meta \.)]
'ac-complete-gccsense)
;;调试快捷键
(global-set-key [f5] 'zch-gdb-test-debug-or-go)
(global-set-key [S-f5]
'zch-gdb-kill)
(global-set-key [f6] 'gud-
next)
(global-set-key [C-f6]
'gud-until)
(global-set-key [S-f6] 'gud-jump)
(global-set-key [f7]
'gud-step)
(global-set-key [f8] 'gud-finish)
(global-set-key [f9]
'zch-gdb-break-remove)
(global-set-key "\C-cmw" 'zch-gdb-break-watch)
(global-set-key
"\C-cmr" 'zch-gdb-break-rwatch)
(global-set-key "\C-cma" 'zch-gdb-break-awatch)
(global-set-key [(control =)]
'gud-print)
(global-set-key [(control +)] 'gud-pstar)
(global-set-key [(meta =)]
'zch-gdb-print-dcptr)
(global-set-key [(meta +)] 'zch-gdb-pstar-dcptr)
(global-set-key [(control meta +)]
'zch-gdb-ptype)
(global-set-key [(meta \,)] 'zch-gdb-switch-window)
(global-set-key
"\C-xga" 'zch-gdb-assembler-buffer)
(global-set-key "\C-xgl" 'zch-gdb-locals-buffer)
(global-set-key
"\C-xgm" 'zch-gdb-memory-buffer)
(global-set-key "\C-xgr" 'zch-gdb-registers-buffer)
(global-set-key
"\C-xgt" 'zch-gdb-threads-buffer)
(global-set-key "\C-xgs" 'zch-gdb-stack-buffer)
(global-set-key
"\C-xgb" 'zch-gdb-breakpoints-buffer)
(global-set-key "\C-xgi" 'zch-gdb-inferior-io)
(global-set-key
"\C-xgp" 'zch-gdb-partial-output-buffer)
(global-set-key "\C-xgo" 'zch-gdb-
print-object)
(global-set-key
"\C-xgy" 'zch-gdb-ptype)
(global-set-key [(control meta shift mouse-1)] 'zch-gdb-ptype)
(global-set-key
"\C-xgk" 'zch-gdb-ptype-dcptr)
(global-set-key [(meta shift mouse-3)] 'zch-gdb-ptype-dcptr)
(global-set-key
"\C-xgw" 'gud-print)
(global-set-key [(control shift mouse-1)] 'gud-
print)
(global-set-key
"\C-xge" 'gud-pstar)
(global-set-key [(control shift mouse-3)] 'gud-pstar)
(global-set-key
"\C-xgd" 'zch-gdb-print-dcptr)
(global-set-key [(control meta mouse-1)] 'zch-gdb-
print-dcptr)
(global-set-key
"\C-xgh" 'zch-gdb-pstar-dcptr)
(global-set-key [(control meta mouse-3)] 'zch-gdb-pstar-dcptr)
(global-set-key
"\C-cbg" 'sbw-symbol-goto-on-cursor)
(global-set-key "\C-cbt" 'sbw-symbol-type-
goto-on-cursor)
(global-set-key
"\C-cbc" 'sbw-symbol-class-goto-on-cursor)
(global-set-key "\C-cbd" 'sbw-find-function-define-or-declare)
(global-set-key
"\C-cbp" 'sbw-print-point)
(global-set-key "\C-cbi" 'sbw-insert-function-define)
(global-set-key
"\C-cba" 'sbw-beginning-of-function)
(global-set-key "\C-cbs" 'sbw-get-syntactic-list)
(global-set-key
"\C-cbq" 'sbw-get-dir-of-file)
(global-set-key [(control \.)] 'zch-insert-pointer-access)
(global-set-key
"\C-cr" 'zch-revert-buffer)
(global-set-key "\C-c\C-r" 'zch-revert-buffer-all)
(global-set-key [(control \
#)] 'zch-replace-files-regexp)
(global-set-key [(control meta \
#)] 'zch-replace-files-regexp-r)
(global-set-key
"\C-c<" 'c-beginning-of-defun)
(global-set-key "\C-c>" 'c-end-of-defun)
(global-set-key
"\C-cmf" 'c-mark-function)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;heqinglong sets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'c++-mode-hook
(lambda ()
(define-key c-mode-base-
map (kbd
"C-c o")
'ff-find-other-file) )
'zch-cedet-hook)
(defun
my-c++-mode-hook ()
(setq tab-width
4)
;(define-key c++-mode-
map "\C-m" 'reindent-then-newline-and-indent)
;(define-key c++-mode-map "\C-ce" 'c-comment-edit)
(setq c++-
delete-function
'backward-delete-char)
(setq c++-tab-always-indent t)
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
(setq c++-empty-arglist-indent 4))
;;隐藏显示程序块
(add-hook 'c++-mode-hook
(lambda () (hs-minor-mode
1)))
(add-hook
'c++-mode-hook
'my-c++-mode-hook)
(display-
time)
;(add-to-list
'load-path "/usr/share/emacs/23.2/lisp/cedet/semantic")
;(require 'semantic)
;; Enable EDE (Project Management) features
(global-ede-mode
1)
;(semantic-load-enable-excessive-code-helpers)
;(semantic-load-enable-semantic-debugging-helpers)
;; Enable SRecode (Template management) minor-mode.
;(global-srecode-minor-mode
1)
(add-to-list
'ac-dictionary-directories "/usr/local/share/emacs/site-lisp/auto-complete")
(require 'auto-complete)
(
require 'auto-complete-config)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;无法使用的插件
;(require 'auto-complete-yasnippet)
;(
require 'auto-complete-c)
;(require 'auto-complete-etags)
;(
require 'auto-complete-extension)
;(require 'auto-complete-octave)
;(
require 'auto-complete-verilog)
;(require 'auto-complete+)
;(
require 'util)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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'
(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))
(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)))
(provide 'auto-complete-settings)
(ac-settings-4-cpp) ;unuseable
(setq inferior-lisp-program "/usr/bin/sbcl
") ;Lisp system
(add-to-list 'load-path "/usr/
local/share/emacs/site-lisp/lispbox-
0.7/slime-
20110205.092829/
") ;SLIME directory
(require 'slime)
(slime-setup)
;; 在行首 C-k 时,同时删除该行。
(setq-default kill-whole-line t)
;; 自动的在文件末增加一新行
(setq require-final-newline t)
;; 当光标在行尾上下移动的时候,始终保持在行尾。
(setq track-eol t)
;;设置usr/local/share/emacs键指向buffer开头,end键指向buffer结尾
(global-set-key [usr/local/share/emacs] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
;;可以显示所有目录以及文件
(setq speedbar-show-unknown-files t)
(global-set-key "\M-s
" 'speedbar)
(load-library "hideshow
")
(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'c++-mode-hook 'hs-minor-mode)
(add-hook 'java-mode-hook 'hs-minor-mode)
(add-hook 'perl-mode-hook 'hs-minor-mode)
(add-hook 'php-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
(defun my-c-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?` ?` _ "''")
(?\( ? _ " )
")
(?\[ ? _ " ]
")
(?{ \n > _ \n ?} >)))
(setq skeleton-pair t)
(local-set-key (kbd "(
") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{
") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "`
") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[
") 'skeleton-pair-insert-maybe))
(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
(add-hook 'c++-mode-hook 'my-c-mode-auto-pair)
;;输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
;=========================================================================
(setq semantic-load-turn-everything-on t)
;(add-hook 'semantic-init-hooks 'semantic-idle-completions-mode)
(semantic-add-system-include "/usr/
local/share/emacs/dev/dnc/include
" 'c++-mode)
;;配置Semantic的检索范围
(setq semanticdb-project-roots
(list
(expand-file-name "/
")))
;;设置semantic.cache路径
(setq semanticdb-default-save-directory "~/.emacs.d
")
(global-set-key [(meta \?)] 'hippie-expand)
;;M-/ 绑定到 hippie-expand
;;设置 hippie-expand 的补全方式。它是一个优先列表, hippie-expand 会优先使用表最前面的函数来补全。
(autoload 'senator-try-expand-semantic "senator
")
(setq hippie-expand-try-functions-list
'(senator-try-expand-semantic ;优先调用了senator的分析结果
try-expand-dabbrev ;当前的buffer补全
try-expand-dabbrev-visible ;别的可见的窗口里寻找补全
try-expand-dabbrev-all-buffers ;所有打开的buffer
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))
(global-set-key [(control \`)] 'align-regexp)
(add-to-list 'load-path "/usr/
local/share/emacs/site-lisp/
")
(require 'yasnippet-bundle)
(global-set-key [(backtab)] 'semantic-ia-complete-symbol-menu)
(add-to-list 'load-path "/usr/
local/share/emacs/site-lisp/cscope-
15.7/contrib/xcscope
")
(require 'xcscope)
;;
;;;;cscope查找设置C
;;c-c s c-h 查看所有的cscope相关的按键
(global-set-key "\C-csA
" 'cscope-unset-initial-directory)
(global-set-key "\C-csB
" 'cscope-display-buffer-toggle)
(global-set-key "\C-csC
" 'cscope-find-called-functions)
(global-set-key "\C-csD
" 'cscope-dired-directory)
(global-set-key "\C-csE
" 'cscope-edit-list-of-files-to-index)
(global-set-key "\C-csG
" 'cscope-find-global-definition-no-prompting)
(global-set-key "\C-csI
" 'cscope-index-files)
(global-set-key "\C-csL
" 'cscope-create-list-of-files-to-index)
(global-set-key "\C-csN
" 'cscope-next-file)
(global-set-key "\C-csP
" 'cscope-prev-file)
(global-set-key "\C-csS
" 'cscope-tell-user-about-directory)
(global-set-key "\C-csT
" 'cscope-tell-user-about-directory)
(global-set-key "\C-csW
" 'cscope-tell-user-about-directory)
(global-set-key "\C-csa
" 'cscope-set-initial-directory)
(global-set-key "\C-csb
" 'cscope-display-buffer)
(global-set-key "\C-csc
" 'cscope-find-functions-calling-this-function)
(global-set-key "\C-csd
" 'cscope-find-global-definition)
(global-set-key "\C-cse
" 'cscope-find-egrep-pattern)
(global-set-key "\C-csf
" 'cscope-find-this-file)
(global-set-key "\C-csg
" 'cscope-find-global-definition)
(global-set-key "\C-csi
" 'cscope-find-files-including-file)
(global-set-key "\C-csn
" 'cscope-next-symbol)
(global-set-key "\C-csp
" 'cscope-prev-symbol)
;;能把一个代码块缩起来,需要的时候再展开
;; M-x hs-minor-mode
;; C-c @ a s show all
;; C-c @ a h hide all
(global-set-key "\C-c
@a\C-h
" 'hs-hide-all)
(global-set-key "\C-c
@a\C-s
" 'hs-show-all)
;; C-c @ s show block
;; C-c @ h hide block
;; C-c @ c toggle hide/show
(global-set-key [f12] 'serial-term);迷你终端
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; general
;;去掉工具条和菜单条,都可以使用快捷键进行操作,没有它们存在的必要
(tool-bar-mode)
(menu-bar-mode)
(scroll-bar-mode)
;;鼠标滚轮,默认的滚动太快,这里设为3行
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
;;当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))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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)
'(ecb-expand-methods-switch-off-auto-expand t)
'(ecb-options-version "2.40")
'(gdb-max-frames 60)
'(show-paren-mode t)
'(transient-mark-mode t))
(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.
)