Emacs Ruby方法参数缩进 [英] Emacs Ruby method parameter indentation
本文介绍了Emacs Ruby方法参数缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使emacs缩进ruby方法调用,如:
I want to make emacs indent ruby method calls like:
foo(
:blah => 'bar',
:shibby => 'baz'
)
最近我可以得到的是:
foo(
:blah => 'bar',
:shibby => 'baz'
)
这是使用ruby-deep-indent-括号,ruby-deep-indent-paren-style,ruby-deep-arglist都设置为nil。
This is using ruby-deep-indent-paren, ruby-deep-indent-paren-style, ruby-deep-arglist all set to nil.
哈希缩进我喜欢...如果我可以做方法调用缩进像哈希我会很开心。任何想法?
Hashes indent how I like... if I could just make method calls indent like hashes I would be happy. Any ideas?
推荐答案
Dmitry Gutov 已发布此修复程序,使用建议,似乎工作:
Dmitry Gutov has posted this fix, using advice, which seems to work:
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
(goto-char (cadr state))
(setq indent (current-indentation)))))
(when indent
(indent-line-to indent)
(when (> offset 0) (forward-char offset)))))
这篇关于Emacs Ruby方法参数缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文