|
106 | 106 | (statements (statement)
|
107 | 107 | (statement ";" statements))
|
108 | 108 | (statement ("def" non-block-expr "do" statements "end")
|
| 109 | + ("defp" non-block-expr "do" statements "end") |
| 110 | + ("defmacro" non-block-expr "do" statements "end") |
| 111 | + ("defmacrop" non-block-expr "do" statements "end") |
109 | 112 | (non-block-expr "fn" match-statements "end")
|
110 | 113 | (non-block-expr "do" statements "end")
|
111 | 114 | ("if" non-block-expr "do" statements "else" statements "end")
|
|
192 | 195 | (beginning-of-line)
|
193 | 196 | (looking-at "^\s+->.+$")))
|
194 | 197 |
|
| 198 | +(defun elixir-smie-line-starts-with-do-colon-p () |
| 199 | + (save-excursion |
| 200 | + (beginning-of-line) |
| 201 | + (looking-at "^\s+do:"))) |
| 202 | + |
195 | 203 | (defun elixir-smie--semi-ends-match ()
|
196 | 204 | "Return non-nil if the current line concludes a match block."
|
197 | 205 | (when (not (eobp))
|
|
353 | 361 | (smie-rule-parent))
|
354 | 362 | (`(:before . "do:")
|
355 | 363 | (cond
|
356 |
| - ((smie-rule-parent-p "def" "if") |
357 |
| - (smie-rule-parent)))) |
| 364 | + ((smie-rule-parent-p "def" "if" "defp" "defmacro" "defmacrop") |
| 365 | + (smie-rule-parent)) |
| 366 | + ((and (smie-rule-parent-p ";") |
| 367 | + (not (smie-rule-hanging-p))) |
| 368 | + (smie-rule-parent elixir-smie-indent-basic)))) |
358 | 369 | (`(:before . "do")
|
359 | 370 | (cond
|
360 | 371 | ((and (smie-rule-parent-p "case")
|
|
444 | 455 | (t elixir-smie-indent-basic)))
|
445 | 456 | (`(:before . "if")
|
446 | 457 | (cond
|
447 |
| - ((smie-rule-parent-p ";") |
| 458 | + (t |
448 | 459 | (smie-rule-parent))))
|
449 | 460 | (`(:before . "->")
|
450 | 461 | (cond
|
|
528 | 539 | (smie-rule-hanging-p))
|
529 | 540 | (smie-rule-parent elixir-smie-indent-basic))
|
530 | 541 | ((smie-rule-parent-p "after" "catch" "def" "defmodule" "defp" "do" "else"
|
531 |
| - "fn" "if" "rescue" "try" "unless") |
| 542 | + "fn" "if" "rescue" "try" "unless" "defmacro" "defmacrop") |
532 | 543 | (smie-rule-parent))
|
533 | 544 | ;; Example
|
534 | 545 | ;;
|
|
541 | 552 | ((and (smie-rule-parent-p "->")
|
542 | 553 | (smie-rule-hanging-p))
|
543 | 554 | (smie-rule-parent))
|
544 |
| - )) |
| 555 | + ;; Example |
| 556 | + ;; |
| 557 | + ;; defp skip, |
| 558 | + ;; do: true <- indent two spaces |
| 559 | + ((and (smie-rule-parent-p ";") |
| 560 | + (smie-rule-hanging-p) |
| 561 | + (elixir-smie-line-starts-with-do-colon-p)) |
| 562 | + (smie-rule-parent (- elixir-smie-indent-basic))))) |
545 | 563 | (`(:after . ";")
|
546 | 564 | (cond
|
547 | 565 | ((smie-rule-parent-p "def")
|
|
0 commit comments