aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/ruby-mode.el
diff options
context:
space:
mode:
authorDmitry Gutov2013-10-11 05:11:37 +0300
committerDmitry Gutov2013-10-11 05:11:37 +0300
commitb68e29263fbe7c31a54c0dab55a0121701ad8ec3 (patch)
treee9b16752a11a67132c01211d48e5bc6b1cbd7884 /lisp/progmodes/ruby-mode.el
parent0922b8260ac76c153b253c992c1a656fca1a22e2 (diff)
downloademacs-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.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r--lisp/progmodes/ruby-mode.el25
1 files changed, 7 insertions, 18 deletions
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