Skip to content

Commit 43f0a06

Browse files
committed
Rearrange code a bit.
1 parent ae86f70 commit 43f0a06

File tree

1 file changed

+42
-46
lines changed

1 file changed

+42
-46
lines changed

elixir-smie.el

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,52 +34,6 @@
3434
table)
3535
"Elixir mode syntax table.")
3636

37-
(defmacro elixir-smie-debug (message &rest format-args)
38-
`(progn
39-
(when elixir-smie-verbose-p
40-
(message (format ,message ,@format-args)))
41-
nil))
42-
43-
(defconst elixir-smie-block-intro-keywords
44-
'(do else catch after rescue -> OP)
45-
"Keywords in which newlines cause confusion for the parser.")
46-
47-
(defvar elixir-smie--operator-regexp
48-
(regexp-opt '("<<<" ">>>" "^^^" "~~~" "&&&" "|||" "===" "!==" "==" "!=" "<="
49-
">=" "<" ">" "&&" "||" "<>" "++" "--" "//"
50-
"/>" "=~" "|>" "->")))
51-
52-
(defun elixir-smie--at-dot-call ()
53-
(and (eq ?w (char-syntax (following-char)))
54-
(eq (char-before) ?.)
55-
(not (eq (char-before (1- (point))) ?.))))
56-
57-
(defun elixir-smie--implicit-semi-p ()
58-
(not (or (memq (char-before) '(?\{ ?\[))
59-
(looking-back elixir-smie--operator-regexp (- (point) 3) t))))
60-
61-
(defun elixir-smie-forward-token ()
62-
(cond
63-
((and (looking-at "\n") (elixir-smie--implicit-semi-p))
64-
(if (eolp) (forward-char 1) (forward-comment 1))
65-
";")
66-
((looking-at elixir-smie--operator-regexp)
67-
(goto-char (match-end 0))
68-
"OP")
69-
(t (smie-default-forward-token))))
70-
71-
(defun elixir-smie-backward-token ()
72-
(let ((pos (point)))
73-
(forward-comment (- (point)))
74-
(cond
75-
((and (> pos (line-end-position))
76-
(elixir-smie--implicit-semi-p))
77-
";")
78-
((looking-back elixir-smie--operator-regexp (- (point) 3) t)
79-
(goto-char (match-beginning 0))
80-
"OP")
81-
(t (smie-default-backward-token)))))
82-
8337
(defconst elixir-smie-grammar
8438
(smie-prec2->grammar
8539
(smie-merge-prec2s
@@ -121,8 +75,50 @@
12175
(left "+" "-" "<<<" ">>>" "^^^" "~~~" "&&&" "|||")
12276
(left "*" "/"))))))
12377

78+
(defvar elixir-smie--operator-regexp
79+
(regexp-opt '("<<<" ">>>" "^^^" "~~~" "&&&" "|||" "===" "!==" "==" "!=" "<="
80+
">=" "<" ">" "&&" "||" "<>" "++" "--" "//"
81+
"/>" "=~" "|>" "->")))
82+
12483
(defvar elixir-smie-indent-basic 2)
12584

85+
(defmacro elixir-smie-debug (message &rest format-args)
86+
`(progn
87+
(when elixir-smie-verbose-p
88+
(message (format ,message ,@format-args)))
89+
nil))
90+
91+
(defun elixir-smie--at-dot-call ()
92+
(and (eq ?w (char-syntax (following-char)))
93+
(eq (char-before) ?.)
94+
(not (eq (char-before (1- (point))) ?.))))
95+
96+
(defun elixir-smie--implicit-semi-p ()
97+
(not (or (memq (char-before) '(?\{ ?\[))
98+
(looking-back elixir-smie--operator-regexp (- (point) 3) t))))
99+
100+
(defun elixir-smie-forward-token ()
101+
(cond
102+
((and (looking-at "\n") (elixir-smie--implicit-semi-p))
103+
(if (eolp) (forward-char 1) (forward-comment 1))
104+
";")
105+
((looking-at elixir-smie--operator-regexp)
106+
(goto-char (match-end 0))
107+
"OP")
108+
(t (smie-default-forward-token))))
109+
110+
(defun elixir-smie-backward-token ()
111+
(let ((pos (point)))
112+
(forward-comment (- (point)))
113+
(cond
114+
((and (> pos (line-end-position))
115+
(elixir-smie--implicit-semi-p))
116+
";")
117+
((looking-back elixir-smie--operator-regexp (- (point) 3) t)
118+
(goto-char (match-beginning 0))
119+
"OP")
120+
(t (smie-default-backward-token)))))
121+
126122
(defun verbose-elixir-smie-rules (kind token)
127123
(let ((value (elixir-smie-rules kind token)))
128124
(elixir-smie-debug "%s '%s'; sibling-p:%s parent:%s prev-is-OP:%s hanging:%s == %s" kind token

0 commit comments

Comments
 (0)