|
170 | 170 | (defun elixir-smie--semi-ends-match () |
171 | 171 | "Return non-nil if the current line concludes a match block." |
172 | 172 | (when (not (eobp)) |
173 | | - (save-excursion |
174 | | - ;; Warning: Recursion. |
175 | | - ;; This is easy though. |
176 | | - |
177 | | - ;; 1. If we're at a blank line, move forward a character. This takes us to |
178 | | - ;; the next line. |
179 | | - ;; 2. If we're not at the end of the buffer, call this function again. |
180 | | - ;; (Otherwise, return nil.) |
181 | | - |
182 | | - ;; The point here is that we want to treat blank lines as a single semi- |
183 | | - ;; colon when it comes to detecting the end of match statements. This could |
184 | | - ;; also be handled by a `while' expression or some other looping mechanism. |
185 | | - (cl-flet ((self-call () |
186 | | - (if (< (point) (point-max)) |
187 | | - (elixir-smie--semi-ends-match) |
188 | | - nil))) |
189 | | - (cond |
190 | | - ((and (eolp) (bolp)) |
191 | | - (forward-char) |
192 | | - (self-call)) |
193 | | - ((looking-at elixir-smie--spaces-til-eol-regexp) |
194 | | - (move-beginning-of-line 2) |
195 | | - (self-call)) |
196 | | - ;; And if we're NOT on a blank line, move to the end of the line, and see |
197 | | - ;; if we're looking back at a block operator. |
198 | | - (t (move-end-of-line 1) |
199 | | - (looking-back elixir-smie--block-operator-regexp))))))) |
| 173 | + (save-excursion |
| 174 | + ;; Warning: Recursion. |
| 175 | + ;; This is easy though. |
| 176 | + |
| 177 | + ;; 1. If we're at a blank line, move forward a character. This takes us to |
| 178 | + ;; the next line. |
| 179 | + ;; 2. If we're not at the end of the buffer, call this function again. |
| 180 | + ;; (Otherwise, return nil.) |
| 181 | + |
| 182 | + ;; The point here is that we want to treat blank lines as a single semi- |
| 183 | + ;; colon when it comes to detecting the end of match statements. This could |
| 184 | + ;; also be handled by a `while' expression or some other looping mechanism. |
| 185 | + (cl-flet ((self-call () |
| 186 | + (if (< (point) (point-max)) |
| 187 | + (elixir-smie--semi-ends-match) |
| 188 | + nil))) |
| 189 | + (cond |
| 190 | + ((and (eolp) (bolp)) |
| 191 | + (forward-char) |
| 192 | + (self-call)) |
| 193 | + ((looking-at elixir-smie--spaces-til-eol-regexp) |
| 194 | + (move-beginning-of-line 2) |
| 195 | + (self-call)) |
| 196 | + ;; And if we're NOT on a blank line, move to the end of the line, and see |
| 197 | + ;; if we're looking back at a block operator. |
| 198 | + (t (move-end-of-line 1) |
| 199 | + (looking-back elixir-smie--block-operator-regexp))))))) |
200 | 200 |
|
201 | 201 | (defun elixir-smie--same-line-as-parent (parent-pos child-pos) |
202 | 202 | "Return non-nil if `child-pos' is on same line as `parent-pos'." |
|
0 commit comments