diff options
| author | Dmitry Gutov | 2014-02-23 10:26:40 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2014-02-23 10:26:40 +0200 |
| commit | dfdb365c4ce062e3506d350e185bc71c0bcc8b10 (patch) | |
| tree | 6f79688a3bfb5d7986806e8bd00e5d2e38c015a8 | |
| parent | 62f9502226a8b910df0abe62b9f9fc7104647c62 (diff) | |
| download | emacs-dfdb365c4ce062e3506d350e185bc71c0bcc8b10.tar.gz emacs-dfdb365c4ce062e3506d350e185bc71c0bcc8b10.zip | |
* lisp/progmodes/ruby-mode.el (ruby-smie-rules): Handle the
inconsistent second element of the list returned by
`smie-indent--parent'.
(ruby-font-lock-keywords): Disqualify any identifier before `=' as
method call.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 10 | ||||
| -rw-r--r-- | test/indent/ruby.rb | 7 |
3 files changed, 17 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bcb09e177c6..40f5d7defc1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -2,6 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | * progmodes/ruby-mode.el (ruby-smie-rules): Don't indent specially | 3 | * progmodes/ruby-mode.el (ruby-smie-rules): Don't indent specially |
| 4 | after `=>' (bug#16811). | 4 | after `=>' (bug#16811). |
| 5 | (ruby-smie-rules): Handle the inconsistent second element of the | ||
| 6 | list returned by `smie-indent--parent'. | ||
| 7 | (ruby-font-lock-keywords): Disqualify any identifier before `=' as | ||
| 8 | method call. | ||
| 5 | 9 | ||
| 6 | 2014-02-23 Juanma Barranquero <lekktu@gmail.com> | 10 | 2014-02-23 Juanma Barranquero <lekktu@gmail.com> |
| 7 | 11 | ||
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 709bc67451d..5cd054a22a8 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -630,9 +630,11 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." | |||
| 630 | (save-excursion | 630 | (save-excursion |
| 631 | ;; Traverse up the parents until the parent is "." at | 631 | ;; Traverse up the parents until the parent is "." at |
| 632 | ;; indentation, or any other token. | 632 | ;; indentation, or any other token. |
| 633 | (while (and (progn | 633 | (while (and (let ((parent (smie-indent--parent))) |
| 634 | (goto-char (1- (cadr (smie-indent--parent)))) | 634 | (goto-char (cadr parent)) |
| 635 | (not (ruby-smie--bosp))) | 635 | (save-excursion |
| 636 | (unless (integerp (car parent)) (forward-char -1)) | ||
| 637 | (not (ruby-smie--bosp)))) | ||
| 636 | (progn | 638 | (progn |
| 637 | (setq smie--parent nil) | 639 | (setq smie--parent nil) |
| 638 | (smie-rule-parent-p ".")))) | 640 | (smie-rule-parent-p ".")))) |
| @@ -2061,7 +2063,7 @@ See `font-lock-syntax-table'.") | |||
| 2061 | "refine" | 2063 | "refine" |
| 2062 | "using") | 2064 | "using") |
| 2063 | 'symbols)) | 2065 | 'symbols)) |
| 2064 | (1 (unless (looking-at " *\\(?:[]|,.)}]\\|$\\)") | 2066 | (1 (unless (looking-at " *\\(?:[]|,.)}=]\\|$\\)") |
| 2065 | font-lock-builtin-face))) | 2067 | font-lock-builtin-face))) |
| 2066 | ;; Kernel methods that have no required arguments. | 2068 | ;; Kernel methods that have no required arguments. |
| 2067 | (,(concat | 2069 | (,(concat |
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 5fd59bfb186..344f16b3d13 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb | |||
| @@ -357,6 +357,13 @@ zoo | |||
| 357 | .lose( | 357 | .lose( |
| 358 | q, p) | 358 | q, p) |
| 359 | 359 | ||
| 360 | a.records().map(&:b).zip( | ||
| 361 | foo) | ||
| 362 | |||
| 363 | # FIXME: This is not consistent with the example below it, but this | ||
| 364 | # ofset only happens if the colon is at eol, which wouldn't be often. | ||
| 365 | # Tokenizing `bar:' as `:bar =>' would be better, but it's hard to | ||
| 366 | # distinguish from a variable reference inside a ternary operator. | ||
| 360 | foo(bar: | 367 | foo(bar: |
| 361 | tee) | 368 | tee) |
| 362 | 369 | ||