[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r114731: * lisp/progmodes/ruby-mode.el (ruby-mode-ma
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] trunk r114731: * lisp/progmodes/ruby-mode.el (ruby-mode-map): Add binding for |
Date: |
Mon, 21 Oct 2013 03:50:15 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 114731
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Mon 2013-10-21 07:50:06 +0400
message:
* lisp/progmodes/ruby-mode.el (ruby-mode-map): Add binding for
`smie-down-list'.
(ruby-smie--args-separator-p): Check that there's no newline
between method call and its arguments.
(ruby-smie-rules): Handle new cases: curly block with and without
parameters, hash surrounded with parens, block passed to
paren-less method call.
* test/indent/ruby.rb: New examples for indentation of blocks. Example
of hash inside parens that inflooped before this commit.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/progmodes/ruby-mode.el
rubymode.el-20091113204419-o5vbwnq5f7feedwu-8804
test/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-8588
test/indent/ruby.rb ruby.rb-20120424165921-h044139hbrd7snvw-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-10-20 14:27:22 +0000
+++ b/lisp/ChangeLog 2013-10-21 03:50:06 +0000
@@ -1,3 +1,10 @@
+2013-10-21 Dmitry Gutov <address@hidden>
+
+ * progmodes/ruby-mode.el (ruby-mode-map): Add binding for
+ `smie-down-list'.
+ (ruby-smie--args-separator-p): Check that there's no newline
+ between method call and its arguments.
+
2013-10-20 Alan Mackenzie <address@hidden>
Allow comma separated lists after Java "implements".
=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el 2013-10-14 01:51:20 +0000
+++ b/lisp/progmodes/ruby-mode.el 2013-10-21 03:50:06 +0000
@@ -152,6 +152,8 @@
(define-key map (kbd "M-C-b") 'ruby-backward-sexp)
(define-key map (kbd "M-C-f") 'ruby-forward-sexp)
(define-key map (kbd "M-C-q") 'ruby-indent-exp))
+ (when ruby-use-smie
+ (define-key map (kbd "M-C-d") 'smie-down-list))
(define-key map (kbd "M-C-p") 'ruby-beginning-of-block)
(define-key map (kbd "M-C-n") 'ruby-end-of-block)
(define-key map (kbd "C-c {") 'ruby-toggle-block)
@@ -327,10 +329,10 @@
(defun ruby-smie--args-separator-p (pos)
(and
+ (< pos (line-end-position))
(or (eq (char-syntax (preceding-char)) '?w)
(and (memq (preceding-char) '(?! ??))
(eq (char-syntax (char-before (1- (point)))) '?w)))
- (< pos (point-max))
(memq (char-syntax (char-after pos)) '(?w ?\"))))
(defun ruby-smie--forward-id ()
@@ -440,20 +442,39 @@
(`(:elem . args) (if (looking-at "\\s\"") 0))
;; (`(:after . ",") (smie-rule-separator kind))
(`(:after . ";")
- (if (smie-rule-parent-p "def" "begin" "do" "class" "module" "for"
- "while" "until" "unless"
- "if" "then" "elsif" "else" "when"
- "rescue" "ensure")
- (smie-rule-parent ruby-indent-level)
- ;; For (invalid) code between switch and case.
- ;; (if (smie-parent-p "switch") 4)
- 0))
+ (cond
+ ((smie-rule-parent-p "def" "begin" "do" "class" "module" "for"
+ "while" "until" "unless"
+ "if" "then" "elsif" "else" "when"
+ "rescue" "ensure")
+ (smie-rule-parent ruby-indent-level))
+ ((and (smie-rule-parent-p "{")
+ (save-excursion
+ (goto-char (1+ (cadr (smie-indent--parent))))
+ (ruby-smie--opening-pipe-p)
+ (forward-char -1)
+ ;; Can't delegate to `smie-rule-parent' because it
+ ;; short-circuits to `current-column' when the parent
+ ;; token is of paren syntax class and not hanging.
+ (cons 'column (+ (smie-indent-virtual)
+ ruby-indent-level)))))
+ ;; For (invalid) code between switch and case.
+ ;; (if (smie-parent-p "switch") 4)
+ (t 0)))
(`(:before . ,(or `"(" `"[" `"{"))
- ;; Treat purely syntactic block-constructs as being part of their parent,
- ;; when the opening statement is hanging.
- (when (smie-rule-hanging-p)
- (smie-backward-sexp 'halfsexp) (smie-indent-virtual)))
+ (cond
+ ((and (equal token "{")
+ (not (smie-rule-prev-p "(" "{" "[" "," "=>")))
+ ;; Curly block opener.
+ (smie-rule-parent))
+ ((smie-rule-hanging-p)
+ ;; Treat purely syntactic block-constructs as being part of their
parent,
+ ;; when the opening statement is hanging.
+ (let ((state (smie-backward-sexp 'halfsexp)))
+ (when (eq t (car state)) (goto-char (cadr state))))
+ (cons 'column (smie-indent-virtual)))))
(`(:after . ,(or "=" "iuwu-mod")) 2)
+ (`(:after . " @ ") (smie-rule-parent))
(`(:before . "do") (smie-rule-parent))
(`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0)
(`(:before . ,(or `"when"))
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog 2013-10-18 04:27:34 +0000
+++ b/test/ChangeLog 2013-10-21 03:50:06 +0000
@@ -1,3 +1,8 @@
+2013-10-21 Dmitry Gutov <address@hidden>
+
+ * indent/ruby.rb: New examples for indentation of blocks. Example
+ of hash inside parens that inflooped before the present commit.
+
2013-10-17 Barry O'Reilly <address@hidden>
* test/automated/timer-tests.el: New file. Tests that (sit-for 0)
=== modified file 'test/indent/ruby.rb'
--- a/test/indent/ruby.rb 2013-10-15 01:21:22 +0000
+++ b/test/indent/ruby.rb 2013-10-21 03:50:06 +0000
@@ -40,6 +40,11 @@
a: b
}
+foo({
+ a: b,
+ c: d
+ })
+
foo = [ # ruby-deep-indent-disabled
1
]
@@ -165,6 +170,18 @@
method! arg1,
arg2
+it "is a method call with block" do |asd|
+ foo
+end
+
+it("is too!") {
+ bar
+}
+
+and_this_one(has) { |block, parameters|
+ tee
+}
+
# Examples below still fail with `ruby-use-smie' on:
foo +
@@ -192,11 +209,3 @@
method (a + b),
c
-
-it "is a method call with block" do
- foo
-end
-
-it("is too!") {
- bar
-}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r114731: * lisp/progmodes/ruby-mode.el (ruby-mode-map): Add binding for,
Dmitry Gutov <=