Chinaunix首页 | 论坛 | 博客
  • 博客访问: 23948
  • 博文数量: 19
  • 博客积分: 1445
  • 博客等级: 上尉
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-30 10:52
文章分类

全部博文(19)

文章存档

2011年(1)

2009年(18)

我的朋友
最近访客

分类: LINUX

2009-10-30 11:16:58

;;设置一个读取插件的默认路径
(add-to-list 'load-path "/home/crazybaby/.emacs.d")


;; (load-file "/usr/local/emacs23/site-lisp/cedet-1.0pre3/common/cedet.el")
;; (semantic-load-enable-code-helpers)

;;(add-to-list 'load-path "/usr/local/emacs23/site-lisp/contrib/xcscope")
;;(require 'xcscope)

;;  (add-to-list 'load-path "/usr/local/emacs23/site-lisp/ecb_2.32")

;;(require 'ecb)

;;;;Python-Mode
#!lisp (-)
(setq load-path (cons "c:/emacs/python_mode" load-path))
(setq auto-mode-alist
      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("python" . python-mode)
            interpreter-mode-alist))
;;(setq python-mode-hook
;;      '(lambda() (progn
;;                 (set-variable 'py-indent-offset 4)
;;                 (set-variable 'py-smart-indentation nil)
;;                 (set-variable 'indent-tabs-mode nil) )))
(defconst py-python-command "c:/python24/python.exe")
(autoload 'python-mode "python-mode" "Python editing mode." t)
;;---------------------------------------------
;; add my customization
(add-hook 'python-mode-hook 'my-python-hook)
;; this gets called by outline to deteremine the level. Just use the length of the whitespace
(defun py-outline-level ()
  (let (buffer-invisibility-spec)
    (save-excursion
      (skip-chars-forward "\t ")
      (current-column))))
;; this get called after python mode is enabled
(defun my-python-hook ()
  ;; outline uses this regexp to find headers. I match lines with no indent and indented "class"
  ;; and "def" lines.
  (setq outline-regexp "[^ \t]\\|[ \t]*\\(def\\|class\\) ")
  ;; enable our level computation
  (setq outline-level 'py-outline-level)
  ;; do not use their \C-c@ prefix, too hard to type. Note this overides some python mode bindings
  (setq outline-minor-mode-prefix "\C-c")
  ;; turn on outline mode
  (outline-minor-mode t)
  ;; initially hide all but the headers
  (hide-body)
  ;; I use CUA mode on the PC so I rebind these to make the more accessible
  (local-set-key [?\C-\t] 'py-shift-region-right)
  (local-set-key [?\C-\S-\t] 'py-shift-region-left)
  ;; make paren matches visible
  (show-paren-mode 1)
)

;;----------------------------------
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "English")
 '(default-input-method "latin-1-prefix")
 '(global-font-lock-mode t nil (font-lock)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )

;;;

;;注释 M-; 或者c-c c-c都可以
(defun huangq-comment-dwim (&optional n)
  "Comment do-what-i-mean"
  (interactive "p")
  (apply 'comment-or-uncomment-region
         (if (and mark-active transient-mark-mode)
             (list (region-beginning) (region-end))
           (if (> n 0)
               (list (line-beginning-position) (line-end-position n))
             (list (line-beginning-position n) (line-end-position))))))

;;选择一个颜色主题
(require 'color-theme)
(color-theme-kingsajz)

;;关闭启动时开机画面
(setq inbibit-startup-message t)

;;C-W M-W
(defadvice kill-ring-save (before slickcopy activate compile)
"When called interactively with no active region, copy a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))

 (defadvice kill-region (before slickcut activate compile)
 "When called interactively with no active region, kill a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))

;;块选择
(global-set-key (kbd "C-x ") 'set-mark-command)
;;字体设置

;;行号
(require 'linum)
(global-linum-mode t)

;;鼠标靠近时自动离开
(mouse-avoidance-mode 'animate)

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

;;用shift方向进行选择
(pc-selection-mode)

(global-set-key [f11] 'delete-other-windows) ;;设置F11为删除其它窗口

;;设置括号配对功能
(show-paren-mode t)
(setq show-paren-style 'parentheses)

;;字体设置
(set-default-font "-bitstream-bitstream vera sans mono-medium-r-normal--15-0-0-0-m-0-iso8859-1")
;;查找\打开文件时,列出文件列表 C-X C-F打开
(require 'ido)
(ido-mode t)

;;设置文件的标题栏 显示在emc上面
(require 'tabbar)
(tabbar-mode)

;;标题栏切换的快捷键
(global-set-key [M-up] 'tabbar-backward-group)
(global-set-key [M-down] 'tabbar-forward-group)
(global-set-key [M-left] 'tabbar-backward)
(global-set-key [M-right] 'tabbar-forward)

;;加载了 session 之后菜单上会多两项:最近访问过的文件和最近修改过的文件
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
;;保存上次打开的文件记录
;;如果session跟desktop配合,下次启动Emacs 的时候,就像根本没有关闭 Emacs 一样
(load "desktop")
(desktop-load-default)
(desktop-read)


;;C-x C-b 那个普通的 buffer menu 换成非常方便的 ibuffer 啦
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)



(setq gdb-many-windows t)
;;...
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")


;;设置快捷键
(global-set-key [f3] 'goto-line)
(global-set-key [f4] 'speedbar)
(global-set-key [f5] 'compile)
(global-set-key [f6] 'gdb)
(global-set-key [f7] 'bookmark-set)
(global-set-key [f8] 'bookmark-jump)
(global-set-key [f9] 'cvs-update)
(global-set-key [f10] 'python-mode)
;;定义F12键为激活ecb
(global-set-key [f12] 'ecb-activate)

(global-set-key [(control tab)] 'switch-to-buffer)

(global-set-key (kbd "M-]") 'comment-dwim)
(global-set-key [delete] 'delete-region)
(global-set-key "%" 'match-paren)
         
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
    ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
    (t (self-insert-command (or arg 1)))))
(global-set-key "%" 'match-paren)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;C/C++
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(global-set-key [(meta return)] 'semantic-ia-complete-symbol-menu) ;;设置Alt+Enter为自动补全菜单

(defun linux-cpp-mode ()
"my cpp mode define"
(interactive)
(c-set-style "K&R")
(setq c-basic-offset 4)
(c-toggle-hungry-state)
;(c-toggle-auto-state)
(define-key c++-mode-map [return] 'newline-and-indent)
)
   
     


(add-hook 'c-mode-hook 'linux-c-mode)
(add-hook 'c++-mode-hook 'linux-cpp-mode)
;; 设置imenu的排序方式为按名称排序
(setq imenu-sort-function 'imenu--sort-by-name)
(defun linux-c-mode()
;; 将回车代替C-j的功能,换行的同时对齐
  (define-key c-mode-map [return] 'newline-and-indent)
;;  (interactive)
;; 设置C程序的对齐风格
  (c-set-style "Stroustrup")

;; 自动模式,在此种模式下当你键入{时,会自动根据你设置的对齐风格对齐
;;   (c-toggle-auto-state)
;; 此模式下,当按Backspace时会删除最多的空格,使得if缩进正常
  (c-toggle-hungry-state)
;; TAB键的宽度设置为4
  (setq c-basic-offset 4)
;; 在菜单中加入当前Buffer的函数索引
  (imenu-add-menubar-index)
;; 在状态条上显示当前光标在哪个函数体内部
  (which-function-mode)
 )



(defun geosoft-backward-word ()
   ;; Move one word backward. Leave the pointer at start of word
   ;; Treat _ as part of word
   (interactive)
   (backward-word 1)
   (backward-char 1)
   (cond ((looking-at "_") (geosoft-backward-word))
         (t (forward-char 1))))

(setq default-directory "/home/crazybaby")

(setq-default indent-tabs-mode nil)
(setq nxml-child-indent 4)

(global-auto-revert-mode t);
(tool-bar-mode nil);
;;(setq c-default-style
;;      '((c-mode . "Stroustrup")))
(setq-default tab-width 4)
(setq c-basic-offset 4)
(setq default-fill-column 80)
(setq column-number-mode t)
(setq make-backup-files nil)
(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)
 '(inhibit-startup-screen 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.
 )

阅读(438) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~