;--------------------------This is the main Emacs initialization file - .emacs.--------------------------------
;--------------------------emacs -batch -f batch-byte-compile emacs-linux--------------------------------
(add-to-list 'load-path (expand-file-name "~/.emacs.d/site-lisp"))
(setq major-mode 'text-mode);一打开就起用 text 模式
(add-hook 'text-mode-hook 'turn-on-auto-fill);启用自动填充模式
;(server-start)
;-----------------------------------------------------设置编码------------------------------------------------
(setq current-language-environment "UTF-8")
;(setq local-coding-system 'utf-8)
;(set-keyboard-coding-system 'utf-8)
;(set-terminal-coding-system 'utf-8)
;(set-selection-coding-system 'utf-8)
;(prefer-coding-system 'utf-8))
;-----------------------------------------------------设置外观----------------------------------------------------
;最大化
(require 'maxframe)
(add-hook 'window-setup-hook 'maximize-frame t)
;去掉滚动条,因为可以使用鼠标滚轮了 ^_^
(scroll-bar-mode nil)
;去掉那个大大的工具栏
(tool-bar-mode nil)
;滚动条放到右边
;(customize-set-variable 'scroll-bar-mode 'right)
;;Theme
(require 'color-theme)
(color-theme-arjen)
(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线。很好玩阿,这个功能
(column-number-mode t);显示列号
(require 'linum)
(global-linum-mode 1)
;显示时间以及格式
(display-time)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-interval 10)
;----------------------------------------------------------设置字体-----------------------------------------
;; Setting English Font
(set-face-attribute
'default nil :font "Droid Sans Mono 10")
;; Chinese Font
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "微软雅黑" :size 13)))
;--------------------------------------------------------按键绑定-------------------------------------------
;;鼠标滚轮,默认的滚动太快,这里改为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)
(global-set-key (kbd "C-z") 'undo);;重新绑定C-z到撤销
;(global-set-key (kbd "C-v") 'yank);粘贴
(global-set-key [delete] 'delete-char);delete 删除一个字符
(global-set-key (kbd "
(global-set-key (kbd "
;-------------------------------------------------全局设置---------------------------------------------------
;关闭烦人的出错时的提示声
(setq visible-bell t)
;设置自动对齐
(setq autoindent)
(fset 'yes-or-no-p 'y-or-n-p);用y/n代替yes/no
(show-paren-mode t);高亮显示成对括号,但不来回弹
(setq show-paren-style 'parentheses)
(global-font-lock-mode t);语法高亮
(setq font-lock-maximum-decoration t);让emacs最大限度的“彩色化”你的程序
(auto-image-file-mode t);打开图片显示功能
(require 'hl-line) ;高亮当前行
(global-hl-line-mode t)
(setq default-directory "E:/Projects")
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(blink-cursor-mode nil);;光标不闪
(setq-default cursor-type 'bar);;光标显示为一竖线
(setq frame-title-format "%S: %f");标题栏显示 %f 缓冲区完整路径 %p 页面百分数 %l 行号
(setq default-fill-column 80);默认显示 80列就换行
(setq-default auto-fill-function 'do-auto-fill)
(setq inhibit-startup-message t);去掉每次启动emacs出来的无用的“信息”
(setq kill-ring-max 200) ;emacs cut(C-w, C-k)命令会把你所有cut掉的部分都存起来,
;之后可以用M-y 一个一个的调出来。set 这个值为最多存档两百个这样的命令
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4);tab宽度为4
;记录修改时间, 缺省的情况下, 在所编辑文件的前八行内插入如下标记
;Time-stamp: <> 或者 Time-stamp: " "
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-format " %04y/%02m/%02d %02H:%02M:%02S by %:u ")
;(setq time-stamp-start "最后修改时间: <[ ]+\\\\?")
(transient-mark-mode t);高亮选择
(setq-default make-backup-files nil);不要生成临时文件
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
(setq tab-stop-list (cons (* x 4) tab-stop-list)))
(setq scroll-margin 5)
(setq scroll-step 1)
(setq sort-fold-case t);emacs有不少和sort有关的命令。缺省设置是分大小写的,但大多数时候我们都希望不分大小写
(setq auto-save-default nil);;不生成#F#文件
(setq-default abbrev-mode t);; ensure abbrev mode is always on
(setq save-abbrevs nil);; do not bug me about saving my abbreviations
(setq default-frame-alist
'((height . 30) (width . 100) (menu-bar-lines . 20) (tool-bar-lines . 0)))
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;---------------------------------------------版本控制---------------------------------------------------
(setq version-control t)
(setq kept-new-versions 3)
(setq delete-old-versions t)
(setq kept-old-versions 2)
(setq dired-kept-versions 1)
;------------------------------------------------yasnippet-----------------------------------------------
(add-to-list 'load-path "~/.emacs.d/site-lisp/yasnippet")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/site-lisp/yasnippet/snippets")
;-------------------------------------------------auto-complete----------------------------------------
(add-to-list 'load-path "~/.emacs.d/site-lisp/auto-complete")
;; After do this, isearch any string, M-: (match-data) always
;; return the list whose elements is integer
(require 'auto-complete)
(require 'auto-complete-config)
;一定要在(require 'auto-complete-config),否则会报错,或者用setq或者eval-after-load
(add-to-list 'ac-dictionary-directories "~/.emacs.d/site-lisp/auto-complete/dict")
(global-auto-complete-mode t)
(ac-config-default)
(setq ac-auto-show-menu 0.2)
(setq ac-menu-height 20)
(set-face-background 'ac-candidate-face "lightgray")
(set-face-underline 'ac-candidate-face "darkgray")
(set-face-background 'ac-selection-face "steelblue")
(setq ac-use-menu-map t)
(define-key ac-menu-map "\C-n" 'ac-next)
(define-key ac-menu-map "\C-p" 'ac-previous)
(set-default 'ac-sources
'(ac-source-yasnippet
ac-source-abbrev
ac-source-words-in-buffer
ac-source-words-in-all-buffer
ac-source-imenu
ac-source-files-in-current-dir
ac-source-filename))
;---------------------------------自动补全括号,括号自动配对--------------------------------------
(defun my-common-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(? ? _ "''")
(? ? _ """")
(? ? _ "()")
(? ? _ "[]")
(?{ \n > _ \n ?} >)))
(setq skeleton-pair t)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "\'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'LaTeX-mode-hook 'my-common-mode-auto-pair)
(add-hook 'c-mode-hook 'my-common-mode-auto-pair)
(add-hook 'c++-mode-hook 'my-common-mode-auto-pair)
(add-hook 'verilog-mode-hook 'my-common-mode-auto-pair)
(add-hook 'php-mode-hook 'my-common-mode-auto-pair)
;---------------------------------------------------------Verilog-----------------------------------------------
;;Verilog mode
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
(add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode))
(setq verilog-auto-newline nil)
(setq verilog-tab-always-indent nil)
;---------------------------------------------------------Auctex----------------------------------------------
;(load "~/site-lisp/site-start.d/auctex.el" nil t t)
;(setq TeX-auto-save t)
;(setq TeX-parse-self t)
;(setq-default TeX-master nil)
;(load "~/site-lisp/site-start.d/preview-latex.el" nil t t)
;(add-hook 'LaTeX-mode-hook
; (lambda ()
; (setq TeX-auto-untabify t ; remove all tabs before saving
; TeX-engine 'xetex ; use xelatex default
; TeX-show-compilation t) ; display compilation windows
; (TeX-global-PDF-mode t) ; PDF mode enable, not plain
; (setq TeX-save-query nil)
; (imenu-add-menubar-index)
; (define-key LaTeX-mode-map (kbd "TAB") 'TeX-complete-symbol)))
;(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-save-query nil )(setq TeX-show-compilation t)))
;(mapc (lambda (mode)
; (add-hook 'LaTeX-mode-hook mode))
; (list 'auto-fill-mode
; 'LaTeX-math-mode
; 'turn-on-reftex
; 'linum-mode))
;(setq default-frame-alist
; '((height . 30) (width . 100) (menu-bar-lines . 20) (tool-bar-lines . 0)))
;(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);把这些缺省禁用的功能打开
;(setq default-fill-column 150);;;; 150列就换行
;-------------------------------------------------html----------------------------------------------
;(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
; (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
;(setq tempo-interactive t)
;----------------------------------------------PHP----------------------------------------
(require 'php-mode)
(add-hook 'php-mode-user-hook 'turn-on-font-lock)
;-----------------------------------------VHDL---------------------------------------------
(setq vhdl-upper-case-keywords t)
(setq vhdl-upper-case-types t)
(setq vhdl-upper-case-attributes t)
(setq vhdl-upper-case-enum-values t)