rails.elからrinariに乗り換えてみました。
\C-c , f v でView
rails.elのときは、\C-c (\C-p,\C-n) の2タッチで切り替えを
行っていたので、まだ違和感があります。![叫び](https://stat.ameba.jp/blog/ucs/img/char/char2/254.gif)
4タッチはECBでも同様なので、慣れないといけない。![パンチ!](https://stat.ameba.jp/blog/ucs/img/char/char2/043.gif)
置き換えることは可能ですが、今はまだ、なるべく標準で慣れたいっす。
いずれ慣れるでしょう
とのんきなpekoshiでした。
ではでは。
以下、.emacs(10/05/04現在、いろんなところを参考にしているので、整理してません。
)
>rinari.el
>ack-grepでgrepするように改造しています。
(defun rinari-rgrep (&optional arg)
"Search through the rails project for a string or `regexp'.
With optional prefix argument just run `rgrep'."
(interactive "P")
(grep-compute-defaults)
(if arg (call-interactively 'rgrep )
(let ((query))
(if mark-active
(setq query (buffer-substring-no-properties (point) (mark)))
(setq query (thing-at-point 'word)))
; (funcall 'rgrep (read-from-minibuffer "search for: " query)
(rgrep (concat "ack-grep --nocolor --nogroup " (read-from-minibuffer "search for: " query) " -G "
rinari-rgrep-file-endings " " (rinari-root))))))
>~/.emacs
;; ~/elisp をライブラリパスに追加
(setq load-path
(append
(list
(expand-file-name "~/elisp/")
)
load-path))
(setq load-path
(append
(list
(expand-file-name "~/elisp/themes")
)
load-path))
;;; 初期フレームの設定
(setq initial-frame-alist
(append
'((top . 0) ; フレームの Y 位置(ピクセル数)
(left . 0) ; フレームの X 位置(ピクセル数)
(width . 80) ; フレーム幅(文字数)
(height . 50)) ; フレーム高(文字数)
initial-frame-alist))
;;; 新規フレームのデフォルト設定
(setq default-frame-alist
(append
'((width . 80) ; フレーム幅(文字数)
(height . 50)) ; フレーム高(文字数)
default-frame-alist))
; emacs23 font
(cond ( (string-match "^23\." emacs-version)
(cond (window-system
(set-default-font "Takaoゴシック-9")
(set-fontset-font (frame-parameter nil 'font)
'japanese-jisx0208
'("Takaoゴシック" . "unicode-bmp"))
; '("IPAGothic" . "unicode-bmp"))
; '("Yutapon coding Heavy" . "unicode-bmp"))
; '("Hiragino Gothic" . "unicode-bmp"))
))))
;;; ホイールマウス
(mouse-wheel-mode t)
(setq mouse-wheel-follow-mouse t)
;;; 対応する括弧を光らせる。
(show-paren-mode 1)
;; 改行コードを表示
(setq eol-mnemonic-dos "(CRLF)")
(setq eol-mnemonic-mac "(CR)")
(setq eol-mnemonic-unix "(LF)")
(require 'sense-region)
(defadvice set-mark-command (around sense-region-set-mark-23 activate)
(if (and (mell-transient-region-active-p)
sense-region-mode)
(copy-face 'region 'sense-region-region-face))
ad-do-it)
(sense-region-on)
;; キーワードのカラー表示を有効化
(global-font-lock-mode t)
;; 全角空白、Tab、改行表示
(require 'jaspace)
(setq jaspace-alternate-jaspace-string "□")
(setq jaspace-alternate-eol-string "↓\n")
(setq jaspace-highlight-tabs t)
(setq jaspace-modes
(append jaspace-modes
'(scheme-mode php-mode yaml-mode js-mode ruby-mode text-mode fundamental-mode LaTeX-mode)))
; tab
(setq elscreen-prefix-key "\C-t")
(setq elscreen-tab-width 12)
(setq elscreen-tab-display-kill-screen nil)
(require 'elscreen "ELSCREEN" t)
;; grep結果バッファでのカーソル移動でダイナミックにファイルを開いてくれる
(require 'color-grep)
(setq color-grep-sync-kill-buffer t)
;; M-x grep-findでPerlのackコマンドを使うよう変更
(setq grep-find-command "ack-grep --nocolor --nogroup ")
;; M-x grep-by-ack
;; Perlのackコマンドを使ったgrep(カーソル付近の単語をデフォルトの検索語に)
(defun grep-by-ack ()
"grep the whole directory for something defaults to term at cursor position"
(interactive)
(setq default-word (thing-at-point 'symbol))
(setq needle1 (or (read-string (concat "ack for <" default-word ">: ")) default-word))
(setq needle1 (if (equal needle1 "") default-word needle1))
(setq default-dir default-directory)
(setq needle2 (or (read-string (concat "target directory <" default-dir ">: ")) default-dir))
(setq needle2 (if (equal needle2 "") default-dir needle2))
(grep-find (concat "ack-grep --nocolor --nogroup " needle1 " " needle2)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 編集行を目立たせる(現在行をハイライト表示する)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defface hlline-face
'((((class color)
(background dark))
(:background "midnightblue" :foreground "white"));;ハイライトの文字色は変えない方がいいかも
(((class color)
(background light))
(:background "ForestGreen"))
(t
()))
"*Face used by hl-line.")
(setq hl-line-face 'hlline-face)
;(setq hl-line-face 'underline) ; 下線
(global-hl-line-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; カラーテーマを適用
(require 'color-theme)
(color-theme-initialize) ;; これを呼ばないと,color-theme-dark-blue2がvoid functionだと怒られる。
(color-theme-dark-blue2)
;; フェイスを変更したい場合は,以下に追加する。
(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.
'(YaTeX-font-lock-declaration-face ((t (:bold t :weight bold :foreground "peru"))))
'(YaTeX-font-lock-label-face ((t (:bold t :weight bold :foreground "gold"))))
'(ac-menu-face ((t (:background "SkyBlue" :foreground "white"))))
'(ac-selection-face ((t (:background "DeepSkyBlue" :foreground "white"))))
'(diff-hunk-header-face ((t (:background "olive drab"))))
'(elscreen-tab-current-screen-face ((t (:background "steel blue"))))
'(font-lock-comment-delimiter-face ((t (:bold t :weight bold :foreground "GreenYellow"))))
'(font-lock-comment-face ((t (:bold t :weight bold :foreground "GreenYellow"))))
'(font-lock-doc-face ((t (:bold t :weight bold :foreground "salmon"))))
'(iswitchb-current-match ((t (:bold t :foreground "green" :weight bold))))
'(iswitchb-single-match ((t (:bold t :weight bold :foreground "green"))))
'(mcomplete-history-method-fixed-part-face ((t (:foreground "green" :bold t :weight bold))))
'(mcomplete-prefix-method-fixed-part-face ((t (:bold t :weight bold :foreground "green"))))
'(mcomplete-substr-method-fixed-part-face ((t (:bold t :weight bold :foreground "green")))))
;; auto-complete の背景をちょっこす変えました。
(when (require 'auto-complete nil t)
(require 'auto-complete-etags)
(global-auto-complete-mode t)
(setq ac-dwim nil)
(custom-set-faces '(ac-menu-face ((t (:background "SkyBlue" :foreground "white"))))
'(ac-selection-face ((t (:background "DeepSkyBlue" :foreground "white")))))
(setq ac-auto-start t)
(global-set-key "\M-/" 'ac-start)
(define-key ac-complete-mode-map "\C-n" 'ac-next)
(define-key ac-complete-mode-map "\C-p" 'ac-previous)
; (define-key ac-complete-mode-map "\M-/" 'ac-stop)
(setq ac-sources '(ac-source-abbrev ac-source-words-in-buffer))
(add-hook 'ruby-mode-hook
(lambda ()
(require 'rcodetools)
(require 'auto-complete-ruby)
(make-local-variable 'ac-omni-completion-sources)
(setq ac-omni-completion-sources '(("\\.\\=" . (ac-source-rcodetools))))))
(setq ac-modes (append ac-modes '(rhtml-mode))))
;;
(setq line-number-mode t)
(setq column-number-mode t)
(global-set-key "\C-h" 'delete-backward-char)
(pc-selection-mode)
(transient-mark-mode 1) ;;選択範囲に色を付ける
;;;====================================
;;;; Buffer 設定
;;;===================================
;;; iswitchb は、バッファ名の一部の文字を入力することで、
;;; 選択バッファの絞り込みを行う機能を実現します。
;;; バッファ名を先頭から入力する必要はなく、とても使いやすくなります。
(iswitchb-mode 1) ;;iswitchbモードON
;;; C-f, C-b, C-n, C-p で候補を切り替えることができるように。
(add-hook 'iswitchb-define-mode-map-hook
(lambda ()
(define-key iswitchb-mode-map "\C-n" 'iswitchb-next-match)
(define-key iswitchb-mode-map "\C-p" 'iswitchb-prev-match)
(define-key iswitchb-mode-map "\C-f" 'iswitchb-next-match)
(define-key iswitchb-mode-map "\C-b" 'iswitchb-prev-match)))
;;; iswitchbで補完対象に含めないバッファ
(setq iswitchb-buffer-ignore
'(
"*twittering-wget-buffer*"
"*twittering-http-buffer*"
"*WoMan-Log*"
"*SKK annotation*"
"*Completions*"
))
(require 'anything-config)
(setq anything-sources (list anything-c-source-buffers
anything-c-source-bookmarks
anything-c-source-recentf
anything-c-source-file-name-history
anything-c-source-locate))
(define-key anything-map (kbd "C-p") 'anything-previous-line)
(define-key anything-map (kbd "C-n") 'anything-next-line)
(define-key anything-map (kbd "C-v") 'anything-next-source)
(define-key anything-map (kbd "M-v") 'anything-previous-source)
(global-set-key (kbd "C-;") 'anything)
;; ruby-mode.el
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
(setq auto-mode-alist
(append '(("\\.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
(require 'ruby-electric)
(add-hook 'ruby-mode-hook '(lambda () (ruby-electric-mode t)))
;; rubydbnx.el
(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)
;; ruby-block.el
(require 'ruby-block)
(ruby-block-mode t)
(setq ruby-block-highlight-toggle t)
;; C-c ' がprefixキー
;(setq rinari-minor-mode-prefixes (list "'"))
(setq load-path (cons (expand-file-name "~/elisp/rinari") load-path))
(require 'rinari)
;;; rhtml-mode
(setq load-path (cons (expand-file-name "~/elisp/rhtml") load-path))
(require 'rhtml-mode)
(add-hook 'rhtml-mode-hook
(lambda () (rinari-launch)))
;; flymake for ruby
(require 'flymake)
;; Invoke ruby with '-c' to get syntax checking
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))
;; エラー行で C-c d するとエラーの内容をミニバッファで表示する
(define-key ruby-mode-map "\C-cd" 'credmp/flymake-display-err-minibuf)))
(defun credmp/flymake-display-err-minibuf ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(let* ((line-no (flymake-current-line-no))
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(count (length line-err-info-list))
)
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(full-file (flymake-ler-full-file (nth (1- count) line-err-info-list)))
(text (flymake-ler-text (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(message "[%s] %s" line text)
)
)
(setq count (1- count)))))
;; rinari-extend-by-emacs-rails.el
(defvar rails-ri-command "fri"
"ri command"
)
(defvar rails-tags-dirs '("app" "lib" "test" "db" "vendor")
"make tag target directories"
)
(defvar rails-tags-command "etags %s"
"make tag target directories"
)
;; helper functions/macros
(defun rails-search-doc-at-point (&optional item)
(interactive)
(setq item (if item item (thing-at-point 'sexp)))
(rails-search-ri item)
)
(defun rails-search-doc (&optional item)
(interactive)
(setq item (read-string "Search symbol: " (if item item (thing-at-point 'sexp))))
(rails-search-ri item)
)
(defun rails-search-doc-for-ri (&optional item)
(interactive)
(setq item (thing-at-point 'filename))
(setq item (if (string-match "," item)
(replace-match "" nil nil item)))
(rails-search-doc item)
)
(defun rails-search-ri (&optional item)
(if item
(let ((buf (buffer-name)))
(unless (string= buf "*ri*")
(switch-to-buffer-other-window "*ri*"))
(setq buffer-read-only nil)
(kill-region (point-min) (point-max))
(message (concat "Please wait..."))
(call-process rails-ri-command nil "*ri*" t item)
(local-set-key [f1] 'rails-search-doc)
(local-set-key [return] 'rails-search-doc-for-ri)
(ansi-color-apply-on-region (point-min) (point-max))
(setq buffer-read-only t)
(goto-char (point-min)))))
(defun rails-create-tags()
"Create tags file"
(interactive)
(message "Creating TAGS, please wait...")
(let ((tags-file-name (concat (rinari-root) "TAGS")))
(shell-command
(format rails-tags-command tags-file-name
(mapconcat (function (lambda (s) (concat (rinari-root) "" s)))
rails-tags-dirs " ")))
(visit-tags-table tags-file-name)))
(provide 'rinari-extend-by-emacs-rails)
(setq rails-tags-dirs '("app" "lib" "test" "db" "vendor"))
(require 'rinari-extend-by-emacs-rails)
(defun ruby-mode-hooks-rinari-extend ()
(define-key ruby-mode-map (kbd "") 'rails-search-doc)
(define-key ruby-mode-map [f1] 'rails-search-doc-at-point)
)
(defun rinari-mode-hooks-rinari-extend ()
(define-key rinari-minor-mode-map "\C-c\C-t" 'rails-create-tags)
)
(add-hook 'ruby-mode-hook 'ruby-mode-hooks-rinari-extend)
(add-hook 'rinari-mode-hook 'rinari-mode-hooks-rinari-extend)
;; yasnippetのロード
(setq load-path (cons (expand-file-name "~/elisp/yasnippet") load-path))
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/elisp/yasnippet/yasnippets-rails/rails-snippets")
;; hippie-expand
(global-set-key "\C-o" 'hippie-expand)
(setq hippie-expand-try-functions-list
'(yas/hippie-try-expand
try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;;; 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)
(setq css-indent-function #'css-c-style-indenter)
;;====================================
;;行番号表示モード
;====================================
;(require 'wb-line-number)
;(wb-line-number-toggle)
;(autoload 'setnu-mode "setnu" nil t)
;(autoload 'wb-line-mode "wb-line-number" nil t)
;(global-set-key [f12] 'wb-line-mode)
(require 'linum)
(global-linum-mode)
;; ECB
(setq load-path (cons (expand-file-name "~/elisp/ecb") load-path))
(load-file "~/elisp/cedet/common/cedet.el")
(setq semantic-load-turn-useful-things-on t)
(require 'ecb)
(setq ecb-tip-of-the-day nil)
(setq ecb-windows-width 0.25)
(defun ecb-toggle ()
(interactive)
(if ecb-minor-mode
(ecb-deactivate)
(ecb-activate)))
(global-set-key [f2] 'ecb-toggle)
(add-hook 'wb-line-number-before-disable-hook
(lambda ()
(when (and (boundp 'ecb-edit-window)
ecb-minor-mode
(eq ecb-edit-window (selected-window)))
(setq ecb-edit-window
(wb-line-number-get-neighbor-left-window
(selected-window))))))
(add-hook 'wb-line-number-after-disable-hook
(lambda ()
(when (and (boundp 'ecb-edit-window)
ecb-minor-mode
(not (window-live-p ecb-edit-window)))
(setq ecb-edit-window (selected-window)))))
(add-hook 'wb-line-number-after-enable-hook
(lambda ()
(when (and (boundp 'ecb-edit-window)
ecb-minor-mode
(eq ecb-edit-window
(wb-line-number-get-neighbor-left-window
(selected-window))))
(setq ecb-edit-window (selected-window)))))
(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.
'(ecb-options-version "2.32")
'(ecb-source-path (quote (("~/ecb/ruby" "Ruby"))))
'(rails-ws:default-server-type "webrick"))
; 短形選択
(autoload 'sense-region-on "sense-region"
"System to toggle region and rectangle." t nil)
(sense-region-on)
;; マウスのホイールスクロールスピードを調節
;; (連続して回しているととんでもない早さになってしまう。特にLogicoolのマウス)
(global-set-key [wheel-up] '(lambda () "" (interactive) (scroll-down 1)))
(global-set-key [wheel-down] '(lambda () "" (interactive) (scroll-up 1)))
(global-set-key [double-wheel-up] '(lambda () "" (interactive) (scroll-down 1)))
(global-set-key [double-wheel-down] '(lambda () "" (interactive) (scroll-up 1)))
(global-set-key [triple-wheel-up] '(lambda () "" (interactive) (scroll-down 2)))
(global-set-key [triple-wheel-down] '(lambda () "" (interactive) (scroll-up 2)))
;; backspaceキーをインクリメンタルサーチ中のミニバッファで有効にする
(define-key isearch-mode-map [backspace] 'isearch-delete-char)
\C-c , f v でView
rails.elのときは、\C-c (\C-p,\C-n) の2タッチで切り替えを
行っていたので、まだ違和感があります。
![叫び](https://stat.ameba.jp/blog/ucs/img/char/char2/254.gif)
4タッチはECBでも同様なので、慣れないといけない。
![パンチ!](https://stat.ameba.jp/blog/ucs/img/char/char2/043.gif)
置き換えることは可能ですが、今はまだ、なるべく標準で慣れたいっす。
いずれ慣れるでしょう
![パー](https://stat.ameba.jp/blog/ucs/img/char/char2/106.gif)
ではでは。
以下、.emacs(10/05/04現在、いろんなところを参考にしているので、整理してません。
![叫び](https://stat.ameba.jp/blog/ucs/img/char/char2/254.gif)
>rinari.el
>ack-grepでgrepするように改造しています。
(defun rinari-rgrep (&optional arg)
"Search through the rails project for a string or `regexp'.
With optional prefix argument just run `rgrep'."
(interactive "P")
(grep-compute-defaults)
(if arg (call-interactively 'rgrep )
(let ((query))
(if mark-active
(setq query (buffer-substring-no-properties (point) (mark)))
(setq query (thing-at-point 'word)))
; (funcall 'rgrep (read-from-minibuffer "search for: " query)
(rgrep (concat "ack-grep --nocolor --nogroup " (read-from-minibuffer "search for: " query) " -G "
rinari-rgrep-file-endings " " (rinari-root))))))
>~/.emacs
;; ~/elisp をライブラリパスに追加
(setq load-path
(append
(list
(expand-file-name "~/elisp/")
)
load-path))
(setq load-path
(append
(list
(expand-file-name "~/elisp/themes")
)
load-path))
;;; 初期フレームの設定
(setq initial-frame-alist
(append
'((top . 0) ; フレームの Y 位置(ピクセル数)
(left . 0) ; フレームの X 位置(ピクセル数)
(width . 80) ; フレーム幅(文字数)
(height . 50)) ; フレーム高(文字数)
initial-frame-alist))
;;; 新規フレームのデフォルト設定
(setq default-frame-alist
(append
'((width . 80) ; フレーム幅(文字数)
(height . 50)) ; フレーム高(文字数)
default-frame-alist))
; emacs23 font
(cond ( (string-match "^23\." emacs-version)
(cond (window-system
(set-default-font "Takaoゴシック-9")
(set-fontset-font (frame-parameter nil 'font)
'japanese-jisx0208
'("Takaoゴシック" . "unicode-bmp"))
; '("IPAGothic" . "unicode-bmp"))
; '("Yutapon coding Heavy" . "unicode-bmp"))
; '("Hiragino Gothic" . "unicode-bmp"))
))))
;;; ホイールマウス
(mouse-wheel-mode t)
(setq mouse-wheel-follow-mouse t)
;;; 対応する括弧を光らせる。
(show-paren-mode 1)
;; 改行コードを表示
(setq eol-mnemonic-dos "(CRLF)")
(setq eol-mnemonic-mac "(CR)")
(setq eol-mnemonic-unix "(LF)")
(require 'sense-region)
(defadvice set-mark-command (around sense-region-set-mark-23 activate)
(if (and (mell-transient-region-active-p)
sense-region-mode)
(copy-face 'region 'sense-region-region-face))
ad-do-it)
(sense-region-on)
;; キーワードのカラー表示を有効化
(global-font-lock-mode t)
;; 全角空白、Tab、改行表示
(require 'jaspace)
(setq jaspace-alternate-jaspace-string "□")
(setq jaspace-alternate-eol-string "↓\n")
(setq jaspace-highlight-tabs t)
(setq jaspace-modes
(append jaspace-modes
'(scheme-mode php-mode yaml-mode js-mode ruby-mode text-mode fundamental-mode LaTeX-mode)))
; tab
(setq elscreen-prefix-key "\C-t")
(setq elscreen-tab-width 12)
(setq elscreen-tab-display-kill-screen nil)
(require 'elscreen "ELSCREEN" t)
;; grep結果バッファでのカーソル移動でダイナミックにファイルを開いてくれる
(require 'color-grep)
(setq color-grep-sync-kill-buffer t)
;; M-x grep-findでPerlのackコマンドを使うよう変更
(setq grep-find-command "ack-grep --nocolor --nogroup ")
;; M-x grep-by-ack
;; Perlのackコマンドを使ったgrep(カーソル付近の単語をデフォルトの検索語に)
(defun grep-by-ack ()
"grep the whole directory for something defaults to term at cursor position"
(interactive)
(setq default-word (thing-at-point 'symbol))
(setq needle1 (or (read-string (concat "ack for <" default-word ">: ")) default-word))
(setq needle1 (if (equal needle1 "") default-word needle1))
(setq default-dir default-directory)
(setq needle2 (or (read-string (concat "target directory <" default-dir ">: ")) default-dir))
(setq needle2 (if (equal needle2 "") default-dir needle2))
(grep-find (concat "ack-grep --nocolor --nogroup " needle1 " " needle2)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 編集行を目立たせる(現在行をハイライト表示する)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defface hlline-face
'((((class color)
(background dark))
(:background "midnightblue" :foreground "white"));;ハイライトの文字色は変えない方がいいかも
(((class color)
(background light))
(:background "ForestGreen"))
(t
()))
"*Face used by hl-line.")
(setq hl-line-face 'hlline-face)
;(setq hl-line-face 'underline) ; 下線
(global-hl-line-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; カラーテーマを適用
(require 'color-theme)
(color-theme-initialize) ;; これを呼ばないと,color-theme-dark-blue2がvoid functionだと怒られる。
(color-theme-dark-blue2)
;; フェイスを変更したい場合は,以下に追加する。
(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.
'(YaTeX-font-lock-declaration-face ((t (:bold t :weight bold :foreground "peru"))))
'(YaTeX-font-lock-label-face ((t (:bold t :weight bold :foreground "gold"))))
'(ac-menu-face ((t (:background "SkyBlue" :foreground "white"))))
'(ac-selection-face ((t (:background "DeepSkyBlue" :foreground "white"))))
'(diff-hunk-header-face ((t (:background "olive drab"))))
'(elscreen-tab-current-screen-face ((t (:background "steel blue"))))
'(font-lock-comment-delimiter-face ((t (:bold t :weight bold :foreground "GreenYellow"))))
'(font-lock-comment-face ((t (:bold t :weight bold :foreground "GreenYellow"))))
'(font-lock-doc-face ((t (:bold t :weight bold :foreground "salmon"))))
'(iswitchb-current-match ((t (:bold t :foreground "green" :weight bold))))
'(iswitchb-single-match ((t (:bold t :weight bold :foreground "green"))))
'(mcomplete-history-method-fixed-part-face ((t (:foreground "green" :bold t :weight bold))))
'(mcomplete-prefix-method-fixed-part-face ((t (:bold t :weight bold :foreground "green"))))
'(mcomplete-substr-method-fixed-part-face ((t (:bold t :weight bold :foreground "green")))))
;; auto-complete の背景をちょっこす変えました。
(when (require 'auto-complete nil t)
(require 'auto-complete-etags)
(global-auto-complete-mode t)
(setq ac-dwim nil)
(custom-set-faces '(ac-menu-face ((t (:background "SkyBlue" :foreground "white"))))
'(ac-selection-face ((t (:background "DeepSkyBlue" :foreground "white")))))
(setq ac-auto-start t)
(global-set-key "\M-/" 'ac-start)
(define-key ac-complete-mode-map "\C-n" 'ac-next)
(define-key ac-complete-mode-map "\C-p" 'ac-previous)
; (define-key ac-complete-mode-map "\M-/" 'ac-stop)
(setq ac-sources '(ac-source-abbrev ac-source-words-in-buffer))
(add-hook 'ruby-mode-hook
(lambda ()
(require 'rcodetools)
(require 'auto-complete-ruby)
(make-local-variable 'ac-omni-completion-sources)
(setq ac-omni-completion-sources '(("\\.\\=" . (ac-source-rcodetools))))))
(setq ac-modes (append ac-modes '(rhtml-mode))))
;;
(setq line-number-mode t)
(setq column-number-mode t)
(global-set-key "\C-h" 'delete-backward-char)
(pc-selection-mode)
(transient-mark-mode 1) ;;選択範囲に色を付ける
;;;====================================
;;;; Buffer 設定
;;;===================================
;;; iswitchb は、バッファ名の一部の文字を入力することで、
;;; 選択バッファの絞り込みを行う機能を実現します。
;;; バッファ名を先頭から入力する必要はなく、とても使いやすくなります。
(iswitchb-mode 1) ;;iswitchbモードON
;;; C-f, C-b, C-n, C-p で候補を切り替えることができるように。
(add-hook 'iswitchb-define-mode-map-hook
(lambda ()
(define-key iswitchb-mode-map "\C-n" 'iswitchb-next-match)
(define-key iswitchb-mode-map "\C-p" 'iswitchb-prev-match)
(define-key iswitchb-mode-map "\C-f" 'iswitchb-next-match)
(define-key iswitchb-mode-map "\C-b" 'iswitchb-prev-match)))
;;; iswitchbで補完対象に含めないバッファ
(setq iswitchb-buffer-ignore
'(
"*twittering-wget-buffer*"
"*twittering-http-buffer*"
"*WoMan-Log*"
"*SKK annotation*"
"*Completions*"
))
(require 'anything-config)
(setq anything-sources (list anything-c-source-buffers
anything-c-source-bookmarks
anything-c-source-recentf
anything-c-source-file-name-history
anything-c-source-locate))
(define-key anything-map (kbd "C-p") 'anything-previous-line)
(define-key anything-map (kbd "C-n") 'anything-next-line)
(define-key anything-map (kbd "C-v") 'anything-next-source)
(define-key anything-map (kbd "M-v") 'anything-previous-source)
(global-set-key (kbd "C-;") 'anything)
;; ruby-mode.el
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
(setq auto-mode-alist
(append '(("\\.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
(require 'ruby-electric)
(add-hook 'ruby-mode-hook '(lambda () (ruby-electric-mode t)))
;; rubydbnx.el
(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)
;; ruby-block.el
(require 'ruby-block)
(ruby-block-mode t)
(setq ruby-block-highlight-toggle t)
;; C-c ' がprefixキー
;(setq rinari-minor-mode-prefixes (list "'"))
(setq load-path (cons (expand-file-name "~/elisp/rinari") load-path))
(require 'rinari)
;;; rhtml-mode
(setq load-path (cons (expand-file-name "~/elisp/rhtml") load-path))
(require 'rhtml-mode)
(add-hook 'rhtml-mode-hook
(lambda () (rinari-launch)))
;; flymake for ruby
(require 'flymake)
;; Invoke ruby with '-c' to get syntax checking
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))
;; エラー行で C-c d するとエラーの内容をミニバッファで表示する
(define-key ruby-mode-map "\C-cd" 'credmp/flymake-display-err-minibuf)))
(defun credmp/flymake-display-err-minibuf ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(let* ((line-no (flymake-current-line-no))
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(count (length line-err-info-list))
)
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(full-file (flymake-ler-full-file (nth (1- count) line-err-info-list)))
(text (flymake-ler-text (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(message "[%s] %s" line text)
)
)
(setq count (1- count)))))
;; rinari-extend-by-emacs-rails.el
(defvar rails-ri-command "fri"
"ri command"
)
(defvar rails-tags-dirs '("app" "lib" "test" "db" "vendor")
"make tag target directories"
)
(defvar rails-tags-command "etags %s"
"make tag target directories"
)
;; helper functions/macros
(defun rails-search-doc-at-point (&optional item)
(interactive)
(setq item (if item item (thing-at-point 'sexp)))
(rails-search-ri item)
)
(defun rails-search-doc (&optional item)
(interactive)
(setq item (read-string "Search symbol: " (if item item (thing-at-point 'sexp))))
(rails-search-ri item)
)
(defun rails-search-doc-for-ri (&optional item)
(interactive)
(setq item (thing-at-point 'filename))
(setq item (if (string-match "," item)
(replace-match "" nil nil item)))
(rails-search-doc item)
)
(defun rails-search-ri (&optional item)
(if item
(let ((buf (buffer-name)))
(unless (string= buf "*ri*")
(switch-to-buffer-other-window "*ri*"))
(setq buffer-read-only nil)
(kill-region (point-min) (point-max))
(message (concat "Please wait..."))
(call-process rails-ri-command nil "*ri*" t item)
(local-set-key [f1] 'rails-search-doc)
(local-set-key [return] 'rails-search-doc-for-ri)
(ansi-color-apply-on-region (point-min) (point-max))
(setq buffer-read-only t)
(goto-char (point-min)))))
(defun rails-create-tags()
"Create tags file"
(interactive)
(message "Creating TAGS, please wait...")
(let ((tags-file-name (concat (rinari-root) "TAGS")))
(shell-command
(format rails-tags-command tags-file-name
(mapconcat (function (lambda (s) (concat (rinari-root) "" s)))
rails-tags-dirs " ")))
(visit-tags-table tags-file-name)))
(provide 'rinari-extend-by-emacs-rails)
(setq rails-tags-dirs '("app" "lib" "test" "db" "vendor"))
(require 'rinari-extend-by-emacs-rails)
(defun ruby-mode-hooks-rinari-extend ()
(define-key ruby-mode-map (kbd "
(define-key ruby-mode-map [f1] 'rails-search-doc-at-point)
)
(defun rinari-mode-hooks-rinari-extend ()
(define-key rinari-minor-mode-map "\C-c\C-t" 'rails-create-tags)
)
(add-hook 'ruby-mode-hook 'ruby-mode-hooks-rinari-extend)
(add-hook 'rinari-mode-hook 'rinari-mode-hooks-rinari-extend)
;; yasnippetのロード
(setq load-path (cons (expand-file-name "~/elisp/yasnippet") load-path))
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/elisp/yasnippet/yasnippets-rails/rails-snippets")
;; hippie-expand
(global-set-key "\C-o" 'hippie-expand)
(setq hippie-expand-try-functions-list
'(yas/hippie-try-expand
try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;;; 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)
(setq css-indent-function #'css-c-style-indenter)
;;====================================
;;行番号表示モード
;====================================
;(require 'wb-line-number)
;(wb-line-number-toggle)
;(autoload 'setnu-mode "setnu" nil t)
;(autoload 'wb-line-mode "wb-line-number" nil t)
;(global-set-key [f12] 'wb-line-mode)
(require 'linum)
(global-linum-mode)
;; ECB
(setq load-path (cons (expand-file-name "~/elisp/ecb") load-path))
(load-file "~/elisp/cedet/common/cedet.el")
(setq semantic-load-turn-useful-things-on t)
(require 'ecb)
(setq ecb-tip-of-the-day nil)
(setq ecb-windows-width 0.25)
(defun ecb-toggle ()
(interactive)
(if ecb-minor-mode
(ecb-deactivate)
(ecb-activate)))
(global-set-key [f2] 'ecb-toggle)
(add-hook 'wb-line-number-before-disable-hook
(lambda ()
(when (and (boundp 'ecb-edit-window)
ecb-minor-mode
(eq ecb-edit-window (selected-window)))
(setq ecb-edit-window
(wb-line-number-get-neighbor-left-window
(selected-window))))))
(add-hook 'wb-line-number-after-disable-hook
(lambda ()
(when (and (boundp 'ecb-edit-window)
ecb-minor-mode
(not (window-live-p ecb-edit-window)))
(setq ecb-edit-window (selected-window)))))
(add-hook 'wb-line-number-after-enable-hook
(lambda ()
(when (and (boundp 'ecb-edit-window)
ecb-minor-mode
(eq ecb-edit-window
(wb-line-number-get-neighbor-left-window
(selected-window))))
(setq ecb-edit-window (selected-window)))))
(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.
'(ecb-options-version "2.32")
'(ecb-source-path (quote (("~/ecb/ruby" "Ruby"))))
'(rails-ws:default-server-type "webrick"))
; 短形選択
(autoload 'sense-region-on "sense-region"
"System to toggle region and rectangle." t nil)
(sense-region-on)
;; マウスのホイールスクロールスピードを調節
;; (連続して回しているととんでもない早さになってしまう。特にLogicoolのマウス)
(global-set-key [wheel-up] '(lambda () "" (interactive) (scroll-down 1)))
(global-set-key [wheel-down] '(lambda () "" (interactive) (scroll-up 1)))
(global-set-key [double-wheel-up] '(lambda () "" (interactive) (scroll-down 1)))
(global-set-key [double-wheel-down] '(lambda () "" (interactive) (scroll-up 1)))
(global-set-key [triple-wheel-up] '(lambda () "" (interactive) (scroll-down 2)))
(global-set-key [triple-wheel-down] '(lambda () "" (interactive) (scroll-up 2)))
;; backspaceキーをインクリメンタルサーチ中のミニバッファで有効にする
(define-key isearch-mode-map [backspace] 'isearch-delete-char)