my .emacs



;; initial window size
(setq initial-frame-alist '((top . 0) (left . 100) (width . 120) (height . 42)))

;;Remove the startup welcome screen
(setq inhibit-startup-message t)

;;Ctrl+mouse wheel zoom font
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)

;;Don't keep asking yes or no, why can't you use y/n
(fset 'yes-or-no-p 'y-or-n-p)

;;Enable highlighting #Mx global-font-lock-mode
(global-font-lock-mode t)

;; indicates parentheses match
(show-paren-mode t)
(setq show-paren-style 'parentheses)

;;Display column number
;;(setq column-number-mode 0)
;;(setq line-number-mode t)
;;Display line numbers on the left
(global-linum-mode 'linum-mode)

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

;;When the cursor is close to the mouse, let the mouse move away automatically, don't block the line of sight
;;(mouse-avoidance-mode 'animate)

;;Smooth scrolling, when the cursor is in the last line, when the next line jumps, there is a clear jumping feeling
(setq scroll-margin 2
      scroll-conservatively 10000)

;;Disable auto save
;(auto-save-mode nil)

;;buffer window shortcut
(global-set-key [C-return] 'kill-this-buffer);C-return closes the current buffer
(global-set-key [f10] 'split-window-vertically); F10 split window
(global-set-key [f11] 'delete-other-windows);F11 close other windows

;;The default is to display 80 columns and wrap the line
(setq default-fill-column 80)

;;Set the line spacing
(setq-default line-spacing 2)

;;Do not generate temporary files
(setq-default make-backup-files nil);

;;The title bar at the top of Emacs displays the file name
(setq frame-title-format " %b")

;; Highlight the current line
;(global-hl-line-mode)

;;Display the time in the column below
(display-time-mode 1)
;;Use 24-hour clock
(setq display-time-24hr-format t)

;;The cursor is a vertical line
(setq-default cursor-type 'bar)

;;Set the default directory for opening files
;(setq default-directory "f:/workspace")

;;Hide the menu bar, scroll bar on the right;;(menu-bar-mode nil)
(menu-bar-mode 0)
(tool-bar-mode 0)  
(scroll-bar-mode 0)  

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

;;automatic completion
(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)

;;------------Locale charset setting (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))				
;default font
(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)

;;Cursor color
(set-cursor-color "green")

;; Set Tab to 4 characters
(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)))

;; replace string in all currently open buffers
(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+up and down keys, move a line of content
;;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)

;;transparent opaque
(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 copy the entire line where the cursor is located, Alt+k, copy the content behind the cursor in the current line
;; 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)

;; Code Template - 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

;;Modified js/jsp/html/htm/jsp/css files are automatically deployed to tomcat when saved
(add-hook 'after-save-hook (lambda() (auto-deploy-to-tomcat)))

;;Copy the current buffer to the corresponding directory under the webapp of tomcat
(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)))

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327028919&siteId=291194637