Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs ruby-mode, indenting wildly inside parentheses?

Tags:

emacs

ruby

Excuse my emacs newbiness here, but does anybody know how to get around this? When coding in emacs, in ruby-mode, it indents to the correct level (i.e. by 2 spaces) after all the keywords, like def, class, module, begin etc, but when breaking parameter lists across multiple lines, it indents to a seemingly random position, like 40 or so columns over.

I've been reading around emacs tab settings and seem to just be going around in circles and not getting to information I'm looking for, so I figured I'd ask here.

Here's a screenshot of where it is placing the cursor in a parameter list. I've tried indenting inside of curly braces (e.g. for a block, or a hash) and that is working ok, it's the parentheses that are messing it up.

Bug

like image 969
d11wtq Avatar asked Sep 13 '11 15:09

d11wtq


2 Answers

http://compgroups.net/comp.emacs/Ruby-mode-indentation-of-continuation-lines

(setq ruby-deep-indent-paren nil)

Or temporarily, within the current session:

M-x set-variable RET ruby-deep-indent-paren RET nil RET

Inside of a parentheses it will now indent like it does everywhere else. There is still a minor bug in the case of what I posted above. It indents 2 spaces further than I want it to, because I'm confusing it with the combination of ( and {.

like image 80
d11wtq Avatar answered Oct 19 '22 06:10

d11wtq


ruby-deep-indent-paren and related vars have no effect for me because ruby-use-smie is t. Setting both to nil didn't seem to help either :-(

But switching to enh-ruby-mode, it's working!

  • Setting enh-ruby-deep-indent-paren to nil had an effect.
  • Setting enh-ruby-bounce-deep-indent to t allows me to press Tab again to toggle between the styles!
like image 39
Beni Cherniavsky-Paskin Avatar answered Oct 19 '22 06:10

Beni Cherniavsky-Paskin