在 Ruby China 收集了不少配置,在这里也放出自己的配置及寻求帮助。这几天开始动手写点 Rails,有一个问题还是让我抓狂,就是在编辑 sass、slim 文件自动缩进的问题,我使用了 auto-indent-mode,并设置 tab-width 默认为 2,在 ruby、c++ 缩进方面挺好的,就是 sass、slim 总是不能够正确缩进,手工按 tab 居然不是按 2 个空格来缩进,使用:w 居然把当前选中行缩进了,还有自动补全方面也是很不足。 (setenv "HOME" "D:/Tools/Emacs-24.2") (setenv "PATH" "D:/Tools/Emacs-24.2")
(add-to-list 'load-path "~/.emacs.d/")
;; add extra store (require 'package) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t) (package-initialize)
;; this can auto install missing plugins (when (not package-archive-contents) (package-refresh-contents))
;; add in your own as you wish: (defvar my-package '(starter-kit starter-kit-bindings starter-kit-eshell starter-kit-lisp starter-kit-js starter-kit-ruby auto-complete auto-indent-mode autopair markdown-mode python-mode coffee-mode sass-mode scss-mode slim-mode tabbar tabbar-ruler yasnippet bm smex magit color-theme color-theme-monokai) "A list of packages to ensure are installed at launch.")
(dolist (p my-package) (when (not (package-installed-p p)) (package-install p)))
;; auto-complete (require 'auto-complete-config) (global-auto-complete-mode t) (setq-default ac-sources '(ac-source-words-in-same-mode-buffers)) (add-hook 'emacs-lisp-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-symbols))) (add-hook 'auto-complete-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-filename))) (set-face-background 'ac-candidate-face "lightgray") (set-face-underline 'ac-candidate-face "darkgray") (set-face-background 'ac-selection-face "steelblue") (define-key ac-completing-map "\M-n" 'ac-next) (define-key ac-completing-map "\M-p" 'ac-previous) (setq ac-auto-start t) (setq ac-dwim t)
;; yasnippet (require 'yasnippet) (yas-global-mode 1)
;; scss (setq scss-compile-at-save nil)
;; slim ;;(require 'slim-mode)
;; magit (require 'magit)
;; tabbar (require 'tabbar)
;; auto-indent-mode (setq auto-indent-on-visit-file t) (require 'auto-indent-mode) (auto-indent-global-mode)
;; autopair (require 'autopair) ;;(autopair-global-mode)
;; theme (require 'color-theme) (color-theme-monokai)
;; basic settings (fset 'yse-or-no-p 'y-or-n-p)
(setq-default make-backup-files nil) (setq auto-save-default nil) (setq innibit-startup-message t) (setq initial_scratch-message "")
;;(setq-default comment-style 'indent) (setq-default tab-width 2) (setq-default indent-tabs-mode nil)
(global-linum-mode t) (ido-mode t) (auto-image-file-mode t) (delete-selection-mode t)
;;(column-number-mode t) ;;(show-paren-mode t) ;;(menu-bar-mode t) ;;(scroll-bar-mode -1) ;;(tool-bar-mode -1) ;;(blink-cursor-mode -1) ;;(set-fringe-style -1) ;;(tooltip-mode -1)
;; other package ;; vimpulse (add-to-list 'load-path "~/.emacs.d/vimpulse") (require 'vimpulse)
;; vimpulse-plugins (add-to-list 'load-path "~/.emacs.d/vimpulse-plugins") (require 'vimpulse-cjk) (require 'vimpulse-operator-comment) ;;(require 'vimpulse-operator-moccur) (require 'vimpulse-relative-linum) (require 'vimpulse-textobj-between)
;; auto-complete-clang (add-to-list 'load-path "~/.emacs.d/auto-complete-clang") (require 'auto-complete-clang)
(setq ac-clang-auto-save t) (setq ac-auto-start t) (setq ac-quick-help-delay 0.5) (column-number-mode t) ;; (ac-set-trigger-key "TAB") (define-key ac-mode-map [(control tab)] 'auto-complete) (defun my-ac-config () (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers)) (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup) ;; (add-hook 'c-mode-common-hook 'ac-cc-mode-setup) (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup) (add-hook 'css-mode-hook 'ac-css-mode-setup) (add-hook 'auto-complete-mode-hook 'ac-common-setup) (global-auto-complete-mode t)) (defun my-ac-cc-mode-setup () (setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources))) (add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup) ;; ac-source-gtags (my-ac-config)
;; ide-skel (require 'ide-skel) (partial-completion-mode) (icomplete-mode)
;; code (setq default-buffer-file-coding-system 'utf-8) (prefer-coding-system 'utf-8)
;; shortcut (global-set-key [(control p)] 'tabbar-backward) (global-set-key [(control n)] 'tabbar-forward)
(global-set-key [f4] 'ide-skel-proj-find-files-by-regexp) (global-set-key [f5] 'ide-skel-proj-grep-files-by-regexp) (global-set-key [f10] 'ide-skel-toggle-left-view-window) (global-set-key [f11] 'ide-skel-toggle-bottom-view-window) (global-set-key [f12] 'ide-skel-toggle-right-view-window)
(global-set-key [C-f1] 'package-list-packages) (global-set-key [C-f3] 'revert-buffer) (global-set-key [C-f4] 'kill-this-buffer) (global-set-key [C-f5] 'shell) (global-set-key [C-f6] 'magit-status)
;; emacs auto save (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. '(auto-indent-next-pair-timer-geo-mean (quote ((default 0.0005 0)))) '(blink-cursor-mode nil) '(column-number-mode t) '(fringe-mode (quote (nil . 0)) nil (fringe)) '(menu-bar-mode t) '(show-paren-mode t) '(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. '(tabbar-button-highlight ((t (:inherit tabbar-button)))) '(tabbar-default ((t (:inherit variable-pitch :background "gray82" :foreground "gray50" :height 0.8)))) '(tabbar-highlight ((t nil))) '(tabbar-selected ((t (:inherit tabbar-default :background "white" :foreground "blue" :box (:line-width 1 :color "black"))))) '(tabbar-separator ((t (:inherit tabbar-default :height 0.2)))) '(tabbar-unselected ((t (:inherit tabbar-default :background "gray72" :foreground "black" :box (:line-width 1 :color "black"))))))