mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00
Revert indentation improvement.
r31061, r31065, r31076, r31308. Because of half baked. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
21e5a1da5c
commit
c3ae81e1a3
2 changed files with 7 additions and 49 deletions
|
@ -459,12 +459,8 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(no-error nil)
|
(no-error nil)
|
||||||
((error "unterminated string")))))
|
((error "unterminated string")))))
|
||||||
|
|
||||||
(defun ruby-deep-indent-paren-p (c &optional pos)
|
(defun ruby-deep-indent-paren-p (c)
|
||||||
(cond ((save-excursion
|
(cond ((listp ruby-deep-indent-paren)
|
||||||
(if pos (goto-char pos))
|
|
||||||
(ruby-expr-beg))
|
|
||||||
nil)
|
|
||||||
((listp ruby-deep-indent-paren)
|
|
||||||
(let ((deep (assoc c ruby-deep-indent-paren)))
|
(let ((deep (assoc c ruby-deep-indent-paren)))
|
||||||
(cond (deep
|
(cond (deep
|
||||||
(or (cdr deep) ruby-deep-indent-paren-style))
|
(or (cdr deep) ruby-deep-indent-paren-style))
|
||||||
|
@ -556,7 +552,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(progn
|
(progn
|
||||||
(and (eq deep 'space) (looking-at ".\\s +[^# \t\n]")
|
(and (eq deep 'space) (looking-at ".\\s +[^# \t\n]")
|
||||||
(setq pnt (1- (match-end 0))))
|
(setq pnt (1- (match-end 0))))
|
||||||
(setq nest (cons (cons (char-after (point)) (point)) nest))
|
(setq nest (cons (cons (char-after (point)) pnt) nest))
|
||||||
(setq pcol (cons (cons pnt depth) pcol))
|
(setq pcol (cons (cons pnt depth) pcol))
|
||||||
(setq depth 0))
|
(setq depth 0))
|
||||||
(setq nest (cons (cons (char-after (point)) pnt) nest))
|
(setq nest (cons (cons (char-after (point)) pnt) nest))
|
||||||
|
@ -564,13 +560,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(goto-char pnt)
|
(goto-char pnt)
|
||||||
)
|
)
|
||||||
((looking-at "[])}]")
|
((looking-at "[])}]")
|
||||||
(if (ruby-deep-indent-paren-p (matching-paren (char-after))
|
(if (ruby-deep-indent-paren-p (matching-paren (char-after)))
|
||||||
(if nest
|
|
||||||
(cdr (nth 0 nest))
|
|
||||||
(save-excursion
|
|
||||||
(forward-char)
|
|
||||||
(ruby-backward-sexp)
|
|
||||||
(point))))
|
|
||||||
(setq depth (cdr (car pcol)) pcol (cdr pcol))
|
(setq depth (cdr (car pcol)) pcol (cdr pcol))
|
||||||
(setq depth (1- depth)))
|
(setq depth (1- depth)))
|
||||||
(setq nest (cdr nest))
|
(setq nest (cdr nest))
|
||||||
|
@ -725,8 +715,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(setq indent nil)) ; do nothing
|
(setq indent nil)) ; do nothing
|
||||||
((car (nth 1 state)) ; in paren
|
((car (nth 1 state)) ; in paren
|
||||||
(goto-char (setq begin (cdr (nth 1 state))))
|
(goto-char (setq begin (cdr (nth 1 state))))
|
||||||
(let ((deep (ruby-deep-indent-paren-p (car (nth 1 state))
|
(let ((deep (ruby-deep-indent-paren-p (car (nth 1 state)))))
|
||||||
(1- (cdr (nth 1 state))))))
|
|
||||||
(if deep
|
(if deep
|
||||||
(cond ((and (eq deep t) (eq (car (nth 1 state)) paren))
|
(cond ((and (eq deep t) (eq (car (nth 1 state)) paren))
|
||||||
(skip-syntax-backward " ")
|
(skip-syntax-backward " ")
|
||||||
|
@ -745,8 +734,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(goto-char parse-start) (back-to-indentation))
|
(goto-char parse-start) (back-to-indentation))
|
||||||
(setq indent (ruby-indent-size (current-column) (nth 2 state))))
|
(setq indent (ruby-indent-size (current-column) (nth 2 state))))
|
||||||
(and (eq (car (nth 1 state)) paren)
|
(and (eq (car (nth 1 state)) paren)
|
||||||
(ruby-deep-indent-paren-p (matching-paren paren)
|
(ruby-deep-indent-paren-p (matching-paren paren))
|
||||||
(1- (cdr (nth 1 state))))
|
|
||||||
(search-backward (char-to-string paren))
|
(search-backward (char-to-string paren))
|
||||||
(setq indent (current-column)))))
|
(setq indent (current-column)))))
|
||||||
((and (nth 2 state) (> (nth 2 state) 0)) ; in nest
|
((and (nth 2 state) (> (nth 2 state) 0)) ; in nest
|
||||||
|
@ -771,9 +759,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(setq eol (point))
|
(setq eol (point))
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(cond
|
(cond
|
||||||
((and (not (ruby-deep-indent-paren-p paren
|
((and (not (ruby-deep-indent-paren-p paren))
|
||||||
(and (cdr (nth 1 state))
|
|
||||||
(1- (cdr (nth 1 state))))))
|
|
||||||
(re-search-forward ruby-negative eol t))
|
(re-search-forward ruby-negative eol t))
|
||||||
(and (not (eq ?_ (char-after (match-end 0))))
|
(and (not (eq ?_ (char-after (match-end 0))))
|
||||||
(setq indent (- indent ruby-indent-level))))
|
(setq indent (- indent ruby-indent-level))))
|
||||||
|
|
|
@ -137,33 +137,5 @@ class TestRubyMode
|
||||||
| end
|
| end
|
||||||
|')
|
|')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_begin_end
|
|
||||||
assert_indent('
|
|
||||||
|begin
|
|
||||||
| a[b]
|
|
||||||
|end
|
|
||||||
|', '
|
|
||||||
|begin
|
|
||||||
| a[b]
|
|
||||||
| end
|
|
||||||
|')
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_array_after_paren_and_space
|
|
||||||
assert_indent('
|
|
||||||
|class A
|
|
||||||
| def foo
|
|
||||||
| foo( [])
|
|
||||||
| end
|
|
||||||
|end
|
|
||||||
|', '
|
|
||||||
|class A
|
|
||||||
| def foo
|
|
||||||
|foo( [])
|
|
||||||
|end
|
|
||||||
| end
|
|
||||||
|')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end if TestRubyMode::EMACS
|
end if TestRubyMode::EMACS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue