@@ -200,30 +200,39 @@ Return non-nil if any line breaks were skipped."
200
200
(block nil
201
201
(while
202
202
(and
203
+ ; ; Cursor is not at the end of the buffer...
203
204
(not (= (point ) (point-max )))
205
+ ; ; ...and the current token is not an empty string...
204
206
(not (string= " " token))
207
+ ; ; ...nor a newline nor a semicolon.
205
208
(not (or (string= " \n " token) (string= " ;" token))))
206
209
(setq token (elixir-smie-next-token-no-lookaround t nil ))
210
+ ; ; If we're at the top level and the token is "->",
211
+ ; ; return t
207
212
(cond ((and (= level 0 ) (string= " ->" token))
208
213
(return t ))
214
+ ; ; If token is "do" or "fn", increment level
209
215
((find token '(" do" " fn" ) :test 'string= )
210
216
(incf level))
217
+ ; ; If token is "end", decrement level
211
218
((string= token " end" )
212
219
(decf level)))))))
213
220
; ; Scan behind:
214
221
(let (token)
215
222
(save-excursion
216
223
(block nil
217
224
(while
218
- (and (not (= (point ) (point-min )))
219
- (not (string= " " token))
220
- (not (string= " do" token))
221
- (not (string= " fn" token)))
225
+ (and
226
+ ; ; Cursor is not at the beginning of buffer...
227
+ (not (= (point ) (point-min )))
228
+ ; ; ...and token is neither empty string, nor "do"/"fn"
229
+ (not (string= " " token))
230
+ (not (string= " do" token))
231
+ (not (string= " fn" token)))
222
232
(setq token (elixir-smie-next-token-no-lookaround nil nil ))
223
233
(when (string= " ->" token)
224
234
(return t )))
225
- (when (or (string= token " do" ))
226
- t )))))
235
+ (when (string= token " do" ) t )))))
227
236
" MATCH-STATEMENT-DELIMITER"
228
237
current-token))))
229
238
@@ -310,15 +319,14 @@ Return non-nil if any line breaks were skipped."
310
319
(`(:after . " end" ) 0 )
311
320
(`(:after . ,(or `" do" ))
312
321
elixir-smie-indent-basic)
313
- (`(:list-intro . ,(or `" do" ))
314
- t )))
322
+ (`(:list-intro . ,(or `" do" )) t )))
315
323
316
324
(define-minor-mode elixir-smie-mode
317
325
" SMIE-based indentation and syntax for Elixir"
318
326
nil nil nil nil
319
327
(set (make-local-variable 'comment-start ) " # " )
320
328
(set (make-local-variable 'comment-end ) " " )
321
- (smie-setup elixir-smie-grammar 'elixir-smie-rules ; 'verbose-elixir-smie-rules
329
+ (smie-setup elixir-smie-grammar 'elixir-smie-rules
322
330
:forward-token 'elixir-smie-forward-token
323
331
:backward-token 'elixir-smie-backward-token ))
324
332
0 commit comments