- 论坛徽章:
- 0
|
发个最新的, 放这儿备用
(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)
'(current-language-environment "UTF-8"
'(ecb-layout-window-sizes (quote (("leftright-analyse" (0.13966480446927373 . 0.3076923076923077) (0.13966480446927373 . 0.36538461538461536) (0.13966480446927373 . 0.3076923076923077) (0.1340782122905028 . 0.6153846153846154) (0.1340782122905028 . 0.36538461538461536)) ("left8" (0.15083798882681565 . 0.25) (0.15083798882681565 . 0.25) (0.15083798882681565 . 0.25) (0.15083798882681565 . 0.2307692307692307 ))))
'(ecb-options-version "2.32"
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1))
'(menu-bar-mode t)
'(scroll-bar-mode nil)
'(show-paren-mode t)
'(size-indication-mode t)
'(tool-bar-mode nil)
'(menu-bar-mode nil)
'(transient-mark-mode (quote (only . t))))
(defun sg-mode-hook-func ()
(set-process-sentinel
(get-buffer-process (current-buffer))
'kill-buffer-on-exit))
(add-hook 'shell-mode-hook 'sg-mode-hook-func)
(add-hook 'gdb-mode-hook 'sg-mode-hook-func)
(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.
'(default ((t (:inherit nil :stipple nil :background "black" :foreground "grey" :inverse-video nil :box nil :strike-through nil verline nil :underline nil :slant normal :weight normal :height 83 :width normal :foundry "unknown" :family "DejaVu Sans Mono" ))))
;;(set-language-environment 'Chinese-GB)
;;(set-keyboard-coding-system 'utf-
;;(set-clipboard-coding-system 'utf-
;;(set-terminal-coding-system 'utf-
;;(set-buffer-file-coding-system 'utf-
;;(set-default-coding-systems 'utf-
;;(set-selection-coding-system 'utf-
;;(modify-coding-system-alist 'process "*" 'utf-
;;(setq default-process-coding-system 'utf-
;;(setq-default pathname-coding-system 'utf-
;;(set-file-name-coding-system 'utf-8)
;;;;;;全屏;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
;; 水平最大化
(defun my-maximized-horz ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
;; 垂直最大化
(defun my-maximized-vert ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;; 最大化
(defun my-maximized ()
(my-maximized-vert)
(my-maximized-horz))
;; 启动时最大化
(cond
((eq window-system 'x)
(my-maximized)))
;;设置有用的个人信息。
(setq user-full-name "Heng Liu"
(setq user-mail-address "liuhengloveyou@gmail.coom"
;;以 y/n代表 yes/no
(fset 'yes-or-no-p 'y-or-n-p)
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线
(mouse-avoidance-mode 'animate)
;;支持emacs和外部程序的粘贴
(setq x-select-enable-clipboard t)
;;设置背景色和字体色
(set-foreground-color "grey"
(set-background-color "black"
;;显示列号
(setq column-number-mode t)
;;关闭启动画面
(setq inhibit-startup-message t)
;;括号匹配时显示另外一边的括号,而不是烦人的跳到另一个括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;;在标题栏显示buffer的名字,而不是 emacs@wangyin.com 这样没用的提示
(setq frame-title-format "emacs@%b"
;;让 Emacs 可以直接打开和显示图片
;;(auto-image-file-mode)
;; 高亮显示要拷贝的区域
(transient-mark-mode t)
;;光标显示为一竖线
(setq-default cursor-type 'bar)
;;进行语法加亮
(global-font-lock-mode t)
;;不产生备份文件
(setq make-backup-files nil)
;;临时文件放到同一个目录下
(setq backup-directory-alist '(("." . "/tmp" ))
;;一打开就起用text模式
(setq default-major-mode 'text-mode)
;;允许临时设置标记
(transient-mark-mode t)
;;默认显示 80列就换行
(setq default-fill-column 80)
;;很大的 kill ring
(setq kill-ring-max 200)
;;用空格代替tab
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
(setq tab-stop-list (cons (* x 2) tab-stop-list)))
;;鼠标滚轮,默认的滚动太快,这里改为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)
;;设置 sentence-end 可以识别中文标点
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*"
(setq sentence-end-double-space nil)
;;解决emacs shell乱码
(setq ansi-color-for-comint-mode t)
(customize-group 'ansi-colors)
(kill-this-buffer);;关闭customize窗口
;;shell,gdb退出后,自动关闭该buffer
(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))))
(defun sg-mode-hook-func ()
(set-process-sentinel
(get-buffer-process (current-buffer))
#'kill-buffer-on-exit))
(add-hook 'shell-mode-hook 'sg-mode-hook-func)
(add-hook 'gdb-mode-hook 'sg-mode-hook-func)
;;让 dired 可以递归的拷贝和删除目录
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
;;把这些缺省禁用的功能打开
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)
;;括号匹配,找到对应的括号
(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)))))
;;可以递归的使用 minibuffer
(setq scroll-margin 3
scroll-conservatively 10000)
;;不显示ecbTip
(setq ecb-tip-of-the-day nil)
;;启动/关闭ECB
(global-set-key [f12] 'ecb-activate)
(global-set-key [C-f12] 'ecb-deactivate)
;;标签功能
(require 'tabbar)
(tabbar-mode)
(global-set-key (kbd "<s-up>") 'tabbar-backward-group)
(global-set-key (kbd "<s-down>") 'tabbar-forward-group)
(global-set-key (kbd "<s-left>") 'tabbar-backward)
(global-set-key (kbd "<s-right>") 'tabbar-forward)
;;ibuffer
(require 'ibuffer)
;;(global-set-key (kbd "C-x C-b") 'ibuffer)
;;ido主要有两个界面:打开文件和切换buffer
(require 'ido)
;;{{{ ido: fast switch buffers
(add-hook 'ido-define-mode-map-hook 'ido-my-keys)
(defun ido-my-keys ()
"Set up the keymap for `ido'."
;; common keys
(define-key ido-mode-map "\C-e" 'ido-edit-input)
(define-key ido-mode-map "\t" 'ido-complete) ;; complete partial
(define-key ido-mode-map "\C-j" 'ido-select-text)
(define-key ido-mode-map "\C-m" 'ido-exit-minibuffer)
(define-key ido-mode-map "?" 'ido-completion-help) ;; list completions
(define-key ido-mode-map [(control ? )] 'ido-restrict-to-matches)
(define-key ido-mode-map [(control ?@)] 'ido-restrict-to-matches)
;; cycle through matches
(define-key ido-mode-map "\C-r" 'ido-prev-match)
(define-key ido-mode-map "\C-s" 'ido-next-match)
(define-key ido-mode-map [right] 'ido-next-match)
(define-key ido-mode-map [left] 'ido-prev-match)
;; toggles
(define-key ido-mode-map "\C-t" 'ido-toggle-regexp) ;; same as in isearch
(define-key ido-mode-map "\C-p" 'ido-toggle-prefix)
(define-key ido-mode-map "\C-c" 'ido-toggle-case)
(define-key ido-mode-map "\C-a" 'ido-toggle-ignore)
;; keys used in file and dir environment
(when (memq ido-cur-item '(file dir))
(define-key ido-mode-map "\C-b" 'ido-enter-switch-buffer)
(define-key ido-mode-map "\C-d" 'ido-enter-dired)
(define-key ido-mode-map "\C-f" 'ido-fallback-command)
;; cycle among directories
;; use [left] and [right] for matching files
(define-key ido-mode-map [down] 'ido-next-match-dir)
(define-key ido-mode-map [up] 'ido-prev-match-dir)
;; backspace functions
(define-key ido-mode-map [backspace] 'ido-delete-backward-updir)
(define-key ido-mode-map "\d" 'ido-delete-backward-updir)
(define-key ido-mode-map [(meta backspace)] 'ido-delete-backward-word-updir)
(define-key ido-mode-map [(control backspace)] 'ido-up-directory)
;; I can't understand this
(define-key ido-mode-map [(meta ?d)] 'ido-wide-find-dir)
(define-key ido-mode-map [(meta ?f)] 'ido-wide-find-file)
(define-key ido-mode-map [(meta ?k)] 'ido-forget-work-directory)
(define-key ido-mode-map [(meta ?m)] 'ido-make-directory)
(define-key ido-mode-map [(meta down)] 'ido-next-work-directory)
(define-key ido-mode-map [(meta up)] 'ido-prev-work-directory)
(define-key ido-mode-map [(meta left)] 'ido-prev-work-file)
(define-key ido-mode-map [(meta right)] 'ido-next-work-file)
;; search in the directories
;; use C-_ to undo this
(define-key ido-mode-map [(meta ?s)] 'ido-merge-work-directories)
(define-key ido-mode-map [(control ?\_)] 'ido-undo-merge-work-directory)
)
(when (eq ido-cur-item 'file)
(define-key ido-mode-map "\C-k" 'ido-delete-file-at-head)
(define-key ido-mode-map "\C-l" 'ido-toggle-literal)
(define-key ido-mode-map "\C-o" 'ido-copy-current-word)
(define-key ido-mode-map "\C-v" 'ido-toggle-vc)
(define-key ido-mode-map "\C-w" 'ido-copy-current-file-name)
)
(when (eq ido-cur-item 'buffer)
(define-key ido-mode-map "\C-b" 'ido-fallback-command)
(define-key ido-mode-map "\C-f" 'ido-enter-find-file)
(define-key ido-mode-map "\C-k" 'ido-kill-buffer-at-head)
))
(ido-mode t)
;;}}}
;;方便的在 kill-ring 里寻找需要的东西
(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
;;所见即所得的编辑一个文本模式的表格
;;(autoload 'table-insert "table" "WYSIWYG table editor")
;;临时记号:当你按 C-. 时就做了一个记号。然后你可以到别处,按C-, 就可以在这两点之间来回跳转了
(global-set-key [(control ?\.)] 'ska-point-to-register)
(global-set-key [(control ?\,)] 'ska-jump-to-register)
(defun ska-point-to-register()
"Store cursorposition _fast_ in a register.
Use skitema-jump-to-register to jump back to the stored
position."
(interactive)
(setq zmacs-region-stays t)
(point-to-register 8))
(defun ska-jump-to-register()
"Switches between current cursorposition and position
that was stored with ska-point-to-register."
(interactive)
(setq zmacs-region-stays t)
(let ((tmp (point-marker)))
(jump-to-register 8)
(set-register 8 tmp)))
;;go-to-char:当你按 C-c a x (x 是任意一个字符) 时,光 标就会到下一个 x 处,再次按 x,光标就到下一个 x.
(defun wy-go-to-char (n char)
"Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
(interactive "p\ncGo to char: ")
(search-forward (string char) nil nil n)
(while (char-equal (read-char)
char)
(search-forward (string char) nil nil n))
(setq unread-command-events (list last-input-event)))
(define-key global-map (kbd "C-c a") 'wy-go-to-char)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C语言设定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;设置C语言编译命令
;;(set 'compile-command' "gcc -g ")
;;CC-mode配置 http://cc-mode.sourceforge.net/
(require 'cc-mode)
(require 'xcscope)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
(add-hook 'c-mode-common-hook(lambda()(c-set-style "k&r")))
;;缩进策略
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "\\>")
(hippie-expand nil)
(indent-for-tab-command)))
;;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))
;; 配置Semantic的检索范围:
(setq semanticdb-project-roots
(list
(expand-file-name "/")))
;; 自定义自动补齐命令,如果在单词中间就补齐,否则就是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)
;; 补全优先级
(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))
;;按键定义
(define-key c-mode-base-map [(f5)] 'compile)
(global-set-key [(f6)] 'gdb)
(global-set-key [(f7)] 'gdb-many-windows)
(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)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;(define-key c-mode-base-map [(meta ?/)] 'hippie-expand)
;;多窗口gdb
;;(setq gdb-many-windows t)
;;(load-library "multi-gud.el")
;;(load-library "multi-gdb-ui.el") |
|