Commit 238150c8 authored by Dmitry Gutov's avatar Dmitry Gutov
Browse files

* lisp/progmodes/ruby-mode.el (ruby-smie-rules): Indent after hanging

iuwu-mod token.
(ruby-smie--implicit-semi-p): Prohibit implicit semicolon after
hanging iuwu-mod token.
(ruby-smie--forward-token): Do not include a dot after a token in
that token.
(ruby-smie--backward-token): Likewise.
parent b0949cc4
2013-10-09 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el (ruby-smie-rules): Indent after hanging
iuwu-mod token.
(ruby-smie--implicit-semi-p): Prohibit implicit semicolon after
hanging iuwu-mod token.
(ruby-smie--forward-token): Do not include a dot after a token in
that token.
(ruby-smie--backward-token): Likewise.
2013-10-08 Juri Linkov <juri@jurta.org>
* isearch.el (isearch-help-map, isearch-mode-map): Don't bind [t]
......
......@@ -296,6 +296,9 @@ Also ignores spaces after parenthesis when 'space."
(let ((tok (save-excursion (ruby-smie--backward-token))))
(or (equal tok "?")
(string-match "\\`\\s." tok))))
(and (eq (car (syntax-after (1- (point)))) 2)
(equal (save-excursion (ruby-smie--backward-token))
"iuwu-mod"))
(save-excursion
(forward-comment 1)
(eq (char-after) ?.))))))
......@@ -334,9 +337,6 @@ Also ignores spaces after parenthesis when 'space."
(if (looking-at ":\\s.+")
(progn (goto-char (match-end 0)) (match-string 0)) ;; bug#15208.
(let ((tok (smie-default-forward-token)))
(when (eq ?. (char-after))
(forward-char 1)
(setq tok (concat tok "." (ruby-smie--forward-id))))
(cond
((member tok '("unless" "if" "while" "until"))
(if (save-excursion (forward-word -1) (ruby-smie--bosp))
......@@ -375,7 +375,7 @@ Also ignores spaces after parenthesis when 'space."
(let ((tok (smie-default-backward-token)))
(when (eq ?. (char-before))
(forward-char -1)
(setq tok (concat (ruby-smie--backward-id) "." tok)))
(setq tok (concat "." tok)))
(when (and (eq ?: (char-before)) (string-match "\\`\\s." tok))
(forward-char -1) (setq tok (concat ":" tok))) ;; bug#15208.
(cond
......@@ -394,6 +394,9 @@ Also ignores spaces after parenthesis when 'space."
(line-end-position))
(ruby-smie--backward-token)) ;Fully redundant.
(t ";")))
;; FIXME: We shouldn't merge the dot with preceding token here
;; either, but not doing that breaks indentation of hanging
;; method calls with dot on the first line.
((equal tok ".")
(concat (ruby-smie--backward-id) tok))
(t tok)))))))
......@@ -419,7 +422,7 @@ Also ignores spaces after parenthesis when 'space."
;; when the opening statement is hanging.
(when (smie-rule-hanging-p)
(smie-backward-sexp 'halfsexp) (smie-indent-virtual)))
(`(:after . "=") 2)
(`(:after . ,(or "=" "iuwu-mod")) 2)
(`(:before . "do")
(when (or (smie-rule-hanging-p)
(save-excursion
......
......@@ -594,6 +594,9 @@ VALUES-PLIST is a list with alternating index and value elements."
| def foo
| self.end
| D.new.class
| [1, 2, 3].map do |i|
| i + 1
| end.sum
| end
|end"))
......@@ -601,11 +604,11 @@ VALUES-PLIST is a list with alternating index and value elements."
(ruby-with-temp-buffer ruby-sexp-test-example
(goto-line 2)
(ruby-forward-sexp)
(should (= 5 (line-number-at-pos)))))
(should (= 8 (line-number-at-pos)))))
(ert-deftest ruby-backward-sexp-skips-method-calls-with-keyword-names ()
(ruby-with-temp-buffer ruby-sexp-test-example
(goto-line 5)
(goto-line 8)
(end-of-line)
(ruby-backward-sexp)
(should (= 2 (line-number-at-pos)))))
......
......@@ -148,10 +148,14 @@ def foo
}
}
foo if
bar
# Examples below still fail with `ruby-use-smie' on:
foo +
bar
foo if
bar
foo = [1, 2, 3].map do |i|
i + 1
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment