diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2013-12-14 08:46:13 +0200 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2013-12-14 08:46:13 +0200 |
commit | 276bc3337b27bcd76aa2735ed96c160c6a1b573a (patch) | |
tree | 998438a0496b773195c79bd11f9372d06497d96f /lisp/progmodes/ruby-mode.el | |
parent | dc7909c40a5524af650a7d4233f393a43bf6706c (diff) | |
download | emacs-276bc3337b27bcd76aa2735ed96c160c6a1b573a.tar.gz emacs-276bc3337b27bcd76aa2735ed96c160c6a1b573a.tar.bz2 emacs-276bc3337b27bcd76aa2735ed96c160c6a1b573a.zip |
Fix bug#16118
* lisp/progmodes/ruby-mode.el (ruby-smie-rules): Return nil before
open-paren tokens when preceded by a open-paren, too.
(ruby-smie-rules): Handle virtual indentation after open-paren
tokens specially. If there is code between it and eol, return the
column where is starts.
* test/indent/ruby.rb: New examples.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r-- | lisp/progmodes/ruby-mode.el | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index af7a4d8c321..13f7335d042 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -549,10 +549,21 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." (ruby-smie--indent-to-stmt)) ((smie-rule-hanging-p) ;; Treat purely syntactic block-constructs as being part of their parent, - ;; when the opening statement is hanging. + ;; when the opening token is hanging and the parent is not an open-paren. (let ((state (smie-backward-sexp 'halfsexp))) - (when (eq t (car state)) (goto-char (cadr state)))) - (cons 'column (smie-indent-virtual))))) + (unless (and (eq t (car state)) + (not (eq (cadr state) (point-min)))) + (cons 'column (smie-indent-virtual))))))) + (`(:after . ,(or `"(" "[" "{")) + ;; FIXME: Shouldn't this be the default behavior of + ;; `smie-indent-after-keyword'? + (save-excursion + (forward-char 1) + (skip-chars-forward " \t") + ;; `smie-rule-hanging-p' is not good enough here, + ;; because we want to accept hanging tokens at bol, too. + (unless (or (eolp) (forward-comment 1)) + (cons 'column (current-column))))) (`(:after . " @ ") (smie-rule-parent)) (`(:before . "do") (ruby-smie--indent-to-stmt)) (`(,(or :before :after) . ".") |