Source

usemacs / raw-elisp / march / macos / .emacs

Full commit
;; (set-language-environment "UTF-8")
;; 設置默認字體,我現在喜歡大一點的字體,養眼。
(set-default-font "Monaco-18")

(set-fontset-font "fontset-default"
		  'unicode '("WenQuanYi Micro Hei Mono" . "unicode-bmp"))

;; 黑白色比較容易疲勞,我選了一組不那麽亮眼的組合
(add-to-list 'load-path "~/site-lisp/color-theme")
(require 'color-theme)
(color-theme-initialize)
(color-theme-gnome)

;; transform window
(load-file "~/site-lisp/alpha-window.el")
(global-set-key [(f6)] 'loop-alpha)

;; linum-mode
(global-set-key [(f7)] 'linum-mode)

(add-to-list 'load-path "~/site-lisp/mmm-mode")

(require 'mmm-mode)
;; 将mmm-mode的背景色设深一些,与当前的背景色匹配
;; (set-face-background 'mmm-default-submode-face "DarkBlue")

;; 設置環境
(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.
 '(column-number-mode t)
 '(display-time-mode t)
 '(indent-tabs-mode nil)
 '(show-paren-mode t)
 '(tab-stop-list nil)
 '(tab-width 4))
 
(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.
 )

;; 以下有些設置的作用記不清了,以後慢慢補回吧。
(fset 'yes-or-no-p 'y-or-n-p) ;将yes/no替换为y/n
(column-number-mode t) ; 显示列号
(display-time-mode 1) ; 显示时间
(setq display-time-24hr-format t) ; 24小时格式
(setq display-time-day-and-date t) ; 显示日期
(mouse-avoidance-mode 'animate) ; 光标移动到鼠标下时,鼠标自动弹开
;; (menu-bar-mode nil)
(tool-bar-mode nil)
(setq frame-title-format "March Liu@%b") ; 显示当前编辑的文档
(setq default-tab-width 4)
(setq x-select-enable-clipboard t)

;; mark settings
;; (global-set-key (kbd "C-4") 'push-mark-command) 

(ido-mode t)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-x b") 'ido-switch-buffer) 

(add-to-list 'load-path "~/site-lisp")

;; wrap settings
(require 'wrap-it)
(global-set-key (kbd "C-'") 'wrap-word-quote)
(global-set-key (kbd "C-'") 'wrap-word)

(load-file "~/site-lisp/highlight-regexp.el")

;; 启动emacs server监听
;; (server-mode t)


;; slime settings
(setq inferior-lisp-program "/opt/local/bin/sbcl") ; your Lisp system 
(setq slime-lisp-implementations '((clisp ("/opt/local/bin/clisp"))
                                   (sbcl ("/opt/local/bin/sbcl") :coding-system utf-8-unix)
                                   (ccl ("/Applications/ccl/dx86cl64"))
                                   (ecl ("/opt/local/bin/ecl"))))
(add-to-list 'load-path "~/site-lisp/slime/") ; your SLIME directory 
(require 'slime) 
(slime-setup)

;; scheme settings
(setq scheme-program-name "guile")

;; Haskell mode
(load-file "~/site-lisp/haskell-init.el")

;; set Python mode
;; 代码折叠设置来自 gb@cs.unc.edu, 感谢他。
(add-hook 'python-mode-hook 'python-mode-hook t)

(defun py-outline-level ()
  (let (buffer-invisibility-spec)
	(save-excursion
	  (skip-chars-forward "\t ")
	  (current-column))))

(defun python-mode-hook ()
  ; this gets called by outline to deteremine the level. Just use the length of the whitespace
  (custom-set-variables
   '(indent-tabs-mode nil)
   '(tab-width 4)
   '(tab-stop-list nil)
   )
   ; outline uses this regexp to find headers. I match lines with no indent and indented "class"
  ; and "def" lines.
  ; 这里我利用了 Martin Sand Christensen 提供的正则表达式,感谢他。
  (setq outline-regexp "[^ \t]\\|[ \t]*\\(def\\|class\\|if\\|elif\\|else\\|while\\|for\\|try\\|except\\|finally|with\\) ")
  ; enable our level computation
  (setq outline-level 'py-outline-level)
  ; turn on outline mode
  (outline-minor-mode t)
  ; make paren matches visible
  (show-paren-mode 1))

(setq python-python-command "/usr/local/bin/ipython")
(setq py-python-command-args '("-colors" "Linux"))
(require 'ipython)
(add-to-list 'load-path "~/site-lisp/pyemacs")
(require 'pymacs)
;; (pymacs-load "ropemacs" "rope-")
;; (require 'yasnippet)
;; (yas/initialize)
;; (yas/load-directory "/usr/share/emacs/site-lisp/yasnippet/snippets")
;; (yas/load-directory "~/site-lisp/scala/contrib/yasnippet/snippets")

;; Perl6 Support
;; (defalias 'perl-mode 'cperl-mode)
(autoload 'cperl-mode "cperl-mode" "alternate mode for editing Perl programs" t)

;; Use cperl-mode instead of the default 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 'cperl-mode-hook t)
(defun cperl-mode-hook ()
  (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")
  (cperl-set-style "CPerl")
  (setq cperl-indent-level 4)
)

;; PHP Mode
;; (add-to-list 'auto-mode-alist  
;;              '("\\.php[34]?\\'\\|\\.phtml\\'" . php-mode))  
;; (add-to-list 'auto-mode-alist '("\\.module\\'" . php-mode))  
;; (add-to-list 'auto-mode-alist '("\\.inc\\'" . php-mode))  
(add-hook 'c-mode-hook  
         '(lambda()  
            (setq tab-width 4)  
            (setq c-basic-offset 4)  
            (setq indent-tabs-mode nil)))  

(add-hook 'php-mode-hook  
         '(lambda()  
            (setq tab-width 4)  
            (setq c-basic-offset 4)  
            (setq indent-tabs-mode nil)))  

(add-hook 'objc-mode-hook  
         '(lambda()  
            (setq tab-width 4)  
            (setq c-basic-offset 4)  
            (setq indent-tabs-mode nil)))  

;; latex settings
(load-library "~/site-lisp/latex-settings")

;; Emacs Muse
;; (load "muse-init")

(put 'upcase-region 'disabled nil)

;; psvn
(require 'psvn)

;; dot
(load-library "graphviz-dot-mode")

;; Mercrial
(add-to-list 'load-path "~/site-lisp/mercurial")
(require 'mercurial)

;; git
(add-to-list 'load-path "~/site-lisp/git-emacs")
(require 'git-emacs)
(require 'git-emacs-autoloads)

;; django setting
(require 'django-html-mode)

;;  css setting
(add-hook 'css-mode-hook 
		  '(lambda()
			 (custom-set-variables
			  '(indent-tabs-mode nil)
			  '(tab-width 2))
			 ))

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

;;; turn on syntax highlighting
;; (global-font-lock-mode 1)

;; groovy settings
(add-to-list 'load-path "~/site-lisp/groovy-mode")
;;; use groovy-mode when file ends in .groovy or has #!/bin/groovy at start
(autoload 'groovy-mode "groovy-mode" "Major mode for editing Groovy code." t)
(add-to-list 'auto-mode-alist '("\\.groovy$" . groovy-mode))
(add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode))

;; Applescript settings
(autoload 'applescript-mode "applescript-mode"
   "Major mode for editing AppleScript source." t)
(add-to-list 'auto-mode-alist '("\\.applescript$" . applescript-mode))

;;; make Groovy mode electric by default.
(add-hook 'groovy-mode-hook
          '(lambda ()
             (require 'groovy-electric)
             (groovy-electric-mode)))

;; scala settings
(add-to-list 'load-path "~/site-lisp/scala")
(require 'scala-mode-auto)

;; (add-hook 'scala-mode-hook
;;           '(lambda()  
;;             (setq tab-width 4)
;;             (setq c-basic-offset 4)
;;             (setq indent-tabs-mode nil)
;;             ))

;; ;; ocaml settings
;; (setq auto-mode-alist
;;           (cons '("\\.ml[iyl]?$" .  caml-mode) auto-mode-alist))

;; ;; you should probably comment the next line or replace ~remy by another path 
;; (setq load-path (cons "~/site-lisp/ocaml-mode/" load-path))

;; ;; (autoload 'caml-mode "ocaml" (interactive)
;; ;;   "Major mode for editing Caml code." t)
;; (autoload 'camldebug "camldebug" (interactive) "Debug caml mode")


;; ;; Emacs Lisp Mode Settings
;; (add-hook 'emacs-lisp-hook
;;           '(lambda ()
;;              (setq semanticdb-project-roots 
;;                    (list
;;                     (expand-file-name "/usr/lib/python2.6/")))))

;; MoinMoin setting
;; (require 'moinmoin-mode)

;; regex-tool.el
(load "regex-tool" t)
(setq regex-tool-perl-path "/usr/bin/perl")

;; TRAMP 远程文件编辑支持
(require 'tramp)

;; cedet settings
(add-to-list 'load-path "~/site-lisp/cedet")
(load-file "~/site-lisp/cedet/common/cedet.el")

;; Enable EDE (Project Management) features
(global-ede-mode 1)
;; Enable EDE for a pre-existing C++ project
;; (ede-cpp-root-project "nlpbamboo" :file "~/third-party/nlpbamboo/makefile")

;; (semantic-load-enable-excessive-code-helpers)
(semantic-load-enable-gaudy-code-helpers)
;; * This enables the use of Exuberent ctags if you have it installed.
;;   If you use C++ templates or boost, you should NOT enable it.
;; (semantic-load-enable-all-exuberent-ctags-support)

(global-srecode-minor-mode 1)

(require 'semantic-ia)
(require 'semantic-gcc)

;;设置检索范围
(setq semanticdb-project-roots 
	  (list
       (expand-file-name "/usr/local/lib/python2.7/")
       (expand-file-name "~/site-lisp/")
       (expand-file-name "~/quicklisp/")
       (expand-file-name "~/Document/myself/socrates/src/socrates")
       (expand-file-name "/")));;可以设置为项目的顶级目录

(require 'cogre)
(require 'cedet-contrib)
(cogre-uml-enable-unicode) 


;;绑定按键
;; 三选一
(global-set-key [(control tab)] 'senator-complete-symbol)
;;(global-set-key [(control tab)] ' senator-completion-menu-popup)
;;(global-set-key [(control tab)] 'semantic-ia-complete-symbol-menu)

;; code jump
(global-set-key [f11] 'semantic-ia-fast-jump)
(global-set-key [S-f11]
                (lambda ()
                  (interactive)
                  (if (ring-empty-p (oref semantic-mru-bookmark-ring ring))
                      (error "Semantic bookmark ring is Currently Empty"))
                  (let* ((ring (oref semantic-mru-bookmark-ring))
                         (alist (semantic-mrub-ring-to-assoc-list ring))
                         (first (cdr (car alist))))
                    (if (semantic-equivalent-tag-p (oref first tag)
                                                   (semantic-current-tag))
                        (setq first (cdr (car (cdr alist)))))
                    (semantic-mrub-switch-tags first))))
(global-set-key [M-S-f11] 'semantic-mrub-anlyze-proto-impl-toggle)

(load-file "~/site-lisp/datetime.el")

;; rst mode
(add-hook 'rst-mode-hook '(lambda() 
                            (auto-fill-mode t)))

(require 'pg)
(load-file "~/site-lisp/sql.el")

(load-file "~/site-lisp/org-settings.el")
(setenv "PATH" (concat (getenv "PATH") 
                       ":/usr/local/bin"
                       ":/usr/local/texlive/2010/bin/universal-darwin/"))

;;vimpulse
(require 'vimpulse)