此博文不再更新,请移歩:https://github.com/visayafan/emacs
;(set-default-font "-microsoft-MS Reference Sans Serif-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")
;(set-default-font " -unknown-DejaVu Sans-normal-normal-normal-*-13-*-*-*-*-0-iso10646-1")
(add-to-list 'load-path "~/.emacs.d")
(tool-bar-mode nil)
(menu-bar-mode t)
(load-file "~/.emacs.d/cedet-1.0/common/cedet.el")
;; (semantic-load-enable-minimum-features)
(semantic-load-enable-code-helpers)
;; (semantic-load-enable-guady-code-helpers)
;; (semantic-load-enable-excessive-code-helpers)
(semantic-load-enable-semantic-debugging-helpers)
;; Enable EDE (Project Management) features
(global-ede-mode 1)
;; Enable EDE (Project Management) features
(global-ede-mode 1)
;; Enable source code folding
(global-semantic-tag-folding-mode 1)
(define-key semantic-tag-folding-mode-map (kbd "C-c , -") 'semantic-tag-folding-fold-block)
(define-key semantic-tag-folding-mode-map (kbd "C-c , =") 'semantic-tag-folding-show-block)
(define-key semantic-tag-folding-mode-map (kbd "C-c . -") 'semantic-tag-folding-fold-all)
(define-key semantic-tag-folding-mode-map (kbd "C-c . =") 'semantic-tag-folding-show-all)
;; 括号自动匹配
(require 'autopair)
(autopair-global-mode) ;; to enable in all buffers
;; 将buffer转化为html文件,保持颜色不变
(require 'htmlize)
;; 显示行号
(require 'linum)
(global-linum-mode 1)
;; 标签
(require 'tabbar)
(tabbar-mode)
(global-set-key (kbd "M-P") 'tabbar-backward-group) 0
(global-set-key (kbd "M-N") 'tabbar-forward-group)
(global-set-key (kbd "M-p") 'tabbar-backward)
(global-set-key (kbd "M-n") 'tabbar-forward)
;; 切换buffer,寻找文件
(require 'ido)
(ido-mode t)
;; 最近访问过的文件和最近修改过的文件
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
;; kill-ring 方便粘贴。
(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
;; 替换自带的切换Buffer功能
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; 高亮当前行:hi-line.el,emacs自己带的
(require 'hl-line)
(global-hl-line-mode t)
;; 应该是Chrome用的吧?
(require 'edit-server)
(edit-server-start)
;; 设置光标为竖线
;; (setq-default cursor-type 'bar)
;; 光标禁止闪烁-1 光标闪烁1
(blink-cursor-mode 1)
(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'C++-mode-hook 'hs-minor-mode)
(add-hook 'lisp-mode-hook 'hs-minor-mode)
(add-hook 'html-mode-hook 'hs-minor-mode)
(global-set-key "\C-cha" 'hs-hide-all)
(global-set-key "\C-cas" 'hs-show-all)
(global-set-key "\C-chb" 'hs-hide-block)
(global-set-key "\C-cbs" 'hs-show-block)
(global-set-key "\C-chl" 'hs-hide-level)
;; hide-region
(require 'hide-region)
(global-set-key (kbd "C-c h r") 'hide-region-hide)
(global-set-key (kbd "C-c s r") 'hide-region-unhide)
;; hide lines
(require 'hide-lines)
(global-set-key (kbd "C-c h L") 'hide-lines)
(global-set-key (kbd "C-c s l") 'show-all-invisible)
(global-set-key (kbd "C-c m l") 'list-matching-lines)
;; 返回最近修改的地方
(require 'goto-last-change)
(global-set-key "\C-c g l" 'goto-last-change)
;;;; sudo apt-get install cscope
(require 'xcscope)
(setq cscope-do-not-update-database t)
(add-hook 'c-mode-hook (function cscope:hook))
(add-hook 'c++-mode-hook (function cscope:hook))
(add-hook 'dired-mode-hook (function cscope:hook))
;(define-key global-map (kbd "C-c s a") 'cscope-set-initial-directory)
(define-key global-map (kbd "C-c s A") 'cscope-unset-initial-directory)
(define-key global-map (kbd "C-c s s ") 'cscope-find-this-symbol)
(define-key global-map (kbd "C-c s d") 'cscope-find-global-definition)
(define-key global-map (kbd "C-c s G") 'cscope-find-global-definition-no-prompting)
(define-key global-map (kbd "C-c s u") 'cscope-pop-mark)
(define-key global-map (kbd "C-c s n") 'cscope-next-symbol)
(define-key global-map (kbd "C-c s N") 'cscope-next-file)
(define-key global-map (kbd "C-c s p") 'cscope-prev-symbol)
(define-key global-map (kbd "C-c s P") 'cscope-prev-file)
(define-key global-map (kbd "C-c s b") 'cscope-display-buffer)
;; (define-key global-map (kbd "C-c s ")' cscope-display-buffer-toggle)
;; 显示被一个输入函数调用的所有函数。
(define-key global-map (kbd "C-c s c") 'cscope-find-functions-calling-this-function)
;; 显示被输入函数调用的所有函数
(define-key global-map (kbd "C-c s C") 'cscope-find-called-functions)
(define-key global-map (kbd "C-c s f") 'cscope-find-this-file);
;; Find files #including a file.
(define-key global-map (kbd "C-c s i") 'cscope-find-files-including-file)
;; Find egrep pattern
(global-set-key (kbd "C-c s e") 'cscope-find-egrep-pattern)
;; Find text string;
(global-set-key (kbd "C-c s t") 'cscope-find-this-text-string)
(require 'yasnippet-bundle)
(setq yas/root-directory "~/.emacs.d/snippets") (yas/load-directory yas/root-directory)
(put 'dired-find-alternate-file 'disabled nil)
(require 'dired-x) ; 有些特殊的功能
;;括号匹配时显示另外一边的括号,而不是烦人的跳到另一个括号。
(setq show-paren-style 'parentheses)
;;把缺省的 major mode 设置为 text-mode, 而不是几乎什么功能也 没有的 fundamental-mode.
(show-paren-mode t)
(mouse-avoidance-mode 'animate)
;;进行语法加亮。
(global-font-lock-mode t)
;;设置有用的个人信息
(setq user-full-name "visaya fan")
(setq user-mail-address "visayafan[AT]gmail.com")
;;让 dired 可以递归的拷贝和删除目录。
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
(setq visible-bell t)
;; 高亮显示选择区域
(setq transient-mark-mode t)
;; 设置tab为4个空格的宽度,而不是原来的2
(setq c-basic-offset 4)
(setq default-tab-width 4)
(setq-default indent-tabs-mode nil)
;; 打开图片显示功能
(auto-image-file-mode t)
;;页面平滑滚动, scroll-margin 3 靠近屏幕边沿3行时开始滚动,可以很好的看到上下文。
(setq scroll-margin 3
scroll-conservatively 10000)
;;; hippie-expand
(global-set-key [(meta ?/)] 'hippie-expand)
(setq hippie-expand-try-functions-list
'(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))
;; 鼠标遇到光标自动躲让
;; (mouse-avoidance-mode 'animate)
;;进行语法加亮。
(global-font-lock-mode t)
;;让 dired 可以递归的拷贝和删除目录。
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
(setq visible-bell t)
;; goto-line
(global-set-key (kbd "M-g") 'goto-line)
;(menu-bar-mode nil)
;(scroll-bar-mode nil)
;; y/n代替yes/no
(fset 'yes-or-no-p 'y-or-n-p)
;;禁用启动画面
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
;;;;去掉喇叭声
(setq visible-bell t)
;; 列号
(setq column-number-mode t)
;; 把滚动条放在左边
(menu-bar-left-scroll-bar)
;; narrow C-x n m / C-x n w
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(global-set-key (kbd "M-@") 'set-mark-command)
(global-set-key (kbd "C-@") 'mark-word)
;; 扩展 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)))))
;; 指针颜色
(set-cursor-color "blue")
;; 鼠标颜色
(set-mouse-color "yellow")
;; 不产生备份文件,临时文件
;; (setq make-backup-files nil)
;; (setq-default make-backup-files nil)
(setq default-fill-column 110)
;; 注意当前行 c++
(global-set-key (kbd "C-;") 'v_c_comment_currentline)
(fset 'v_c_comment_currentline
"\355// ")
(global-set-key (kbd "") 'gdb)
(global-set-key (kbd "") 'other-window)
(global-set-key (kbd "") 'ido-switch-buffer)
(global-set-key (kbd "") 'eshell)
;;有了这段代码之后,当你按 C-c a x (x 是任意一个字符) 时,光标就会到下一个 x 处。再次按 x,光标就到下一个 x。比如 C-c a w w w w ..., C-c a b b b b b b ...
(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)
;;临时记号
;;有时你需要跳到另一个文件进行一些操作,然后很快的跳回来。你当然可以使用 bookmark 或者寄存器。但是这些实在是太慢了。你多想拥有vi那样的 ma, mb, 'a, 'b 的操作。现在你可以用几行 elisp 达到类似的目的:
(global-set-key "\C-cp" 'ska-point-to-register)
(global-set-key "\C-cn" 'ska-jump-to-register)
(defun ska-point-to-register()
"Store cursorposition _fast_ in a register.
Use ska-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)))
(global-set-key (kbd "") 'smart-compile)
(add-hook 'c-mode-hook 'linux-c-mode)
(add-hook 'c++-mode-hook 'linux-cpp-mode)
(defun linux-c-mode()
;; 将回车代替C-j的功能,换行的同时对齐
(define-key c-mode-map [return] 'newline-and-indent)
(interactive)
;; 设置C程序的对齐风格
(c-set-style "K&R")
;; 自动模式,在此种模式下当你键入{时,会自动根据你设置的对齐风格对齐
;; (c-toggle-auto-state)
;; 此模式下,当按Backspace时会删除最多的空格
;;(c-toggle-hungry-state)
;; TAB键的宽度设置为8
(setq c-basic-offset 4)
;; 在菜单中加入当前Buffer的函数索引
(imenu-add-menubar-index)
;; 在状态条上显示当前光标在哪个函数体内部
(which-function-mode)
)
(defun linux-cpp-mode()
(define-key c++-mode-map [return] 'newline-and-indent)
;(define-key c++-mode-map [(control c) (c)] 'compile)
(interactive)
(c-set-style "K&R")
;(c-toggle-auto-state)
;(c-toggle-hungry-state)
(setq c-basic-offset 4)
(imenu-add-menubar-index)
(which-function-mode)
)
;;; CC-mode配置 http://cc-mode.sourceforge.net/
(setq c-default-style
'((c-mode . "k&r") (other . "gnu")))
(setq c-basic-offset 4)
(add-hook 'c++-mode-hook
'(lambda()
(c-set-style "k&r")))
;;智能编译
(defun smart-compile()
;; "比较智能的C/C++编译命令,如果当前目录有makefile则用make -k编译,否则,如果是
;;处于c-mode,就用gcc -Wall编译,如果是c++-mode就用g++ -Wall编译"
(interactive)
;; 查找 Makefile
(let ((candidate-make-file-name '("makefile" "Makefile" "GNUmakefile"))
(command nil))
(if (not (null
(find t candidate-make-file-name :key
'(lambda (f) (file-readable-p f)))))
(setq command "mingw32-make.exe -k ")
;; 没有找到 Makefile ,查看当前 mode 是否是已知的可编译的模式
(if (null (buffer-file-name (current-buffer)))
(message "Buffer not attached to a file, won't compile!")
(if (eq major-mode 'c-mode)
(setq command
(concat "gcc -g -Wall -o "
(file-name-sans-extension
(file-name-nondirectory buffer-file-name))
" "
(file-name-nondirectory buffer-file-name)
;; " -lm "
))
(if (eq major-mode 'c++-mode)
(setq command
(concat "g++ -g -Wall -o "
(file-name-sans-extension
(file-name-nondirectory buffer-file-name))
" "
(file-name-nondirectory buffer-file-name)
;; " -lm "
))
(if (eq major-mode 'fortran-mode)
(setq command
(concat "ifort "
;; (file-name-nondirectory buffer-file-name))
;; (file-name-sans-extension
(file-name-nondirectory buffer-file-name)
" -o "
))
(message "Unknow mode, won't compile!"))))))
(if (not (null command))
(let ((command (read-from-minibuffer "Compile command: " command)))
(compile command)))))
;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))))
;; 使用cperl-mode代替默认的perl-mode
(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
;; 缩进相关
(add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)
(defun n-cperl-mode-hook ()
(setq cperl-indent-level 4)
(setq cperl-continued-statement-offset 0)
(setq cperl-extra-newline-before-brace t)
(set-face-background 'cperl-array-face "wheat")
(set-face-background 'cperl-hash-face "wheat")
)
;; org-mode
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-col" 'org-store-link)
(global-set-key "\C-coc" 'org-capture)
(global-set-key "\C-coa" 'org-agenda)
(global-set-key "\C-cob" 'org-iswitchb)
(add-hook 'org-mode-hook
(lambda () (setq truncate-lines nil)))
(setq org-todo-keywords
'((sequence "TODO(t)" "|" "DONE(d)")
(sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")))
(setq org-log-done 'time)
(setq org-log-done 'note)
;; 当所有子项目都标记为Done的时候,父项目也被标记为Done
(defun org-summary-todo (n-done n-not-done)
"Swith entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states) ; turn off logging.
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
(setq org-tag-alist '(("@STL" . ?s) ("@OJ" . ?o) ("@Python" . ?p) ("@English" . ?e)))
;;(require 'calendar)
(setq calendar-latitude +30.15)
(setq calendar-longitude +120.10)
(setq calendar-location-name "Hangzhou")
;; 设置阴历显示,在 calendar 上用 pC 显示阴历
(setq chinese-calendar-celestial-stem
["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
["子" "丑" "寅" "卯" "辰" "巳" "戊" "未" "申" "酉" "戌" "亥"])
(setq calendar-remove-frame-by-deleting t)
(setq calendar-week-start-day 1)
(setq mark-diary-entries-in-calendar t)
(setq mark-holidays-in-calendar nil)
(setq view-calendar-holidays-initially nil)
;;(setq mark-diary-entries-in-calendar t)
;;(setq mark-holidays-in-calendar t)
;;(setq view-calendar-holidays-initially nil)
;; my advice for exit-calendar : save and close the _diray buffer
(defadvice exit-calendar (before my-advice-close-diary ())
"save and close the _diary buffer to avoid open it when
starting emacs next time."
(let ((bf (find-file-noselect diary-file t)))
(and bf
(save-excursion
(with-current-buffer bf (save-buffer) (kill-buffer nil))))))
(ad-activate 'exit-calendar)
;;I don't care these holidays
(setq christian-holidays nil)
(setq hebrew-holidays nil)
(setq islamic-holidays nil)
(setq solar-holidays nil)
(setq general-holidays '((holiday-fixed 1 1 "元旦")
(holiday-fixed 2 14 "情人节")
(holiday-fixed 3 14 "白色情人节")
(holiday-fixed 4 1 "愚人节")
(holiday-fixed 5 1 "劳动节")
(holiday-float 5 0 2 "母亲节")
(holiday-fixed 6 1 "儿童节")
(holiday-float 6 0 3 "父亲节")
(holiday-fixed 7 1 "建党节")
(holiday-fixed 8 1 "建军节")
(holiday-fixed 9 10 "教师节")
(holiday-fixed 10 1 "国庆节")
(holiday-fixed 12 25 "圣诞节")))
;;abbrev
(setq abbrev-mode t)
(setq abbrev-file-name ;; tell emacs where to read abbrev
"~/.emacs.d/abbrev_defs") ;; definitions from...
(setq save-abbrevs t) ;; save abbrevs when files are saved
;; you will be asked before the abbreviations are saved
(quietly-read-abbrev-file) ;; reads the abbreviations file on startup
(if (file-exists-p abbrev-file-name)
(quietly-read-abbrev-file))
;; 支持emacs和外部程序的粘贴
(setq x-select-enable-clipboard t)
;; 在标题栏显示buffer名
(setq frame-title-format '("" buffer-file-name ))
(add-to-list 'load-path "~/.emacs.d/color-theme")
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)))
; (color-theme-gnome2)))
(global-set-key "\C-ccc" 'color-theme-gnome2)
(global-set-key "\C-ccb" 'color-theme-blue-sea)
(global-set-key "\C-ccg" 'color-theme-gray30)
(global-set-key "\C-ccd" 'color-theme-euphoria)
(global-set-key "\C-cce" 'color-theme-emacs-21)
;; 保存
(global-set-key "\C-cds" 'desktop-save)
(global-set-key "\C-cdc" 'desktop-change-dir)
(add-to-list 'load-path "~/.emacs.d/auto-complete-1.3.1")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/lisp/auto-complete/ac-dict")
(ac-config-default)
(require 'unicad)
(load "desktop")
(desktop-load-default)
(desktop-read)
(setq tags-table-list
'("~/.emacs.d/TAGS"))
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(global-set-key "\C-cca" 'v_cua_mode)
(fset 'v_cua_mode
[?\M-x ?c ?u ?a ? ?m ?o ?d ?e return])
;; cls 清屏
(defun eshell/clc()
"to clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
;;;;ECB
(add-to-list 'load-path "~/.emacs.d/ecb-2.40")
(require 'ecb)
(setq ecb-tip-o/-the-day nil)
;; 隐藏和显示ECB窗口
(define-key global-map [(control f1)] 'ecb-hide-ecb-windows)
(define-key global-map [(control f2)] 'ecb-show-ecb-windows)
;; 使某一ecb窗口最大化
(define-key global-map "\C-c1" 'ecb-maximize-window-directories)
(define-key global-map "\C-c2" 'ecb-maximize-window-sources)
(define-key global-map "\C-c3" 'ecb-maximize-window-methods)
(define-key global-map "\C-c4" 'ecb-maximize-window-history)
;; 恢复原始窗口布局
(define-key global-map "\C-c0" 'ecb-restore-default-window-sizes)
(global-set-key [f9] 'ecb-activate)
;; 各窗口间切换
(global-set-key [M-left] 'windmove-left)
(global-set-key [M-right] 'windmove-right)
(global-set-key [M-up] 'windmove-up)
(global-set-key [M-down] 'windmove-down)
(global-set-key "\C-z" 'undo)
;; For Linux 鼠标滚轮+C设置字体大小
(global-set-key (kbd "") 'text-scale-increase)
(global-set-key (kbd "") 'text-scale-decrease)
(global-set-key "\C-cln" 'linum-mode)
(global-set-key "\C-cmb" 'menu-bar-mode)
(global-set-key (kbd "M-P") 'tabbar-backward-group)
(global-set-key (kbd "M-N") 'tabbar-forward-group)
(global-set-key (kbd "M-p") 'tabbar-backward)
(global-set-key (kbd "M-n") 'tabbar-forward)
(global-set-key "\C-cds" 'desktop-save)
(global-set-key "\C-cdc" 'desktop-change-dir)
(require 'winner)
(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 "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 90 :width normal :foundry "unknown" :family "文泉驿等宽微米黑"))))
'(tabbar-selected-face ((t (:inherit tabbar-default-face :background "#102e4e" :foreground "green" :box (:line-width 2 :color "#102e4e" :style released-button)))))
'(tabbar-unselected-face ((t (:inherit tabbar-default-face :foreground "#102e4e" :box (:line-width 2 :color "white" :style pressed-button))))))
;;;;http://www.gnu.org/software/auctex/download-for-unix.html
;;;; .configure make sudo make install
(add-to-list 'load-path "~/.emacs.d/auctex-11.86")
(add-to-list 'load-path "~/.emacs.d/auctex-11.86/preview")
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq TeX-output-view-style (quote (("^pdf$" "." "evince %o %(outpage)"))))
;; (add-hook 'LaTeX-mode-hook
;; (lambda()
;; (add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
;; (setq TeX-command-default "XeLaTeX")))
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq preview-scale-function 1.3)
(setq LaTeX-math-menu-unicode t)
(setq TeX-insert-braces nil)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
;;Auctex for Latex
(add-hook 'LaTeX-mode-hook 'LaTeX-install-toolbar)
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(add-hook 'LaTeX-mode-hook (lambda()
;;调用latex命令
(add-to-list 'TeX-command-list (list "LaTeX" "latex %s.tex" 'TeX-run-command nil t))
;;调用dvipdfmx命令
(add-to-list 'TeX-command-list (list "dvi2pdf" "dvipdfmx %s.dvi" 'TeX-run-command nil t))
;;调用pdflatex命令;;调用pdflatex命令;;调用pdflatex命令
(add-to-list 'TeX-command-list (list "pdf Latex" "pdflatex %s.tex" 'TeX-run-command nil t))
; View PDF
(add-to-list 'TeX-command-list (list "View pdf" "start .\\\"%s.pdf\""'TeX-run-command nil t))
;;设置环境为xelatex
(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
;;(setq TeX-command-default "XeLaTeX")
;;(setq TeX-save-query nil )
;;(setq TeX-show-compilation t)
))
;; latex-math-mode
;; latex-math-mode (add math symbols to menu and shortcuts)
;; So that you can use, e.g., `a, to input \alpha. You may also define
;; your own customized shortcuts by setting the variable
;; LaTeX-math-list before loading LaTeX-math-mode.
;; to enable maths support
(setq LaTeX-math-mode t)
(setq TeX-electric-escape t) ;; you may like it or dislike it. I found it useful when inputting repeated commands -- you just need to type \ and ENTER to repeat the last latex command.
(add-hook 'LaTeX-mode-hook 'latex-math-mode) ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'latex-math-mode) ; with Emacs latex mode
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
;; reftex-mode
(autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
(autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
(autoload 'reftex-citation "reftex-cite" "Make citation" nil)
(autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
;; (add-to-list 'load-path "~/.emacs.d/ibus-el-0.2.1")
(require 'ibus)
;; Turn on ibus-mode automatically after loading .emacs
(add-hook 'after-init-hook 'ibus-mode-on)
;; Use C-SPC for Set Mark command
(ibus-define-common-key ?\C-\s nil)
;; Use C-/ for Undo command
(ibus-define-common-key ?\C-/ nil)
;; Change cursor color depending on IBus status
(setq ibus-cursor-color '("red" "blue" "limegreen"))
;; Use s-SPC to toggle input status
(global-set-key (kbd "S-SPC") 'ibus-toggle)
;; 插入日期
(global-set-key "\C-cid" 'insert-date)
(defun insert-date ()
"Insert date at point."
(interactive)
(insert (format-time-string "%Y年%m月%e日 %a %l:%M %p")))
(global-set-key "\C-cid" 'insert-date)
;; 插入当前时间
(global-set-key "\C-cit" 'insert-current-time)
(defun insert-current-time ()
"Insert the current time"
(interactive "*")
(insert (current-time-string)))
(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.
'(c-default-style (quote ((java-mode . "java") (awk-mode . "awk") (other . "gnu"))))
'(column-number-mode t)
'(default-input-method "chinese-b5-quick")
'(ecb-options-version "2.40")
'(matlab-shell-command "/usr/local/MATLAB/R2010b/bin/matlab")
'(menu-bar-mode t)
'(show-paren-mode t))
(add-to-list 'load-path "~/.emacs.d/matlab-emacs/matlab-emacs")
(require 'matlab-load)
(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)
;; turn off auto-verify on save
(setq matlab-verify-on-save-flag nil)
(defun my-matlab-mode-hook ()
(setq fill-column 76)) ; where auto-fill should wrap
(add-hook 'matlab-mode-hook 'my-matlab-mode-hook)
(defun my-matlab-shell-mode-hook ()
'())
(add-hook 'matlab-shell-mode-hook 'my-matlab-shell-mode-hook)
(global-font-lock-mode t)
;; (matlab-mode-hilit)
(autoload 'tlc-mode "tlc" "tlc Editing Mode" t)
(add-to-list 'auto-mode-alist '("\\.tlc$" . tlc-mode))
(setq tlc-indent-function t)
;; 全屏
(global-set-key [(control f10)] 'fs)
(defun fs()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
)
(setq tab-width 4 indent-tabs-mode nil)
;; iimage mode
(autoload 'iimage-mode "iimage" "Support Inline image minor mode." t)
(autoload 'turn-on-iimage-mode "iimage" "Turn on Inline image minor mode." t)
(defun org-toggle-iimage-in-org ()
"display images in your org file"
(interactive)
(if (face-underline-p 'org-link)
(set-face-underline-p 'org-link nil)
(set-face-underline-p 'org-link t))
(iimage-mode))
(defun latex-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?$ _ "$")
))
(setq skeleton-pair t)
(local-set-key (kbd "$") 'skeleton-pair-insert-maybe)
)
(add-hook 'LaTeX-mode-hook 'latex-auto-pair)
(add-hook 'latex-mode-hook 'latex-auto-pair)
(global-set-key "\C-ciy" 'yas/insert-snippet)
(add-to-list 'load-path "~/.emacs.d/doxymacs-1.8.0/lisp")
(require 'doxymacs)
(add-hook 'c-mode-common-hook 'doxymacs-mode)
(add-hook 'python-mode-hook 'doxymacs-mode)
;;当 % 在括号上按下时,那么匹配括号,否则输入一个 %。你只需要在 .emacs 文件里加入这些东西就可以达到目的:
;; (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)))))
; C-x a w来取消abbrev扩展,有时候不想被扩展的缩写自动被扩展后可以用此来恢复
(global-set-key (kbd "C-x a w") 'unexpand-abbrev)
;; (add-to-list 'load-path "~/.emacs.d/twittering-mode")
;; (require 'twittering-mode)
;; ;; (setq twittering-use-master-password t)
;; (setq twittering-allow-insecure-server-cert t)
;; (setq twittering-oauth-use-ssl nil)
;; (setq twittering-use-ssl nil)
;; (twittering-enable-unread-status-notifier)
;; (setq-default twittering-icon-mode t)
;; (setq twittering-initial-timeline-spec-string '(":home@sina"))
(add-to-list 'load-path "~/.emacs.d/ace-jump-mode")
(require 'ace-jump-mode)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(add-to-list 'load-path "~/.emacs.d/expand-region.el")
(require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)
(add-to-list 'load-path "~/.emacs.d/mark-multiple.el")
(require 'mark-more-like-this)
(global-set-key (kbd "C-<") 'mark-previous-like-this)
(global-set-key (kbd "C->") 'mark-next-like-this)
(global-set-key (kbd "C-M-m") 'mark-more-like-this) ; like the other two, but takes an argument (negative is previous)
(global-set-key (kbd "C-*") 'mark-all-like-this)
;; M-left M-right M-up M-down to move between buffers and windows
(windmove-default-keybindings 'meta)