武装了下emacs

来源:互联网 发布:广州蜜蜂软件 编辑:程序博客网 时间:2024/04/30 22:44

1.Tabbar(标签式的浏览):http://sourceforge.net/project/showfiles.php?group_id=79309&package_id=81110

下载后的el文件放在emacs的库的加载路径下,我放在emacs的安装目录的site-lisp下,因为那里文件较少。

然后在配置文件(_emacs.el.emacs.d/init.el中添加)

;; tabbar

(require 'tabbar)

(tabbar-mode t)

(global-set-key (kbd "M--") 'tabbar-backward-group)

(global-set-key (kbd "M-=") 'tabbar-forward-group)

(global-set-key (kbd "M-1") 'tabbar-backward)

(global-set-key (kbd "M-2") 'tabbar-forward) 

2.php-mod:http://sourceforge.net/projects/php-mode/

;;_+ php-mode
(require 'php-mode)
(define-key php-mode-map
     [menu-bar php php-debug]
     '("PHP Debug" . php-debug))
(define-key php-mode-map
     [menu-bar php php-run]
     '("Run PHP" . php-run))
(defun php-debug ()
    (interactive)
    (shell-command
     (concat "E:/AppServ/php5/php.exe -l /"" (buffer-file-name) "/"")))
(defun php-run ()
     (interactive)
     (shell-command
      (concat "E:/AppServ/php5/php.exe -q /"" (buffer-file-name) "/"")))
(defun my-php-mode()
   ;; 将回车代替C-j的功能,换行的同时对齐
     (define-key php-mode-map [return] 'newline-and-indent)
     (define-key php-mode-map [(control c) (r)] 'php-run)
     (define-key php-mode-map [(control c) (d)] 'php-debug)
     (interactive)
   ;; 设置php程序的对齐风格
     (c-set-style "K&R")
   ;; 自动模式,在此种模式下当你键入{时,会自动根据你设置的对齐风格对齐
     (c-toggle-auto-state)
   ;; 此模式下,当按Backspace时会删除最多的空格
     (c-toggle-hungry-state)
   ;; TAB键的宽度设置为4
     (setq c-basic-offset 4)
   ;; 在菜单中加入当前Buffer的函数索引
     (imenu-add-menubar-index)
   ;; 在状态条上显示当前光标在哪个函数体内部
     (which-function-mode)
     )
(add-hook 'php-mode-hook 'my-php-mode)

3.emacs mod for gdb:

主页:http://www.inet.net.nz/~nickrob/

教程:http://www.linuxjournal.com/article/7876

目前的emacs配置如下:

(tool-bar-mode -1);去除工具栏
;
;中文字体设置
(setq w32-charset-info-alist
(cons '(
"gbk" w32-charset-gb2312 . 936) w32-charset-info-alist))

(setq default-frame-alist
(append
'((font . 
"fontset-gbk")) default-frame-alist))

(create-fontset-from-fontset-spec
"-outline-Courier New-normal-r-normal-normal-13-97-96-96-c-*-fontset-gbk")
(set-fontset-font
"fontset-default" nil
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'kana
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'han
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'cjk-misc
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'symbol
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-default-font 
"fontset-gbk"

;;关闭emacs启动时的画面
(setq inhibit-startup-message t)
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线。
(setq mouse-avoidance-mode 'animate)
;; 在行首 C-k 时,同时删除该行。
(setq-default kill-whole-line t)
;; 当光标在行尾上下移动的时候,始终保持在行尾。
(setq track-eol t)


;;设置缺省模式是text,而不是基本模式
(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill) 
;;开启语法高亮。
(global-font-lock-mode 1)
(setq default-directory 
"~/mp/";;设置初始目录
;
; 配色方案
(setq default-frame-alist
'(
   (foreground-color . 
"Wheat")
   (background-color . 
"DarkSlateGray")
   (cursor-color     . 
"Orchid")
  )
)
;; Treat 'y' or <CR> as yes, 'n' as no.--------------------------------------
(fset 'yes-or-no-p 'y-or-n-p)
(define-key query-replace-map 
[return] 'act)
(define-key query-replace-map 
[?C-m] 'act)
(defun copy-line (&optional arg)
 
"Save current line into Kill-Ring without mark the line"
 (interactive 
"P")
 (let ((beg (line-beginning-position)) 
    (end (line-end-position arg)))
 (copy-region-as-kill beg end))
)

(defun copy-word (&optional arg)
 
"Copy words at point"
 (interactive 
"P")
 (let ((beg (progn (if (looking-back 
"[a-zA-Z0-9]" 1) (backward-word 1)) (point))) 
    (end (progn (forward-word arg) (point))))
 (copy-region-as-kill beg end))
)

(defun copy-paragraph (&optional arg)
 
"Copy paragraphes at point"
 (interactive 
"P")
 (let ((beg (progn (backward-paragraph 
1) (point))) 
    (end (progn (forward-paragraph arg) (point))))
 (copy-region-as-kill beg end))
)

;; 所有的备份文件转移到~/backups目录下
(setq backup-directory-alist (quote (("." . "~/backups"))))
(setq version-control t)
(setq kept-old-versions 
2)
(setq kept-new-versions 
5)
(setq delete-old-versions t)
(setq backup-directory-alist '((
"." . "~/backups")))
(setq backup-by-copying t)
;;------------------------------------------------------------------
;
;;;根据后缀判断所用的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)
  
;; 在菜单中加入当前Buffer的函数索引
  (imenu-add-menubar-index)
  
;; 在状态条上显示当前光标在哪个函数体内部
  (which-function-mode)
  
;;按键定义
  (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 
[(f5)] 'compile)
  (define-key c-mode-base-map 
[(f8)] 'ff-get-other-file)
  (define-key c-mode-base-map 
[(f9)] 'gdb)
  (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)

;; tabbar------------------------
(require 'tabbar)
(tabbar-mode t)
(global-set-key (kbd 
"M--") 'tabbar-backward-group)
(global-set-key (kbd 
"M-=") 'tabbar-forward-group)
(global-set-key (kbd 
"M-1") 'tabbar-backward)
(global-set-key (kbd 
"M-2") 'tabbar-forward) 

;;phpmod
;
;_+ php-mode
(require 'php-mode)
(define-key php-mode-map
     
[menu-bar php php-debug]
     '(
"PHP Debug" . php-debug))
(define-key php-mode-map
     
[menu-bar php php-run]
     '(
"Run PHP" . php-run))
(defun php-debug ()
    (interactive)
    (shell-command
     (concat 
"E:/AppServ/php5/php.exe -l "" (buffer-file-name) """)))
(defun php-run ()
     (interactive)
     (shell-command
      (concat 
"E:/AppServ/php5/php.exe -q "" (buffer-file-name) """)))
(defun my-php-mode()
   
;; 将回车代替C-j的功能,换行的同时对齐
     (define-key php-mode-map [return] 'newline-and-indent)
     (define-key php-mode-map 
[(control c) (r)] 'php-run)
     (define-key php-mode-map 
[(control c) (d)] 'php-debug)
     (interactive)
   
;; 设置php程序的对齐风格
     (c-set-style "K&R")
   
;; 自动模式,在此种模式下当你键入{时,会自动根据你设置的对齐风格对齐
     (c-toggle-auto-state)
   
;; 此模式下,当按Backspace时会删除最多的空格
     (c-toggle-hungry-state)
   
;; TAB键的宽度设置为4
     (setq c-basic-offset 4)
   
;; 在菜单中加入当前Buffer的函数索引
     (imenu-add-menubar-index)
   
;; 在状态条上显示当前光标在哪个函数体内部
     (which-function-mode)
     )
(add-hook 'php-mode-hook 'my-php-mode)
;;------------------gdb-many-window,use M-x gdb-----
;
;http://www.inet.net.nz/~nickrob/
(setq gdb-many-windows t)
(load-library 
"multi-gud.el")
(load-library 
"multi-gdb-ui.el")
;;session--http://docs.huihoo.com/homepage/shredderyin/emacs_elisp.html
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
;;desktop associate to session--M-x desktop-save
(load "desktop"
(desktop-load-default) 
(desktop-read)