首页

2010年5月29日星期六

我的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)
'(display-time-mode t)
'(show-paren-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.
)

;(setq visible-bell t);关闭出错提示声
(setq inhibit-startup-message t);关闭开启画面
(setq column-number-mode t);
;------------------------------- 设置界面-------------------------------
(set-cursor-color "Wheat")
(set-mouse-color "Wheat")
(set-foreground-color "Wheat")
(set-background-color "DarkSlateGray")
(if window-system
(setq default-frame-alist
(append
'( (top . 100)
(left . 100)                            
(width . 150)
(height . 50))
default-frame-alist))
)
;-----------------------------end of 设置界面--------------------------

;------------------------------- 设置显示时间---------------------------
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
;--------------------------------endof 设置显示时间---------------------

;-------------------------------快捷键---------------------------------
; (define-key [(f7)] 'compile)
;;;;以下是我的快捷键设置

(global-set-key [(meta g)] 'goto-line)
;;(global-set-key [(meta ?/)] 'hippie-expand)

;; F12 t 从当前缓冲区建立任务
(global-set-key (kbd " t") 'planner-create-task-from-buffer)
;; F12 g 切换到当日的任务
;;(global-set-key (kbd " g") 'planner-goto-today)
(global-set-key (kbd " g") 'planner-goto-today)
(global-set-key (kbd " p") 'plan)
;; F12 r 添加当前备忘录
(global-set-key (kbd " r") 'remember)
;; F12 c 切换到日历
(global-set-key (kbd " c") 'calendar)

;;;F2:进入wiki-mode模式
;;(global-set-key [(f2)] 'emacs-wiki-find-file)

;;;F3:切换到dired模式
;;(global-set-key [(f3)] 'dired)

;;;F4:切换到shell模式
;;(global-set-key [(f4)] 'ansi-term)


;;;F5:打开speedbar
(global-set-key [(f5)] 'speedbar)

;;;;F7:调用compile
;;(global-set-key (kbd "") 'compile)

;;;Alt+s : 让speedbar获得焦点
(global-set-key (kbd "M-s") 'speedbar-get-focus)

;;;F9:列举我的书签
(global-set-key (kbd "") 'list-bookmarks)

;;;F10:添加当前页到书签中
(global-set-key [(f10)] 'bookmark-set)

;;;F12 u 更新当前版本
(global-set-key (kbd " u") 'vc-next-action)

;;------------------------End of 快捷键 ---------------------


;(setq kill-ring-max 200);; 设置粘贴缓冲条目数量
(setq enable-recursive-minibuffers t);; 设置递归使用minibuffer
;;(setq scroll-margin 3
;;      scroll-conservatively 10000) ;;防止页面滚动时跳动
(setq default-major-mode 'text-mode);;设置默认模式是text mode
(show-paren-mode t)
(setq show-paren-style 'parentheses) ;; 设置显示括号匹配,但不跳转
(mouse-avoidance-mode 'animate) ;;让鼠标不要挡住光标



;------------------------------程序语言--------------------------------
;;;; CC-mode配置 http://cc-mode.sourceforge.net/
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)

;;;;根据后缀判断所用的mode
;;;;注意:我在这里把.h关联到了c++-mode
(setq auto-mode-alist
(append '(("\\.h$" . c++-mode)) auto-mode-alist))


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

(defun my-c-mode-common-hook()
(setq tab-width 4 indent-tabs-mode nil)
;;; hungry-delete and auto-newline
(c-toggle-auto-hungry-state 1)
;;按键定义
(define-key c-mode-base-map [(control \`)] 'hs-toggle-hiding)
(define-key c-mode-base-map [(return)] 'newline-and-indent)
(define-key c-mode-base-map [(f7)] 'compile)
(define-key c-mode-base-map [(f8)] 'ff-get-other-file)
(define-key c-mode-base-map [(meta \`)] 'c-indent-command)
;; (define-key c-mode-base-map [(tab)] 'hippie-expand)
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;预处理设置
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "cpp")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq hs-minor-mode t)
(setq abbrev-mode t)
(setq tab-width 4 indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;;;;我的C++语言编辑策略
(defun my-c++-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
(c-set-style "stroustrup")
(define-key c++-mode-map [f3] 'replace-regexp)
)

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

;;;;C/C++语言启动时自动加载semantic对/usr/include的索引数据库
(setq semanticdb-search-system-databases t)
(add-hook 'c-mode-common-hook
(lambda ()
(setq semanticdb-project-system-databases
(list (semanticdb-create-database
semanticdb-new-database-class
"/usr/include")))))
;;;;我的Java语言编辑策略
(defun my-java-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
)

(add-hook 'java-mode-hook 'my-java-mode-hook)


(setq ansi-color-for-comint-mode t)
(customize-group 'ansi-colors)
(kill-this-buffer);关闭customize窗口


;自定义按键


(global-set-key [f8] 'other-window);F8窗口间跳转
(global-set-key [C-return] 'kill-this-buffer);C-return关闭当前buffer
(global-set-key [f10] 'split-window-vertically);F10分割窗口
(global-set-key [f11] 'delete-other-windows);F11 关闭其它窗口
(global-set-key [f1] 'my-fullscreen);F1 全屏
(global-set-key (kbd "C-.") 'backward-page);文件首
(global-set-key (kbd "C-/") 'forward-page);文件尾


;普通设置


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

(global-font-lock-mode t);语法高亮
(auto-image-file-mode t);打开图片显示功能
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
(column-number-mode t);显示列号
(show-paren-mode t);显示括号匹配

(tool-bar-mode nil);去掉那个大大的工具栏
(scroll-bar-mode nil);去掉滚动条
;(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开
(setq mouse-yank-at-point t);支持中键粘贴
(transient-mark-mode t);允许临时设置标记
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(setq frame-title-format '("" buffer-file-name "@emacs" ));在标题栏显示buffer名称
(setq default-fill-column 80);默认显示 80列就换行


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


(global-set-key [f11] 'my-fullscreen) ;; 启动全屏的快捷键
;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C/C++设定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;缩进策略
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "\\>")
(hippie-expand nil)
(indent-for-tab-command)))
;补全优先级
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(
senator-try-expand-sematic
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))

(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)

(add-hook 'semantic-init-hooks 'semantic-idle-completions-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)
(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 auto-save-default nil);不生成名为#filename# 的临时文件
(require 'linum)
(global-linum-mode t)

没有评论:

发表评论