Skip to content

Instantly share code, notes, and snippets.

@kazshu
Created February 13, 2013 12:10
Show Gist options
  • Select an option

  • Save kazshu/4944179 to your computer and use it in GitHub Desktop.

Select an option

Save kazshu/4944179 to your computer and use it in GitHub Desktop.
;; ~/.emacs.d/lispにパスを通す
(let ((default-directory (expand-file-name "~/.emacs.d/lisp")))
(add-to-list 'load-path default-directory)
(if (fboundp 'normal-top-level-add-subdirs-to-load-path)
(normal-top-level-add-subdirs-to-load-path)))
(setq load-path (cons "~/.emacs.d/emacs-rails" load-path))
(setq load-path (cons "~/.emacs.d/color-theme" load-path))
(setq load-path (cons "~/.emacs.d/auto-install" load-path))
(setq load-path (cons "~/.emacs.d/twittering-mode" load-path))
(setq load-path (cons "~/.emacs.d/auto-complete" load-path))
;; (setq load-path (cons "~/.emacs.d/auto-complete-1.3.1" load-path))
(require 'filecache)
(file-cache-add-directory-list
(list "~" "~/dev/mad/")) ;; ディレクトリを追加
(define-key minibuffer-local-completion-map "\C-c\C-i"
'file-cache-minibuffer-complete)
;; 起動時のサイズ・フレーム
(setq initial-frame-alist
(append (list
'(width . 200)
'(height . 60)
'(top . 0)
'(left . 0)
)
initial-frame-alist))
(setq default-frame-alist initial-frame-alist)
;; ビープ音・画面フラッシュを消す
(setq ring-bell-function 'ignore)
;;(setq visible-bell t)
;; 透過率
(set-frame-parameter (selected-frame) 'alpha '(95 80))
;; color-theme
(require 'color-theme)
(color-theme-initialize)
(color-theme-midnight)
;; カーソルの点滅を止める
(blink-cursor-mode 1)
;;言語を日本語にする
(set-language-environment 'Japanese)
;; 極力UTF-8とする
(prefer-coding-system 'utf-8)
;; 現在行を目立たせる
(global-hl-line-mode 0)
;; モードラインに時間を表示する
(display-time)
;; 選択部分のインデント
(global-set-key "\C-x\C-i" 'indent-region)
;; 1 行ずつスムーズにスクロールする
(setq scroll-step 1)
;; 起動時にスタートアップ画面を表示しない
(setq inhibit-startup-message t)
;; キーバインドの設定
;; optionキーをmetaとして使う
(setq mac-option-modifier 'meta)
;; C-zでUndo
(global-set-key "\C-z" 'undo)
;; C-hでBackspace
(global-set-key (kbd "C-h") 'backward-delete-char)
;; Mac標準のキーボードショートカットを使用
;;(mac-key-mode 1)
;; 行番号表示のオンオフにM-nを割当
(global-set-key "\M-n" 'linum-mode)
;;細かい使い勝手の設定
;; 行番号をデフォルトで表示
(global-linum-mode 1)
(setq linum-format "%4d ")
;; 対応する括弧を光らせる
(show-paren-mode 1)
;; バックアップファイルの設定
(setq backup-directory-alist '(("" . "~/.emacs.d/backup")))
;; 補完
;;; 部分一致の補完機能
(partial-completion-mode t)
;; ディレクトリ
(require 'dired-x)
;; yes,no を y,n に
(fset 'yes-or-no-p 'y-or-n-p)
;; mode-compile
(autoload 'mode-compile "mode-compile"
"Command to compile current buffer file based on the major mode" t)
(global-set-key "\C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
"Command to kill a compilation launched by `mode-compile'" t)
(global-set-key "\C-ck" 'mode-compile-kill)
;; ruby-mode
(autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files" t)
(setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode)) interpreter-mode-alist))
(autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook '(lambda () (inf-ruby-keys)))
;; ruby-electric.el --- electric editing commands for ruby files
(require 'ruby-electric)
(add-hook 'ruby-mode-hook '(lambda () (ruby-electric-mode t)))
;; indent
(setq ruby-indent-level 2)
(setq ruby-indent-tabs-mode nil)
(setq indent-tabs-mode nil)
(require 'untabify-file)
;; newline and indent
(global-set-key "\C-m" 'newline-and-indent)
(setq ns-command-modifier (quote meta))
(setq ns-alternate-modifier (quote super))
;; emacs-rails
(defun try-complete-abbrev (old)
(if (expand-abbrev) t nil))
(setq hippie-expand-try-functions-list
'(try-complete-abbrev
try-complete-file-name
try-expand-dabbrev))
(require 'cl)
(require 'rails)
;; ruby-block
(require 'ruby-block)
(ruby-block-mode t)
;; ミニバッファに表示し, かつ, オーバレイする.
(setq ruby-block-highlight-toggle t)
;; rubydb
(autoload 'rubydb "rubydb3x"
"run rubydb on program file in buffer *gud-file*.
the directory containing file becomes the initial working directory
and source-file directory for your debugger." t)
;; フォントセットを作る
(let* ((fontset-name "myfonts") ; フォントセットの名前
(size 16) ; ASCIIフォントのサイズ [9/10/12/14/15/17/19/20/...]
(asciifont "Ricty") ; ASCIIフォント
(h (* size 10))
(jpfont "Ricty") ; 日本語フォント
(font (format "%s-%d:weight=bold:slant=normal" asciifont size))
(fontspec (font-spec :family asciifont))
(jp-fontspec (font-spec :family jpfont))
(fsn (create-fontset-from-ascii-font font nil fontset-name)))
(set-face-attribute 'default nil :family asciifont :height h)
(set-fontset-font fsn 'japanese-jisx0213.2004-1 jp-fontspec)
(set-fontset-font fsn 'japanese-jisx0213-2 jp-fontspec)
(set-fontset-font fsn 'katakana-jisx0201 jp-fontspec) ; 半角カナ
(set-fontset-font fsn '(#x0080 . #x024F) fontspec) ; 分音符付きラテン
(set-fontset-font fsn '(#x0370 . #x03FF) fontspec) ; ギリシャ文字
)
;; デフォルトのフレームパラメータでフォントセットを指定
(add-to-list 'default-frame-alist '(font . "fontset-myfonts"))
;; フォントサイズの比を設定
(dolist (elt '(("^-apple-hiragino.*" . 1.0)
(".*osaka-bold.*" . 1.0)
(".*osaka-medium.*" . 1.0)
(".*courier-bold-.*-mac-roman" . 1.0)
(".*monaco cy-bold-.*-mac-cyrillic" . 0.9)
(".*monaco-bold-.*-mac-roman" . 0.9)))
(add-to-list 'face-font-rescale-alist elt))
;; デフォルトフェイスにフォントセットを設定
;; # これは起動時に default-frame-alist に従ったフレームが
;; # 作成されない現象への対処
(set-face-font 'default "fontset-myfonts")
;; スクローロバーを非表示
(set-scroll-bar-mode nil)
;; タイトルバー
(setq frame-title-format "%b")
(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.
'(rails-ws:default-server-type "webrick"))
(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.
)
;; rspec-mode
(require 'rspec-mode)
(custom-set-variables '(rspec-use-rake-flag nil))
(custom-set-faces)
;; auto-install
(require 'auto-install)
(setq auto-install-directory "~/.emacs.d/auto-install/")
(auto-install-update-emacswiki-package-name t)
(auto-install-compatibility-setup)
;; anything
(require 'anything-startup)
(define-key global-map (kbd "C-;") 'anything)
;; Emacs が保持する terminfo を利用する
(setq system-uses-terminfo nil)
;; shell の存在を確認
(defun skt:shell ()
(or (executable-find "zsh")
(executable-find "bash")
(executable-find "cmdproxy")
(error "can't find 'shell' command in PATH!!")))
;; Shell 名の設定
(setq shell-file-name (skt:shell))
(setenv "SHELL" shell-file-name)
(setq explicit-shell-file-name shell-file-name)
;; multi-term
(require 'multi-term)
(setq multi-term-program shell-file-name)
(add-to-list 'term-unbind-key-list '"M-x")
(add-hook 'term-mode-hook
'(lambda ()
;; C-h を term 内文字削除にする
(define-key term-raw-map (kbd "C-h") 'term-send-backspace)
;; C-y を term 内ペーストにする
(define-key term-raw-map (kbd "C-y") 'term-paste)
))
(global-set-key (kbd "C-c t") '(lambda ()
(interactive)
(multi-term)))
(global-set-key (kbd "C-c t") '(lambda ()
(interactive)
(if (get-buffer "*terminal<1>*")
(switch-to-buffer "*terminal<1>*")
(multi-term))))
(global-set-key (kbd "C-c n") 'multi-term-next)
(global-set-key (kbd "C-c p") 'multi-term-prev)
(require 'recentf-ext)
(setq recentf-max-saved-items 1000)
;; (recentf-mode 1)
;; feature-mode
(require 'feature-mode)
(eval-when-compile (require 'cl))
;;
;; Keywords and font locking
;;
(defconst feature-mode-keywords
'("Feature" "Scenario", "Given", "Then", "When", "And", "フィーチャ", "シナリオ", "前提", "ならば", "かつ"))
(cond
((featurep 'font-lock)
(or (boundp 'font-lock-variable-name-face)
(setq font-lock-variable-name-face font-lock-type-face)))
(set (make-local-variable 'font-lock-syntax-table) feature-font-lock-syntax-table))
(defconst feature-font-lock-keywords
(list
'("^ *Feature:" (0 font-lock-keyword-face) (".*" nil nil (0 font-lock-type-face t)))
'("^ *Scenario\\(?: Outline\\)?:" (0 font-lock-keyword-face) (".*" nil nil (0 font-lock-function-name-face t)))
'("^ *Given" . font-lock-keyword-face)
'("^ *When" . font-lock-keyword-face)
'("^ *Then" . font-lock-keyword-face)
'("^ *And" . font-lock-keyword-face)
'("^ *フィーチャ:" (0 font-lock-keyword-face) (".*" nil nil (0 font-lock-type-face t)))
'("^ *シナリオ\\(?:アウトライン\\)?:" (0 font-lock-keyword-face) (".*" nil nil (0 font-lock-function-name-face t)))
'("^ *背景" . font-lock-keyword-face)
'("^ *前提" . font-lock-keyword-face)
'("^ *もし" . font-lock-keyword-face)
'("^ *ならば" . font-lock-keyword-face)
'("^ *かつ" . font-lock-keyword-face)
'("^ *\\(?:More \\)?Examples:" . font-lock-keyword-face)
'("^ *#.*" 0 font-lock-comment-face t)
))
;; yaml-mode
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;; twittering-mode
;;(require 'twittering-mode) なんか面倒っぽい
;; coffee-mode
(add-to-list 'load-path "~/.emacs.d/vendor/coffee-mode")
(require 'coffee-mode)
(add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
(add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode))
(defun coffee-custom ()
"coffee-mode-hook"
(set (make-local-variable 'tab-width) 2))
(add-hook 'coffee-mode-hook
'(lambda() (coffee-custom)))
;; auto-complete
;; (require 'auto-complete)
;; (require 'auto-complete-config)
;; (global-auto-complete-mode t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment