my emacs fav config

(setenv "PATH" (concat "/usr/local/bin:"(getenv "PATH") ))
(setenv "GOPATH" "/Volumes/untitled/sgt/fpj/src/go")

; misc
(turn-on-font-lock)
(setq default-truncate-lines 1)
(set-background-color "black")
(set-foreground-color "white")
(set-cursor-color "white")
(setq-default indent-tabs-mode nil)

; hide tool bar
(tool-bar-mode -1)

; set misc
;(setq default-directory "z:/projects")

(load-file "/Applications/Emacs.app/Contents/Resources/lisp/graphviz-dot-mode.el")

; modes
;(add-to-list 'load-path "D:/usr/emacs-22.3/lisp/progmodes")
;php mode
;(load "php-mode")
;(add-to-list 'auto-mode-alist '("\\.php[34]?\\'\\|\\.phtml\\'" . php-mode))

;(autoload 'flex-mode "flex-mode" nil t)
(require 'godot-gdscript)
;(add-to-list 'auto-mode-alist (cons (purecopy "\\.gd\\'") 'godot-gdscript-mode))
;(add-to-list 'interpreter-mode-alist (cons (purecopy "godot-gdscript[0-9.]*") 'godot-gdscript-mode))

;flex mode
(autoload 'flex-mode "flex-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.l$" . flex-mode))

;bison mode
(autoload 'bison-mode "bison-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.y$" . bison-mode))

;javascript mode
(autoload 'javascript-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . javascript-mode))

;;actionscript mode
;; actionscript
; "Symbol's value as variable is void: running-on-x"といわれたので。
; via http://blog.pettomato.com/content/site-lisp/.emacs
(defvar running-on-x (eq window-system 'x))
(autoload 'actionscript-mode "actionscript-mode" "Major mode for actionscript." t)
;; Activate actionscript-mode for any files ending in .as
(add-to-list 'auto-mode-alist '("\\.as$" . actionscript-mode))
;; Load our actionscript-mode extensions.
(eval-after-load "actionscript-mode" '(load "as-config"))

;(autoload 'actionscript-mode "actionscript-mode"
;"Major mode for editing ActionScript files." t)
;(add-to-list 'auto-mode-alist '("\\.as[123]?$" . actionscript-mode))

;; actionscript
;(autoload 'actionscript-mode "actionscript-mode" "Major mode for actionscript." t)
;(add-to-list 'auto-mode-alist '("\\.as$" . actionscript-mode))
;(eval-after-load "actionscript-mode" '(load "actionscript-config"))

;sgml mode
(add-to-list 'hs-special-modes-alist
'(sgml-mode
"<!--\\|<[^/>]*[^/]>" ;; regexp for start block
"-->\\|</[^/>]*[^/]>" ;; regexp for end block
"<!--" ;; regexp for comment start. (need this??)
sgml-skip-tag-forward
nil))


(put 'upcase-region 'disabled nil)

(put 'downcase-region 'disabled nil)

(setq c-default-style "bsd"
c-basic-offset 4)

;cg-mode
(setq load-path (cons "/Applications/Emacs.app/Contents/Resources/lisp/" load-path))
(require 'cg-mode)

;csharp
(autoload 'csharp-mode "csharp-mode" "Major mode for editing C# code." t)
(setq auto-mode-alist
(append '(("\\.cs$" . csharp-mode)) auto-mode-alist))

;glsl
(autoload 'glsl-mode "glsl-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.glsl\\'" . glsl-mode))
(add-to-list 'auto-mode-alist '("\\.vert\\'" . glsl-mode))
(add-to-list 'auto-mode-alist '("\\.frag\\'" . glsl-mode))
(add-to-list 'auto-mode-alist '("\\.geom\\'" . glsl-mode))

;;povray
;(add-to-list 'load-path "C:/Program Files/emacs-22.3/lisp/pov-mode-3.2")
;(autoload 'pov-mode "pov-mode" "PoVray scene file mode" t)
;(add-to-list 'auto-mode-alist '("\\.pov\\'" . pov-mode))
;(add-to-list 'auto-mode-alist '("\\.inc\\'" . pov-mode))
;
;;rib
;(add-to-list 'load-path "C:/Program Files/emacs-22.3/lisp/progmodes")
;(autoload 'rib-mode "rib-mode" "renderman scene file mode" t)
;(add-to-list 'auto-mode-alist '("\\.rib\\'" . rib-mode))
;
;;rls
;(autoload 'rsl-mode "rsl-mode" "renderman shader language mode" t)
;(add-to-list 'auto-mode-alist '("\\.sl\\'" . rsl-mode))
;(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.
; '(current-language-environment "UTF-8")
; '(tool-bar-mode nil))
;(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.
; )
;
;;;(defun copy-word (&optional arg)
;;; "Copy words at point into kill-ring"
;;; (interactive "P")
;;; (copy-thing 'backward-word 'forward-word arg)
;;; ;;(paste-to-mark arg)
;;; )
;
(defun copy-word (&optional arg)
"Copy words at point"
(interactive "P")
(let ((beg (progn (if (looking-back "[a-zA-Z0-9\_\-]" 1) (backward-word 1)) (point)))
(end (progn (forward-word arg) (point))))
(copy-region-as-kill beg end))
)

(global-set-key (kbd "C-c w") (quote copy-word))


(defun copy-paragraph (&optional arg)
"Copy paragraphes at point"
(interactive "P")
(let ((beg (progn (backward-paragraph 1) (point)))
(end (progn (forward-paragraph arg) (point))))
(copy-region-as-kill beg end))
)

(global-set-key (kbd "C-c p") (quote copy-paragraph))


(defun get-point (symbol &optional arg)
"get the point"
(funcall symbol arg)
(point))

(defun copy-thing (begin-of-thing end-of-thing &optional arg)
"copy thing between beg & end into kill ring"
(save-excursion
(let ((beg (get-point begin-of-thing 1))
(end (get-point end-of-thing arg)))
(copy-region-as-kill beg end))))

(defun paste-to-mark(&optional arg)
"Paste things to mark, or to the prompt in shell-mode"
(let ((pasteMe
(lambda()
(if (string= "shell-mode" major-mode)
(progn (comint-next-prompt 25535) (yank))
(progn (goto-char (mark)) (yank) )))))
(if arg
(if (= arg 1)
nil
(funcall pasteMe))
(funcall pasteMe))))

;;; "[\(\)\,\.\;\&\-\<\>\"\[\]\=\{\}]"
(defun beginning-of-string(&optional arg)
" "
(re-search-backward "[ \t\(\)\,\.\;\&\-\<\>\"\=\{\}]" (line-beginning-position) 3 1)
(if (looking-at "[\t \(\)\,\.\;\&\-\<\>\"\=\{\}]") (goto-char (+ (point) 1)) ))


(defun end-of-string(&optional arg)
" "
(re-search-forward "[ \t\(\)\,\.\;\&\-\<\>\"\=\{\}]" (line-end-position) 3 arg)
(if (looking-back "[\t \(\)\,\.\;\&\-\<\>\"\=\{\}]") (goto-char (- (point) 1)) ))

(defun thing-copy-string-to-mark(&optional arg)
" Try to copy a string and paste it to the mark
When used in shell-mode, it will paste string on shell prompt by default "
(interactive "P")
(copy-thing 'beginning-of-string 'end-of-string arg))

(global-set-key (kbd "C-c s") (quote thing-copy-string-to-mark))

(defun copy-line (&optional arg)
"Save current line into Kill-Ring without mark the line "
(interactive "P")
(copy-thing 'beginning-of-line 'end-of-line arg))

(global-set-key (kbd "C-c l") (quote copy-line))

; header
; save
;;(autoload 'auto-update-file-header "header2")
;;(add-hook 'write-file-hooks 'auto-update-file-header)

; insert new
(autoload 'auto-make-header "header2")
(add-hook 'c-mode-common-hook 'auto-make-header)
(add-hook 'python-mode-hook 'auto-make-header)
(add-hook 'go-mode-hook 'auto-make-header)

(add-to-list 'load-path "/Applications/Emacs.app/Contents/Resources/lisp/")
(require 'go-mode-autoloads)

posted @ 2014-08-10 16:48  mweiguo  阅读(275)  评论(0编辑  收藏  举报