我的.emacs



;;窗口初始大小
(setq initial-frame-alist '((top . 0) (left . 100) (width . 120) (height . 42)))

;;去掉启动欢迎界面
(setq inhibit-startup-message t)

;;Ctrl+鼠标滚轮缩放字体
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)

;;不要总是没完没了的问yes or no, 为什么不能用 y/n
(fset 'yes-or-no-p 'y-or-n-p)

;;打开高亮 #M-x global-font-lock-mode
(global-font-lock-mode t)

;;示括号匹配
(show-paren-mode t)
(setq show-paren-style 'parentheses)

;;显示列号
;;(setq column-number-mode 0)
;;(setq line-number-mode t)
;;在左侧显示行号
(global-linum-mode 'linum-mode)

;;set mark
(global-set-key (kbd "M-SPC") 'set-mark-command)

;;光标靠近鼠标的时候,让鼠标自动让开,别挡住视线
;;(mouse-avoidance-mode 'animate)

;;平滑滚动, 在光标在最后一行的时候,继续下一行跳动的时候,有明显的跳动感觉
(setq scroll-margin 2
      scroll-conservatively 10000)

;;禁止自动保存
;(auto-save-mode nil)

;;buffer 窗口快捷
(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 关闭其它窗口

;;默认显示 80列就换行
(setq default-fill-column 80)

;;设置行间距
(setq-default line-spacing 2)

;;不要生成临时文件
(setq-default make-backup-files nil);

;;Emacs顶部标题栏显示文件名
(setq frame-title-format " %b")

;;高亮显示当前行
;(global-hl-line-mode)

;;在下面栏中显示时间
(display-time-mode 1)
;;使用24小时制
(setq display-time-24hr-format t)

;;光标为竖线
(setq-default cursor-type 'bar)

;;设置打开文件的缺省目录
;(setq default-directory "f:/workspace")

;;隐藏菜单栏、右侧的滚动条 ;;(menu-bar-mode nil)
(menu-bar-mode 0)
(tool-bar-mode 0)  
(scroll-bar-mode 0)  

(add-to-list 'load-path "~/.emacs.d")

;;自动完成
(add-to-list 'load-path "~/.emacs.d/auto-complete")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/ac-dict")
(ac-config-default)

;;------------语言环境字符集设置(utf-8)-------------
(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-selection-coding-system 'utf-8)
(modify-coding-system-alist 'process "*" 'utf-8)
(setq default-process-coding-system '(utf-8 . utf-8))
(setq-default pathname-coding-system 'utf-8)
(set-file-name-coding-system 'utf-8)
(setq ansi-color-for-comint-mode t)
(setq file-name-coding-system 'utf-8)
(setq path-name-coding-system 'utf-8)
(if (eq system-type 'windows-nt)
    (setq file-name-coding-system 'gbk))				
;默认字体
(set-default-font "Courier New-12")

;;package
(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)

;; color-theme
(require 'color-theme)
;(color-theme-initialize)
;(color-theme-gnome2)
(color-theme-classic)

;;光标颜色
(set-cursor-color "green")

;; 设置Tab为4个字符
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
      (setq tab-stop-list (cons (* x 4) tab-stop-list)))

;; 在当前所有打开的buffer中替换字符串
(defun query-replace-in-open-buffers (arg1 arg2)
  "query-replace in all open files"
  (interactive "sRegexp:\nsReplace with:")
  (mapcar
   (lambda (x)
     (find-file x)
     (save-excursion
       (goto-char (point-min))
       (query-replace-regexp arg1 arg2)))
   (delq
    nil
    (mapcar
     (lambda (x)
       (buffer-file-name x))
     (buffer-list)))))

;;Alt+上下键,移动一行内容
;;move line up down
(defun move-text-internal (arg)
  (cond
   ((and mark-active transient-mark-mode)
    (if (> (point) (mark))
        (exchange-point-and-mark))
    (let ((column (current-column))
          (text (delete-and-extract-region (point) (mark))))
      (forward-line arg)
      (move-to-column column t)
      (set-mark (point))
      (insert text)
      (exchange-point-and-mark)
      (setq deactivate-mark nil)))
   (t
    (let ((column (current-column)))
      (beginning-of-line)
      (when (or (> arg 0) (not (bobp)))
        (forward-line)
        (when (or (< arg 0) (not (eobp)))
          (transpose-lines arg))
        (forward-line -1))
      (move-to-column column t)))))

(defun move-text-down (arg)
  "Move region (transient-mark-mode active) or current line arg lines down."
  (interactive "*p")
  (move-text-internal arg))

(defun move-text-up (arg)
  "Move region (transient-mark-mode active) or current line  arg lines up."
  (interactive "*p")
  (move-text-internal (- arg)))

(global-set-key [M-up] 'move-text-up)
(global-set-key [M-down] 'move-text-down)

;;透明不透明
(global-set-key [(f8)] 'loop-alpha)
(setq alpha-list '((75 55) (100 100)))

(defun loop-alpha ()    
  (interactive)    
  (let ((h (car alpha-list)))                    
    ((lambda (a ab)    
       (set-frame-parameter (selected-frame) 'alpha (list a ab))    
       (add-to-list 'default-frame-alist (cons 'alpha (list a ab)))    
       ) (car h) (car (cdr h)))    
    (setq alpha-list (cdr (append alpha-list (list h))))))

;;Alt+w 复制光标所在一整行,Alt+k,复制当前行光标后面的内容
;; Smart copy, if no region active, it simply copy the current whole line
(defadvice kill-line 
  (before check-position activate) 
  (if (member major-mode 
			  '(emacs-lisp-mode scheme-mode lisp-mode c-mode c++-mode objc-mode js-mode latex-mode plain-tex-mode)) 
	  (if (and (eolp) (not (bolp))) 
		  (progn (forward-char 1) (just-one-space 0) (backward-char 1)))))

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

 (defadvice kill-region (before slick-cut 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)))))

;; Copy line from point to the end, exclude the line break 
(defun qiang-copy-line (arg) 
  "Copy lines (as many as prefix argument) in the kill ring" 
  (interactive "p") 
  (kill-ring-save (point) (line-end-position)) 
  (line-beginning-position (+ 1 arg)))
(global-set-key (kbd "M-k") 'qiang-copy-line)

;;代码模板- yasnippet
(yas-global-mode 1)

;;js2-mode
(require 'js2-mode);
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))

;;----- clojure-mode ------
(add-to-list 'load-path "~/.emacs.d/clojure")
(require 'clojure-mode);
;;slime
(eval-after-load "slime" 
  '(progn (slime-setup '(slime-repl))))
(add-to-list 'load-path "~/.emacs.d/slime")
(require 'slime)
(slime-setup)

(load-file "~/.emacs.d/wdy.el");



wdy.el

;;修改过的 js/jsp/html/htm/jsp/css 文件在保存时自动部署到tomcat下
(add-hook 'after-save-hook (lambda() (auto-deploy-to-tomcat)))

;;复制当前buffer到tomcat的webapp下对应的目录中
(setq tomcat-path "D:/Program Files/Apache Software Foundation/Apache Tomcat 6.0.20/webapps/")
(defun auto-deploy-to-tomcat()
  "Copy me to the Tomcat WebApps"
  (interactive)
  (if (string-match ".*/\\(.*\\)/WebRoot\\(.*\\)/.*\\(.js\\|.jsp\\|.css\\|.html\\|.htm\\|.jsp\\)" buffer-file-name)
	  (let ((target-path (concat tomcat-path (match-string 1 buffer-file-name) (match-string 2 buffer-file-name))))
		(message (concat "Copy current buffer To: " target-path ))
		(copy-file buffer-file-name target-path t))))


;;SVN update
;(global-set-key [(F5)]  'svn-update)
(defun svn-update()
  "Svn update"
  (interactive)
  (let ((cmd (concat "TortoiseProc.exe /command:update /path:\"" buffer-file-name "\" /closeonend:0")))
    (message cmd)
  (shell-command cmd)))

;(global-set-key [(F12)]  'svn-commit)
(defun svn-commit()
  "Svn commit"
  (interactive)
  (let ((cmd (concat "TortoiseProc.exe /command:commit /path:\"" buffer-file-name "\" /closeonend:0")))
    (message cmd)
  (shell-command cmd)))

;;SVN diff
;(global-set-key [(F5)]  'svn-diff)
(defun svn-diff()
  "Svn diff"
  (interactive)
  (let ((cmd (concat "TortoiseProc.exe /command:diff /path:\"" buffer-file-name "\" /closeonend:0")))
    (message cmd)
  (shell-command cmd)))

猜你喜欢

转载自wondery.iteye.com/blog/1828812
今日推荐