help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ruby and RubyOn Rails setup - Cannot enable indentation and snippets


From: Sayth Renshaw
Subject: Ruby and RubyOn Rails setup - Cannot enable indentation and snippets
Date: Tue, 1 Jan 2013 04:27:00 -0800 (PST)
User-agent: G2/1.0

Hi

I have been trying to configure emacs24 now for sometime to be good using ruby 
and later rails. I am on Fedora 18.

Well the biggest issue I have is that emacs will not indent ruby correctly, 
well it doesn't indent at all.

I have tried several variations all done by hand by myself, emacs-starter-kit 
with ruby loaded, prelude emacs(indents end keyword correctly but does not 
indent the block) with ruby loaded and cannot get proper indentation, snippets 
and/or autocompletion. I can get some bits in the installs but it is not ideal.

By default Sublime text2 does all this and I cannot manage to emacs configured.

This is my .emacs(left out references to marmalade etc) I put together using 
ruby-mode, rinari, rsense and yasnippet.
I get the features of rsense, however I cannot get it to indent correctly or 
have yasnippet insert snippet from tab press.

Example indentation

Correct
multi_array.each do
  x.each do |y|
    puts y

  end
end

Emacs
multi_array.each do
x.each do |y|
puts y
end
end


If anyone can advise on what to improve it would be greatly appreciated.

(setq-default indent-tabs-mode nil)    ; use only spaces and no tabs
(setq default-tab-width 4)

(require 'pep8)
(require 'pylint)

;; org mode
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

 (global-set-key "\C-cl" 'org-store-link)
 (global-set-key "\C-cc" 'org-capture)
 (global-set-key "\C-ca" 'org-agenda)
 (global-set-key "\C-cb" 'org-iswitchb)

(require 'yasnippet-bundle)
(yas/global-mode)
(add-hook 'rinari-minor-mode-hook
          #'(lambda ()
              (setq yas/mode-symbol 'rails-mode)))

(add-hook 'ruby-mode-hook
          #'(lambda ()
              (setq yas/mode-symbol 'ruby-mode)))

(setq ruby-indent-level 4)
(require 'rinari)
(add-to-list 'load-path "/home/sayth/.emacs.d/rhtml")
(require 'rhtml-mode)

(autoload 'ruby-mode "ruby-mode"
    "Mode for editing ruby source files")
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
(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)))

(setq load-path (cons (expand-file-name "~/.emacs.d/rails-reloaded") load-path))
  (require 'rails-autoload)

(setq rsense-home "/home/sayth/opt/rsense-0.3")
(add-to-list 'load-path (concat rsense-home "/etc"))
(require 'rsense)
(add-hook 'ruby-mode-hook
          (lambda ()
            (add-to-list 'ac-sources 'ac-source-rsense-method)
            (add-to-list 'ac-sources 'ac-source-rsense-constant)))

Sayth


reply via email to

[Prev in Thread] Current Thread [Next in Thread]