mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
I switched from this very behavior a couple of days ago cause the reindenting was causing my headaches every now and then. But not having has been causing me even bigger headaches.
63 lines
2.6 KiB
EmacsLisp
63 lines
2.6 KiB
EmacsLisp
(autoload 'ruby-mode "ruby-mode" nil t)
|
|
|
|
(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode))
|
|
(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode))
|
|
(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode))
|
|
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
|
|
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
|
|
(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode))
|
|
(add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode))
|
|
(add-to-list 'auto-mode-alist '("\\.rabl\\'" . ruby-mode))
|
|
|
|
(add-hook 'ruby-mode-hook
|
|
(lambda ()
|
|
(flyspell-prog-mode)
|
|
(linum-mode t)
|
|
(fci-mode)
|
|
(require 'inf-ruby)
|
|
(require 'ruby-electric)
|
|
(require 'ruby-compilation)
|
|
(require 'flymake)
|
|
(require 'flymake-ruby)
|
|
(when (require 'rsense nil 'noerror)
|
|
(add-to-list 'ac-sources 'ac-source-rsense-method)
|
|
(add-to-list 'ac-sources 'ac-source-rsense-constant))
|
|
(flymake-ruby-load)
|
|
(highlight-indentation-mode)
|
|
(highlight-indentation-current-column-mode)
|
|
(ruby-electric-mode t)
|
|
(setq ruby-deep-arglist t)
|
|
(setq ruby-deep-indent-paren nil)
|
|
(setq c-tab-always-indent nil)
|
|
(setq ruby-use-encoding-map nil)
|
|
(setq ruby-electric-expand-delimiters-list (quote (124)))
|
|
(setq whitespace-action (quote (auto-cleanup)))
|
|
(define-key ruby-mode-map
|
|
(kbd "RET") 'reindent-then-newline-and-indent)
|
|
(define-key ruby-mode-map
|
|
(kbd "s-r") 'ruby-compilation-this-buffer)
|
|
(define-key ruby-mode-map
|
|
(kbd "C-c C-.") 'ac-complete-rsense)
|
|
(define-key ruby-mode-map
|
|
(kbd "C-x t") 'textmate-goto-file)
|
|
(define-key ruby-mode-map
|
|
(kbd "C-x C-t") 'textmate-goto-file)
|
|
(define-key ruby-mode-map
|
|
(kbd "C-c C-l") 'goto-line)
|
|
(define-key ruby-mode-map
|
|
(kbd "C-c C-b") 'eproject-ibuffer)))
|
|
|
|
;; Yasnippet workaround for ruby-electric-mode
|
|
;; See: http://code.google.com/p/yasnippet/issues/detail?id=71
|
|
(defun yas/advise-indent-function (function-symbol)
|
|
(eval `(defadvice ,function-symbol (around yas/try-expand-first activate)
|
|
,(format
|
|
"Try to expand a snippet before point, then call `%s' as usual"
|
|
function-symbol)
|
|
(let ((yas/fallback-behavior nil))
|
|
(unless (and (interactive-p)
|
|
(yas/expand))
|
|
ad-do-it)))))
|
|
(yas/advise-indent-function 'ruby-indent-line)
|
|
(yas/advise-indent-function 'ruby-indent-command)
|