Main / Emacs / Programes

<< Emacs | Programes | Gnus >>

Updated: 2007-08-25-13:30:42

配置适合写代码的环境

  用Emacs来写代码是最重要的,我最近简化了许多配置,比如去掉ecb,cedet,jde等大家伙

但下面的配置,你仍需要下载php-mode.el,除非你不写PHP :),hanking过的php-mode.el

 

(defun my-c-mode()
   ;; 将回车代替C-j的功能,换行的同时对齐
    (define-key c-mode-map [return] 'newline-and-indent)
    (interactive)
   ;; 设置程序的对齐风格
    (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)
    ;; load global
    ;;(gtags-mode 1)
    ;;(gtags-make-complete-list)
    )
(add-hook 'c-mode-hook 'my-c-mode)

;;_+ cpp-mode
(defun my-cpp-mode()
   ;; 将回车代替C-j的功能,换行的同时对齐
    (define-key c++-mode-map [return] 'newline-and-indent)
    (interactive)
   ;; 设置程序的对齐风格
    (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)
    ;; load global
    ;;(gtags-mode 1)
    ;;(gtags-make-complete-list)
    )
(add-hook 'c++-mode-hook 'my-cpp-mode)

;;_+ java-mode
(defun my-java-mode()
   ;; 将回车代替C-j的功能,换行的同时对齐
    (define-key java-mode-map [return] 'newline-and-indent)
    (interactive)
   ;; 设置程序的对齐风格
    (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)
    ;; load global
    ;;(gtags-mode 1)
    ;;(gtags-make-complete-list)
    )
(add-hook 'java-mode-hook 'my-java-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 "D:/mysoft/php5/php.exe -l \"" (buffer-file-name) "\"")))
(defun php-run ()
    (interactive)
    (shell-command
     (concat "D:/mysoft/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)

 

 

 

更多链接

Tags 用法
用Emacs-Jde编写Java
编辑 C/C++ 程序
GDB 的使用
编辑 PHP 程序
RCS, CVS, Subversion 等源码管理工具的控制
CVS 的图形界面
使用模板Template自动生成程序框架
使得emacs和doxygen产生的文档进行交互