免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1562 | 回复: 0
打印 上一主题 下一主题

emacs配置2 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-03 14:42 |只看该作者 |倒序浏览
;; Function to copy lines
;; "C-c w" copy one line, "C-u 5 C-c w" copy 5 lines
(defun copy-lines(&optional arg)
(interactive "p")
(save-excursion
(beginning-of-line)
(set-mark (point))
(if arg
(next-line (- arg 1)))
(end-of-line)
(kill-ring-save (mark) (point))
)
)
;; set key
(global-set-key (kbd "C-c w") 'copy-lines)
(require 'cedet) ;;加载cedet
(require 'ecb) ;;加载ecb
(require 'xcscope)
(require 'ecb) ;;加载ecb
(require 'session) ;;加载session
(add-hook 'after-init-hook 'session-initialize) ;; 启动时初始化session
(require 'doxymacs) ;; 启动doxymacs
(add-hook 'c-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode
(add-hook 'c++-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode
(desktop-load-default) ;;读取默认desktop设置
(desktop-read) ;;读取当前目录保存的desktop设置
(set-face-background 'default "LightCyan3") ;;设置背景色为 浅青色3
(set-face-font 'default "-outline-新宋体-normal-r-normal-normal-*-*-96-96-c-*-iso8859-1") ;;设置字体为新宋体 ( Only for windows )
;(global-set-key [f12] 'ecb-activate) ;;定义F12键为激活ecb
;(global-set-key [C-f12] 'ecb-deactivate) ;;定义Ctrl+F12为停止ecb
;(global-set-key [f11] 'delete-other-windows) ;;设置F11为删除其它窗口
;;(global-set-key [(meta return)] 'semantic-ia-complete-symbol-menu) ;;设置Alt+Enter为自动补全菜单
;(global-set-key [C-\;] 'ecb-goto-window-edit-last) ;;切换到编辑窗口
;(global-set-key [C-\'] 'ecb-goto-window-methods) ;;切换到函数窗口
;(global-set-key [C-.] 'cscope-find-global-definition) ;;搜索定义
;(global-set-key [C-,] 'cscope-pop-mark) ;; 跳出转向
;(enable-visual-studio-bookmarks) ;; 启动VS书签子程序
;;(setq semanticdb-project-roots (list "d:/work")) ;; 设置cemanticdb的扫描根目录
;(add-hook 'c-mode-common-hook ( lambda() ( c-set-style "k&r" ) ) ) ;;设置C语言默认格式
;(add-hook 'c++-mode-common-hook ( lambda() ( c-set-style "k&r" ) ) ) ;;设置C++语言默认格式
(setq initial-frame-alist '((top . 0) (left . 0) (width . 120) (height . 44)))
;; 全局键的设置
(global-set-key [(meta g)] 'goto-line);; 定位到行
;; F12 c 切换到日历
(global-set-key (kbd " c") 'calendar)
;;;F3:切换到dired模式c
(global-set-key [(f3)] 'dired)
;;;F4:切换到shell模式
;(global-set-key [(f4)] 'ansi-term)
;;;F5:打开speedbar
(global-set-key [(f5)] 'speedbar)
;;;F9:列举我的书签
(global-set-key (kbd "") 'list-bookmarks)
;;;F10:添加当前页到书签中
(global-set-key [(f10)] 'bookmark-set)

;;;; 关闭启动画面
(setq inhibit-startup-message t)
(global-set-key (kbd "C-x C-b") 'ibuffer)
;;时间戳设置(time-stamp),设定文档上次保存的信息
;;只要里在你得文档里有Time-stamp:的设置,就会自动保存时间戳
;;启用time-stamp
(setq time-stamp-active t)
;;去掉time-stamp的警告?
(setq time-stamp-warn-inactive t)
;;设置time-stamp的格式,我如下的格式所得的一个例子:
(setq time-stamp-format "%:u %02m/%02d/%04y %02H02M02S")
;;将修改时间戳添加到保存文件的动作里。
(add-hook 'write-file-hooks 'time-stamp)
;;时间显示设置
;;启用时间显示设置,在minibuffer上面的那个杠上(忘了叫什么来着)
(display-time-mode 1)
;;时间使用24小时制
(setq display-time-24hr-format t)
;;时间显示包括日期和具体时间
(setq display-time-day-and-date t)
;;时间栏旁边启用邮件设置
(setq display-time-use-mail-icon t)
;;时间的变化频率,单位多少来着?
(setq display-time-interval 10)

;;所有的问题用y/n方式,不用yes/no方式。有点懒,只想输入一个字母
(fset 'yes-or-no-p 'y-or-n-p)
;;当指针到一个括号时,自动显示所匹配的另一个括号
(show-paren-mode 1)
;;滚动页面时比较舒服,不要整页的滚动
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000)
;;启动Emacs自动设置为两个窗口(上下各一个)
(split-window-vertically)
;;改变emacs标题栏的标题
;;设置备份文件的路径
(setq backup-directory-alist '(("./backup" . "~/.emacs.tmp")))
;;备份设置方法,直接拷贝
(setq backup-by-copying t)
;;设置我所在地方的经纬度,calendar里有个功能是日月食的预测,和你的经纬度相联系的。
(setq calendar-latitude +39.9)
(setq calendar-longitude +116.4)
;;我的所在地北京,欢迎大家来找北京请我吃饭
(setq calendar-location-name "Beijing")
;;在minibuffer上面可以显示列号
(column-number-mode t)
;;设定一些自定义的生日和节日
;;隐私需要,删掉朋友的生日
;;后面那些农历节日需要每年根据日历修改
;;有些可惜,没有中国传统农历,谁能写个扩展elisp包弄一下
(setq general-holidays '((holiday-fixed 1 1 "元旦")
(holiday-fixed 3 8 "妇女节")
(holiday-fixed 4 1 "愚人节")
(holiday-fixed 4 11 "谁的生日")
(holiday-fixed 5 1 "劳动节")
(holiday-fixed 10 1 "国庆节")
(holiday-fixed 12 25 "圣诞节")
(holiday-fixed 2 5 "元宵节")
(holiday-fixed 4 4 "清明节")
(holiday-fixed 4 21 "鬼节")
(holiday-fixed 6 22 "端午节")
(holiday-fixed 9 28 "中秋节")
(holiday-float 5 0 2 "母亲节")
(holiday-float 6 0 3 "父亲节")
))
;;在日历中突出标记节日和生日
(setq mark-holidays-in-calendar t)
;;打开calendar自动打开节日和生日列表
(setq view-calendar-holidays-initially t)
;;窗口设置
(gnus-add-configuration '(article (vertical 1.0 (summary .35 point) (article 1.0))))
;;Group Buffer设置, 自动进入Topic-mode
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
;;Sumarry Buffer设置
(setq gnus-summary-line-format ":%U%R %B %s %-60=|%4L |%-20,20f |%&user-date; \n")
;;常用习惯,F1打开帮助,常用帮助有info和woman(就是在emacs中看man)
(global-set-key [f1] 'info)
;;恢复,常用键
(global-set-key [control z] 'undo)
;;F4,kill键,习惯设置,关闭当前buffer
;(global-set-key [C-f4] 'kill-this-buffer)
;(global-set-key (kbd " k") 'calendar)
;;文件管理器,常用
;(global-set-key [f6] 'dired-jump)
(add-to-list 'load-path "~/.thumbs.el")
(autoload 'thumbs "thumbs" "Preview images in a directory." t)
; 以不提示的方式找到光标所在符号的定义
(define-key global-map [f7] 'cscope-find-global-definition-no-prompting)
; 返回调用此函数的上级处
(define-key global-map [f6] 'cscope-pop-mark)
; 以提示方式搜索符号被定义的地方
(define-key global-map [(control f7)] 'cscope-find-global-definition)
; 搜索指定符号被引用的地方
(define-key global-map [(control /)] 'cscope-find-this-symbol)
; 定位到上一个引用处
(define-key global-map [M-up] 'cscope-prev-symbol)
; 定位到下一个引用处
(define-key global-map [M-down] 'cscope-next-symbol)
; 查找指定文件
(define-key global-map [(control f1)] 'cscope-find-this-file)
; 搜索包含指定文件的文件列表
(define-key global-map [(control i)] 'cscope-find-files-including-file)
; 搜索字符串
(define-key global-map [(control t)] 'cscope-find-this-text-string)
; 显示搜索结果列表
(define-key global-map [(control f9)] 'cscope-display-buffer)
(define-key global-map [(control f2)] 'cscope-find-functions-calling-this-function)
;(define-key global-map [(control f10)] 'cscope-display-buffer-toggle)
(define-key global-map [f12] 'c-down-conditional-with-else)
(define-key global-map [M-f12] 'c-up-conditional-with-else)
(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.
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2)))
(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.
)


;;;; CC-mode配置  
http://cc-mode.sourceforge.net/
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;;;我的C/C++语言编辑策略
(defun my-c-mode-common-hook()
  (setq tab-width 4 indent-tabs-mode nil)
  ;;; hungry-delete and auto-newline
  (c-toggle-auto-hungry-state 1)
  ;;按键定义
  (define-key c-mode-base-map [(control \`)] 'hs-toggle-hiding)
  (define-key c-mode-base-map [(return)] 'newline-and-indent)
;;  (define-key c-mode-base-map [(f7)] 'compile)
  (define-key c-mode-base-map [(meta \`)] 'c-indent-command)
;;  (define-key c-mode-base-map [(tab)] 'hippie-expand)
  (define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
  (define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;预处理设置
  (setq c-macro-shrink-window-flag t)
  (setq c-macro-preprocessor "cpp")
  (setq c-macro-cppflags " ")
  (setq c-macro-prompt-flag t)
  (setq hs-minor-mode t)
  (setq abbrev-mode t)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;;;;我的C++语言编辑策略
(defun my-c++-mode-hook()
  (setq tab-width 4 indent-tabs-mode nil)
  (c-set-style "stroustrup")
;;  (define-key c++-mode-map [f3] 'replace-regexp)
)

;配置Semantic的检索范围:
(setq semanticdb-project-roots
   (list
        (expand-file-name "/")))
;自定义自动补齐命令,这部分是抄hhuu的,如果在单词中间就补齐,否则就是tab。
(defun my-indent-or-complete ()
   (interactive)
   (if (looking-at "\\>")
    (hippie-expand nil)
    (indent-for-tab-command))
)
(global-set-key [(control tab)] 'my-indent-or-complete)
;;hippie的自动补齐策略,优先调用了senator的分析结果:
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
    '(
  senator-try-expand-semantic
  try-expand-dabbrev
  try-expand-dabbrev-visible
  try-expand-dabbrev-all-buffers
  try-expand-dabbrev-from-kill
  try-expand-list
  try-expand-list-all-buffers
  try-expand-line
        try-expand-line-all-buffers
        try-complete-file-name-partially
        try-complete-file-name
        try-expand-whole-kill
        )
    )
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)-menu)


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/109300/showart_2170198.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP