mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-31 20:02:42 +00:00
* 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.
This commit is contained in:
parent
0922b8260a
commit
b68e29263f
@ -1,5 +1,11 @@
|
||||
2013-10-11 Dmitry Gutov <dgutov@yandex.ru>
|
||||
|
||||
* 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.
|
||||
|
||||
* emacs-lisp/smie.el (smie--matching-block-data): Invalidate the
|
||||
cache also after commands that modify the buffer but don't move
|
||||
point.
|
||||
|
@ -292,10 +292,11 @@ Also ignores spaces after parenthesis when 'space."
|
||||
'(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\))
|
||||
;; Make sure it's not the end of a regexp.
|
||||
(not (eq (car (syntax-after (1- (point)))) 7)))
|
||||
(and (memq (char-before) '(?\? ?=))
|
||||
(let ((tok (save-excursion (ruby-smie--backward-token))))
|
||||
(or (equal tok "?")
|
||||
(string-match "\\`\\s." tok))))
|
||||
(and (eq (char-before) ?\?)
|
||||
(equal (save-excursion (ruby-smie--backward-token)) "?"))
|
||||
(and (eq (char-before) ?=)
|
||||
(string-match "\\`\\s." (save-excursion
|
||||
(ruby-smie--backward-token))))
|
||||
(and (eq (car (syntax-after (1- (point)))) 2)
|
||||
(equal (save-excursion (ruby-smie--backward-token))
|
||||
"iuwu-mod"))
|
||||
@ -306,7 +307,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||
(defun ruby-smie--redundant-do-p (&optional skip)
|
||||
(save-excursion
|
||||
(if skip (backward-word 1))
|
||||
(member (nth 2 (smie-backward-sexp ";")) '("while"))))
|
||||
(member (nth 2 (smie-backward-sexp ";")) '("while" "until" "for"))))
|
||||
|
||||
(defun ruby-smie--opening-pipe-p ()
|
||||
(save-excursion
|
||||
@ -423,19 +424,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||
(when (smie-rule-hanging-p)
|
||||
(smie-backward-sexp 'halfsexp) (smie-indent-virtual)))
|
||||
(`(:after . ,(or "=" "iuwu-mod")) 2)
|
||||
(`(:before . "do")
|
||||
(when (or (smie-rule-hanging-p)
|
||||
(save-excursion
|
||||
(forward-word 1) ;Skip "do"
|
||||
(skip-chars-forward " \t")
|
||||
(and (equal (save-excursion (ruby-smie--forward-token))
|
||||
"opening-|")
|
||||
(save-excursion (forward-sexp 1)
|
||||
(skip-chars-forward " \t")
|
||||
(or (eolp)
|
||||
(looking-at comment-start-skip))))))
|
||||
;; `(column . ,(smie-indent-virtual))
|
||||
(smie-rule-parent)))
|
||||
(`(:before . "do") (smie-rule-parent))
|
||||
(`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0)
|
||||
(`(:before . ,(or `"when"))
|
||||
(if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level
|
||||
|
@ -151,6 +151,10 @@ def foo
|
||||
foo if
|
||||
bar
|
||||
|
||||
if foo?
|
||||
bar
|
||||
end
|
||||
|
||||
# Examples below still fail with `ruby-use-smie' on:
|
||||
|
||||
foo +
|
||||
|
Loading…
Reference in New Issue
Block a user