Created
August 26, 2014 03:19
-
-
Save mattdeboard/b2b1e1991a9c5d5538bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun elixir-smie--semi-ends-match () | |
"Return non-nil if the current line concludes a match block." | |
(save-excursion | |
;; Warning: Recursion. | |
;; This is easy though. | |
;; 1. If we're at a blank line, move forward a character. This takes us to | |
;; the next line. | |
;; 2. If we're not at the end of the buffer, call this function again. | |
;; (Otherwise, return nil.) | |
;; The point here is that we want to treat blank lines as a single semi- | |
;; colon when it comes to detecting the end of match statements. This could | |
;; also be handled by a `while' expression or some other looping mechanism. | |
(flet ((self-call () | |
(if (< (point) (point-max)) | |
(elixir-smie--semi-ends-match) | |
nil))) | |
(cond | |
((and (eolp) (bolp)) | |
(forward-char) | |
(self-call)) | |
((looking-at elixir-smie--spaces-til-eol-regexp) | |
(move-beginning-of-line 2) | |
(self-call)) | |
;; And if we're NOT on a blank line, move to the end of the line, and see | |
;; if we're looking back at a block operator. | |
(t (move-end-of-line 1) | |
(looking-back elixir-smie--block-operator-regexp)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment