diff options
| author | Dmitry Gutov | 2013-10-11 05:11:37 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2013-10-11 05:11:37 +0300 |
| commit | b68e29263fbe7c31a54c0dab55a0121701ad8ec3 (patch) | |
| tree | e9b16752a11a67132c01211d48e5bc6b1cbd7884 | |
| parent | 0922b8260ac76c153b253c992c1a656fca1a22e2 (diff) | |
| download | emacs-b68e29263fbe7c31a54c0dab55a0121701ad8ec3.tar.gz emacs-b68e29263fbe7c31a54c0dab55a0121701ad8ec3.zip | |
* lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the
cases of ? and =.
(ruby-smie-rules): Simplify the "do" rule. The cases when the
predicate would return nil are almost non-existent.
(ruby-smie--redundant-do-p): Include "until" and "for" statements.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 25 | ||||
| -rw-r--r-- | test/indent/ruby.rb | 4 |
3 files changed, 17 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 362447e651c..1c1a5701602 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2013-10-11 Dmitry Gutov <dgutov@yandex.ru> | 1 | 2013-10-11 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 2 | ||
| 3 | * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the | ||
| 4 | cases of ? and =. | ||
| 5 | (ruby-smie-rules): Simplify the "do" rule. The cases when the | ||
| 6 | predicate would return nil are almost non-existent. | ||
| 7 | (ruby-smie--redundant-do-p): Include "until" and "for" statements. | ||
| 8 | |||
| 3 | * emacs-lisp/smie.el (smie--matching-block-data): Invalidate the | 9 | * emacs-lisp/smie.el (smie--matching-block-data): Invalidate the |
| 4 | cache also after commands that modify the buffer but don't move | 10 | cache also after commands that modify the buffer but don't move |
| 5 | point. | 11 | point. |
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index f734dc50e47..2f922162586 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -292,10 +292,11 @@ Also ignores spaces after parenthesis when 'space." | |||
| 292 | '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\)) | 292 | '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\)) |
| 293 | ;; Make sure it's not the end of a regexp. | 293 | ;; Make sure it's not the end of a regexp. |
| 294 | (not (eq (car (syntax-after (1- (point)))) 7))) | 294 | (not (eq (car (syntax-after (1- (point)))) 7))) |
| 295 | (and (memq (char-before) '(?\? ?=)) | 295 | (and (eq (char-before) ?\?) |
| 296 | (let ((tok (save-excursion (ruby-smie--backward-token)))) | 296 | (equal (save-excursion (ruby-smie--backward-token)) "?")) |
| 297 | (or (equal tok "?") | 297 | (and (eq (char-before) ?=) |
| 298 | (string-match "\\`\\s." tok)))) | 298 | (string-match "\\`\\s." (save-excursion |
| 299 | (ruby-smie--backward-token)))) | ||
| 299 | (and (eq (car (syntax-after (1- (point)))) 2) | 300 | (and (eq (car (syntax-after (1- (point)))) 2) |
| 300 | (equal (save-excursion (ruby-smie--backward-token)) | 301 | (equal (save-excursion (ruby-smie--backward-token)) |
| 301 | "iuwu-mod")) | 302 | "iuwu-mod")) |
| @@ -306,7 +307,7 @@ Also ignores spaces after parenthesis when 'space." | |||
| 306 | (defun ruby-smie--redundant-do-p (&optional skip) | 307 | (defun ruby-smie--redundant-do-p (&optional skip) |
| 307 | (save-excursion | 308 | (save-excursion |
| 308 | (if skip (backward-word 1)) | 309 | (if skip (backward-word 1)) |
| 309 | (member (nth 2 (smie-backward-sexp ";")) '("while")))) | 310 | (member (nth 2 (smie-backward-sexp ";")) '("while" "until" "for")))) |
| 310 | 311 | ||
| 311 | (defun ruby-smie--opening-pipe-p () | 312 | (defun ruby-smie--opening-pipe-p () |
| 312 | (save-excursion | 313 | (save-excursion |
| @@ -423,19 +424,7 @@ Also ignores spaces after parenthesis when 'space." | |||
| 423 | (when (smie-rule-hanging-p) | 424 | (when (smie-rule-hanging-p) |
| 424 | (smie-backward-sexp 'halfsexp) (smie-indent-virtual))) | 425 | (smie-backward-sexp 'halfsexp) (smie-indent-virtual))) |
| 425 | (`(:after . ,(or "=" "iuwu-mod")) 2) | 426 | (`(:after . ,(or "=" "iuwu-mod")) 2) |
| 426 | (`(:before . "do") | 427 | (`(:before . "do") (smie-rule-parent)) |
| 427 | (when (or (smie-rule-hanging-p) | ||
| 428 | (save-excursion | ||
| 429 | (forward-word 1) ;Skip "do" | ||
| 430 | (skip-chars-forward " \t") | ||
| 431 | (and (equal (save-excursion (ruby-smie--forward-token)) | ||
| 432 | "opening-|") | ||
| 433 | (save-excursion (forward-sexp 1) | ||
| 434 | (skip-chars-forward " \t") | ||
| 435 | (or (eolp) | ||
| 436 | (looking-at comment-start-skip)))))) | ||
| 437 | ;; `(column . ,(smie-indent-virtual)) | ||
| 438 | (smie-rule-parent))) | ||
| 439 | (`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0) | 428 | (`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0) |
| 440 | (`(:before . ,(or `"when")) | 429 | (`(:before . ,(or `"when")) |
| 441 | (if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level | 430 | (if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level |
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 48275ee3e31..b280ec93ce2 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb | |||
| @@ -151,6 +151,10 @@ z = { | |||
| 151 | foo if | 151 | foo if |
| 152 | bar | 152 | bar |
| 153 | 153 | ||
| 154 | if foo? | ||
| 155 | bar | ||
| 156 | end | ||
| 157 | |||
| 154 | # Examples below still fail with `ruby-use-smie' on: | 158 | # Examples below still fail with `ruby-use-smie' on: |
| 155 | 159 | ||
| 156 | foo + | 160 | foo + |