emacsをrails用にカスタマイズ

rinariは使ってたけど、他にもいろいろ便利そうな機能があったので、拡張。

  • rhtml-Mode
  • elscreen-tab
  • snippet
  • line-number

このあたりを導入。

使用しているテーマの背景が黒いため、rhtml-Modeのハイライトが非常に見にくい。
なのでrhtml-fonts.elの

(defface erb-face
  '((((class color) (min-colors 88) (background dark))
     :background "black")

:backgroundをblackに変更。
ハイライトは消えるがrubyブロックの始まりと終わり(<%, %>)はハイライトされているので問題ない。
あとはelscreen-tabがものすごい便利だが、もっとタブの移動を簡略化したかったのでelscreen.elのキーマッピングの部分を以下のように変更
次のタブ:C-z C-n → C-z >
前のタブ:C-z C-p → C-z <
しかし機能しなかった。もしかして.emacsの方で再定義しないとダメ?
でも設定ファイルを書き換えても前のキーマッピングが機能するってどういうことよ?

ちなみに設定した.emacsファイルの内容

;; タブキー
(setq default-tab-width 2)
(setq indent-line-function 'indent-relative-maybe)
;; シフト + 矢印で範囲選択
(setq pc-select-selection-keys-only t)
(pc-selection-mode 1)
;; ウィンドウ設定
;;(set-background-color "Black")
;;(set-foreground-color "White")
;;(set-cursor-color "Gray")

(when (eq window-system 'mac)
  (add-hook 'window-setup-hook
            (lambda ()
              (setq mac-autohide-menubar-on-maximize t)
              (set-frame-parameter nil 'fullscreen 'fullboth)
              )))
(defun mac-toggle-max-window ()
  (interactive)
  (if (frame-parameter nil 'fullscreen)
      (set-frame-parameter nil 'fullscreen nil)
    (set-frame-parameter nil 'fullscreen 'fullboth)))

;;; 対応する括弧を光らせる。
(show-paren-mode 1)
;;;バックアップファイルを作らない
(setq make-backup-files nil)
;;;カーソル行番号表示
(setq line-number-mode t) 
;; ウィンドウを透明化
(add-to-list 'default-frame-alist '(alpha . (0.80 0.80)))
;; スタートアップページを表示しない
(setq inhibit-startup-message t)
;; タイトルバーにファイル名を表示する
(setq frame-title-format "%b")
;; バッファを切り替え補完
(iswitchb-mode 1)

;;; minibuf-isearch
;;; ミニバッファの履歴をC-rでインクリメンタルサーチ
(require 'minibuf-isearch)

;;trampのパスを設定
(add-to-list 'load-path "~/emacs/tramp/lisp/")
(require 'tramp)
(put 'dired-find-alternate-file 'disabled nil)

;;; theme-monokai
(custom-set-faces
 '(default *1 (:foreground "#75715E"))))
 '(font-lock-function-name-face ((((class color) (min-colors 88) (background dark)) (:foreground "#A6E22E"))))
 '(font-lock-keyword-face ((((class color) (min-colors 88) (background dark)) (:foreground "#F92672"))))
 '(font-lock-preprocessor-face *2 (:foreground "#E6DB74"))))
 '(font-lock-type-face ((((class color) (min-colors 88) (background dark)) (:foreground "#66d9ef"))))
 '(font-lock-variable-name-face ((((class color) (min-colors 88) (background dark)) (:foreground "#FD971F"))))
 '(region ((((class color) (min-colors 88) (background dark)) (:background "#49483E"))))
 '(show-paren-match ((((class color) (background dark)) (:background "#3E3D32"))))
 '(variable-pitch *3

;; yasnippetのロード
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "/Applications/Emacs.app/Contents/Resources/lisp/yasnippets-rails/rails-snippets")

;;; line-number 
(require 'linum)
(global-linum-mode t)
(setq linum-format "%5d")

;;; elscreen
(require 'elscreen "ELSCREEN" t)
(require 'elscreen-tab)

;;; css-mode
(autoload 'css-mode "css-mode" nil t)
(setq auto-mode-alist (cons '("\\.css$" . css-mode) auto-mode-alist))
(setq css-indent-level 2)

http://apple-tart.net/dokuwiki/doku.php?id=development_tool:emacs:plugins

*1:t (:stipple nil :background "#000000" :foreground "#F8F8F2" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :family "outline-consolas")))) '(cursor ((t (:background "#F8F8F2" :Foreground "#272822")))) '(font-lock-comment-face ((((class color) (min-colors 88) (background dark

*2:t (:inherit font-lock-builtin-face :foreground "#66d9ef")))) '(font-lock-string-face ((((class color) (min-colors 88) (background dark

*3:t (:family "DejaVu Sans"))))) ;;rinari ;; Interactively Do Things (highly recommended, but not strictly required) (require 'ido) (ido-mode t) ;; Rinari (add-to-list 'load-path "/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/rinari/") (require 'rinari) ;;; rhtml-mode (add-to-list 'load-path "/Applications/Emacs.app/Contents/Resources/lisp/rhtml") (require 'rhtml-mode) (add-hook 'rhtml-mode-hook (lambda () (rinari-launch))) ;; load-pathにyasnippetのパスを通す (setq load-path (cons (expand-file-name "/Applications/Emacs.app/Contents/Resources/lisp/yasnippet") load-path