Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72021
  • 博文数量: 21
  • 博客积分: 1478
  • 博客等级: 上尉
  • 技术积分: 220
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-22 20:41
文章分类

全部博文(21)

文章存档

2011年(1)

2010年(2)

2009年(18)

我的朋友

分类:

2009-11-09 12:03:06

;自定义按键
(global-set-key [f5] 'shell);f1进入shell
(setq compile-command "make -f makefile")
(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 [f12] 'my-fullscreen);f12 全屏
(global-set-key (kbd "C-,") 'backward-page);文件首
(global-set-key (kbd "C-.") 'forward-page);文件尾
(global-set-key [f2] 'zl-newline-up)
(global-set-key [f3] 'zl-newline)
(global-set-key [f4] 'goto-line)
(global-set-key [f6] 'dired-jump)
(global-set-key [(control tab)] 'my-indent-or-complete)
(global-set-key [f9] 'ansi-term)

;普通设置
(setq inhibit-startup-message t);关闭起动时闪屏
(setq visible-bell t);关闭出错时的提示声
(setq make-backup-files nil);不产生备份文件
(setq default-major-mode 'text-mode);一打开就起用 text 模式
(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);显示括号匹配
(display-time-mode 1);显示时间,格式如下
(setq display-time-24hr-format t)
(setq display-time-day-and-date 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 78);默认显示 80列就换行
(setq fill-column 78)
(setq show-trailing-whitespace t);显示多余空格

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


;非交互式编译
(defun do-compile ()
  "save buffers and start compile"
  (interactive)
  (save-some-buffers t)
  (setq compilation-read-command nil)
  (compile compile-command)
  (setq compilation-read-command t))


;shell,gdb退出后,自动关闭该buffer
(add-hook 'shell-mode-hook 'mode-hook-func)
(add-hook 'gdb-mode-hook 'mode-hook-func)
(defun mode-hook-func ()
  (set-process-sentinel (get-buffer-process (current-buffer))
                        #'kill-buffer-on-exit))
(defun kill-buffer-on-exit (process state)
  (message "%s" state)
  (if (or
       (string-match "exited abnormally with code.*" state)
       (string-match "finished" state))
      (kill-buffer (current-buffer))))

(add-hook 'text-mode-hook 'turn-on-auto-fill)
(setq-default auto-fill-function 'do-auto-fill)
;(dired-directory dired-directory "%b"))))
;(menu-bar-mode nil)
;;
;; Settings about Tab

(setq default-tab-width 8)
(setq tab-width 4 indent-tabs-mode t)
(setq show-paren-mode t)
(setq indent-line-function 'indent-relative-maybe)
(setq c-basic-offset 8)
;;;; Create ~/.emacs.el to speed up eamcs
(defun autocompile nil
"compile itself if ~/.emacs"
(interactive)
(if (string= (buffer-file-name) (concat default-directory ".emacs"))
(byte-compile-file (buffer-file-name))))
(add-hook 'after-save-hook 'autocompile)

(defun zl-newline nil
(interactive)
(end-of-line)
(newline-and-indent))


(defun zl-newline-up nil
(interactive)
(beginning-of-line)
(newline-and-indent))

(defun zl-delete-line nil
(interactive)
(beginning-of-line)
(set-mark-command 0)
(beginning-of-line 2)
(kill-region (point) (mark)))

(global-set-key (kbd "C-d") 'zl-delete-line)

(setq auto-mode-alist
 (cons '("\\.py$" . python-mode) auto-mode-alist))

(setq interpreter-mode-alist
 (cons '("python" . python-mode)
 interpreter-mode-alist))

(autoload 'python-mode "python-mode" "Python editing mode." t)
;;; add these lines if you like color-based syntax highlighting

(global-font-lock-mode t)

(setq font-lock-maximum-decoration t)
(set-language-environment 'Chinese-GB)

(set-keyboard-coding-system 'euc-cn)

(set-clipboard-coding-system 'euc-cn)

(set-terminal-coding-system 'euc-cn)

(set-buffer-file-coding-system 'euc-cn)

(set-selection-coding-system 'euc-cn)

(modify-coding-system-alist 'process "*" 'euc-cn)

(setq default-process-coding-system

 '(euc-cn . euc-cn))

(setq-default pathname-coding-system 'euc-cn)
(add-to-list 'load-path "d:/site-lisp/cedet")

;; Enable EDE (Project Management) features
;(global-ede-mode 1)

;; Enable EDE for a pre-existing C++ project
;; (ede-cpp-root-project "NAME" :file "~/myproject/Makefile")


;; Enabling Semantic (code-parsing, smart completion) features
;; Select one of the following:

;; * This enables the database and idle reparse engines
(semantic-load-enable-minimum-features)

;; * This enables some tools useful for coding, such as summary mode
;; imenu support, and the semantic navigator
(semantic-load-enable-code-helpers)

;; * This enables even more coding tools such as intellisense mode
;; decoration mode, and stickyfunc mode (plus regular code helpers)
;; (semantic-load-enable-gaudy-code-helpers)

;; * This enables the use of Exuberent ctags if you have it installed.
;; If you use C++ templates or boost, you should NOT enable it.
;; (semantic-load-enable-all-exuberent-ctags-support)

;; Enable SRecode (Template management) minor-mode.
;; (global-srecode-minor-mode 1)

;加入cedet插件
(load-file "d:/site-lisp/cedet/common/cedet.el")
(add-hook 'texinfo-mode-hook (lambda () (require 'sb-texinfo)))
(require 'cedet)
(semantic-load-enable-code-helpers)
(autoload 'speedbar-frame-mode "speedbar" "popup a speedbar frame" t)
(autoload 'speedbar-get-focus "speedbar" "jump to speedbar frame" t)
(define-key-after (lookup-key global-map [menu-bar tools])
  [speedbar]
  '("speedbar" .
    speedbar-frame-mode)
  [calendar])
(global-set-key [f7] 'speedbar);f4打开/关闭speedbar
;;;;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")))))
;project root path
(setq semanticdb-project-roots
      (list
       (expand-file-name "~/devel")))

(put 'upcase-region 'disabled nil)
(global-set-key [(f1)] (lambda() ;;设定F1为woman快捷键
                 (interactive)
                 (let ((woman-topic-at-point t))
                 (woman))))
(setq woman-use-own-frame nil) ;; WoMan不打开新的 frame, 你可能会想要这个配置

(put 'downcase-region 'disabled nil)

;ecb设置
;加入ecb插件
(require 'ecb)
;(require 'ecb-autoloads)
(global-set-key [f8] 'ecb-activate)
(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-layout-window-sizes (quote (("left8" (0.20967741935483872 . 0.27586206896551724) (0.20967741935483872 . 0.2413793103448276) (0.20967741935483872 . 0.27586206896551724) (0.20967741935483872 . 0.1724137931034483)))))
 '(ecb-options-version "2.40")
 '(ecb-primary-secondary-mouse-buttons (quote mouse-2--C-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.
 )

;;; Backup Configuration
;; Put autosave files (ie #foo#) in one place, *not*
;; scattered all over the file system!
(defvar autosave-dir
 "/home/yyc/.emacs.d/backup/")

(make-directory autosave-dir t)

  (defun make-auto-save-file-name ()
    (concat autosave-dir
            (if buffer-file-name
              (concat "#" (file-name-nondirectory buffer-file-name) "#")
              (expand-file-name
                (concat "#%" (buffer-name) "#")))))

;; Put backup files (ie foo~) in one place too. (The backup-directory-alist
;; list contains regexp=>directory mappings; filenames matching a regexp are
;; backed up in the corresponding directory. Emacs will mkdir it if necessary.)
(defvar backup-dir "/home/yyc/.emacs.d/backup/")
(setq backup-directory-alist (list (cons "." backup-dir)))

;; Call execute-extended-command using Ctrl.
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)

;; Some Configuration about Backspace.
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
(defun duplicate-line()
  (interactive)
  (move-beginning-of-line 1)
  (kill-line)
  (yank)
  (open-line 1)
; (next-line 1)
  (yank)
)
;(global-set-key (kbd "C-d") 'duplicate-line)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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))
;;;; cc-mode配置 [url][/url]
(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语言编辑策略
(defun my-c-mode-common-hook()
  (setq default-tab-width 4 indent-tabs-mode nil)
  (setq tab-width 4 indent-tabs-mode nil)
  (setq c-basic-offset 4)
  ;;; 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 [(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 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 default-tab-width 4 indent-tabs-mode nil)
  (setq tab-width 4 indent-tabs-mode nil)
  (setq c-basic-offset 4)
  ;;(define-key c++-mode-map [f3] 'replace-regexp)
  (c-set-style "stroustrup"))
(add-hook 'c++-mode-hook 'my-c++-mode-hook)

;(set-default-font "-outline-微软雅黑-normal-normal-normal-sans-15-*-*-*-p-*-iso8859-1")
(set-frame-font "-outline-微软雅黑-normal-normal-normal-sans-15-*-*-*-p-*-iso8859-1")
(require 'color-theme)

(when window-system
  (set-face-foreground 'modeline-buffer-id "RoyalBlue4")
  (set-face-background 'modeline "LightCyan1")
  (set-face-background 'modeline-inactive "DarkSlateGray2")
  (set-face-background 'fringe "LightCyan1")
  (set-face-background 'default "lightyellow1")
  (set-face-background 'region "lemonchiffon2")
  (set-face-background 'scroll-bar "lemonchiffon3")
  (set-face-background 'tool-bar "lemonchiffon3")
  (set-face-background 'header-line "lemonchiffon1")
  (set-face-background 'trailing-whitespace "lightyellow2"))


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