diff options
| author | Dmitry Gutov | 2013-10-26 05:16:37 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2013-10-26 05:16:37 +0400 |
| commit | bae91342a41c1aef864c64c2354dfbfc58335bfa (patch) | |
| tree | cbbd3638d05ffca818ac046281802ce8ae97b61e | |
| parent | eb89dc14d9367b3f2dbb265dedf2e781a4105b03 (diff) | |
| download | emacs-bae91342a41c1aef864c64c2354dfbfc58335bfa.tar.gz emacs-bae91342a41c1aef864c64c2354dfbfc58335bfa.zip | |
* lisp/progmodes/ruby-mode.el (ruby-smie--args-separator-p): Be more
specific in what the first arg can be: a non-keyword word,
string/regexp/percent literal opener, opening paren, or unary
operator followed directly by word.
* test/automated/ruby-mode-tests.el (ruby-toggle-block-to-brace): Fix
the test, in respect to adding the space after the curly.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 11 | ||||
| -rw-r--r-- | test/ChangeLog | 5 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 4 | ||||
| -rw-r--r-- | test/indent/ruby.rb | 25 |
5 files changed, 37 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 82e03a48da4..e25d5bab1e1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-10-26 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * progmodes/ruby-mode.el (ruby-smie--args-separator-p): Be more | ||
| 4 | specific in what the first arg can be: a non-keyword word, | ||
| 5 | string/regexp/percent literal opener, opening paren, or unary | ||
| 6 | operator followed directly by word. | ||
| 7 | |||
| 1 | 2013-10-25 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2013-10-25 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * progmodes/prolog.el: Remove old indent; use post-self-insert-hook. | 10 | * progmodes/prolog.el: Remove old indent; use post-self-insert-hook. |
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index dbca0d4dd26..b85385a7428 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -372,9 +372,18 @@ explicitly declared in magic comment." | |||
| 372 | (and | 372 | (and |
| 373 | (< pos (line-end-position)) | 373 | (< pos (line-end-position)) |
| 374 | (or (eq (char-syntax (preceding-char)) '?w) | 374 | (or (eq (char-syntax (preceding-char)) '?w) |
| 375 | ;; FIXME: Check that the preceding token is not a keyword. | ||
| 376 | ;; This isn't very important most of the time, though. | ||
| 375 | (and (memq (preceding-char) '(?! ??)) | 377 | (and (memq (preceding-char) '(?! ??)) |
| 376 | (eq (char-syntax (char-before (1- (point)))) '?w))) | 378 | (eq (char-syntax (char-before (1- (point)))) '?w))) |
| 377 | (memq (char-syntax (char-after pos)) '(?w ?\")))) | 379 | (or (and (eq (char-syntax (char-after pos)) ?w) |
| 380 | (not (looking-at (regexp-opt '("unless" "if" "while" "until" | ||
| 381 | "else" "elsif" "do" "end") | ||
| 382 | 'symbols)))) | ||
| 383 | (memq (syntax-after pos) '(7 15)) | ||
| 384 | (save-excursion | ||
| 385 | (goto-char pos) | ||
| 386 | (looking-at "\\s(\\|[-+!~:]\\sw"))))) | ||
| 378 | 387 | ||
| 379 | (defun ruby-smie--at-dot-call () | 388 | (defun ruby-smie--at-dot-call () |
| 380 | (and (eq ?w (char-syntax (following-char))) | 389 | (and (eq ?w (char-syntax (following-char))) |
diff --git a/test/ChangeLog b/test/ChangeLog index 10acf187967..6572b9c46e4 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-10-26 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/ruby-mode-tests.el (ruby-toggle-block-to-brace): Fix | ||
| 4 | the test, in respect to adding the space after the curly. | ||
| 5 | |||
| 1 | 2013-10-24 Michael Albinus <michael.albinus@gmx.de> | 6 | 2013-10-24 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 7 | ||
| 3 | * automated/ert-tests.el (ert-test-skip-unless): New test case. | 8 | * automated/ert-tests.el (ert-test-skip-unless): New test case. |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index dafe393377b..dc86b4a2914 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -292,8 +292,8 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 292 | (should (string= "foo do |b|\nend" (buffer-string))))) | 292 | (should (string= "foo do |b|\nend" (buffer-string))))) |
| 293 | 293 | ||
| 294 | (ert-deftest ruby-toggle-block-to-brace () | 294 | (ert-deftest ruby-toggle-block-to-brace () |
| 295 | (let ((pairs '((16 . "foo {|b| b + 2 }") | 295 | (let ((pairs '((17 . "foo { |b| b + 2 }") |
| 296 | (15 . "foo {|b|\n b + 2\n}")))) | 296 | (16 . "foo { |b|\n b + 2\n}")))) |
| 297 | (dolist (pair pairs) | 297 | (dolist (pair pairs) |
| 298 | (with-temp-buffer | 298 | (with-temp-buffer |
| 299 | (let ((fill-column (car pair))) | 299 | (let ((fill-column (car pair))) |
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 1fd19cf34d4..9532a4b4245 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb | |||
| @@ -174,6 +174,19 @@ method? arg1, | |||
| 174 | method! arg1, | 174 | method! arg1, |
| 175 | arg2 | 175 | arg2 |
| 176 | 176 | ||
| 177 | method !arg1, | ||
| 178 | arg2 | ||
| 179 | |||
| 180 | method [], | ||
| 181 | arg2 | ||
| 182 | |||
| 183 | method :foo, | ||
| 184 | :bar | ||
| 185 | |||
| 186 | method (a + b), | ||
| 187 | c, :d => :e, | ||
| 188 | f: g | ||
| 189 | |||
| 177 | it "is a method call with block" do |asd| | 190 | it "is a method call with block" do |asd| |
| 178 | foo | 191 | foo |
| 179 | end | 192 | end |
| @@ -213,18 +226,6 @@ foo = [1, 2, 3].map do |i| | |||
| 213 | i + 1 | 226 | i + 1 |
| 214 | end | 227 | end |
| 215 | 228 | ||
| 216 | method !arg1, | ||
| 217 | arg2 | ||
| 218 | |||
| 219 | method [], | ||
| 220 | arg2 | ||
| 221 | |||
| 222 | method :foo, | ||
| 223 | :bar | ||
| 224 | |||
| 225 | method (a + b), | ||
| 226 | c | ||
| 227 | |||
| 228 | bar.foo do # "." is parent to "do"; it shouldn't be. | 229 | bar.foo do # "." is parent to "do"; it shouldn't be. |
| 229 | bar | 230 | bar |
| 230 | end | 231 | end |