@@ -260,12 +260,30 @@ is used to limit the scan."
260260 (put-text-property beg (1+ beg) 'elixir-interpolation
261261 (cons (nth 3 context) (match-data )))))
262262
263- (defconst elixir-syntax-propertize-function
264- (syntax-propertize-rules
265- ((elixir-rx string-delimiter)
266- (0 (ignore (elixir-syntax-stringify))))
267- ((rx (group " #{" (0+ (not (any " }" ))) " }" ))
268- (0 (ignore (elixir-syntax-propertize-interpolation))))))
263+ (defconst elixir-sigil-delimiter-pair
264+ '((?\( . " )" )
265+ (?\{ . " }" )
266+ (?\< . " >" )
267+ (?\[ . " ]" )))
268+
269+ (defun elixir-syntax-replace-property-in-sigil ()
270+ (let ((heredoc-p (save-excursion
271+ (goto-char (match-beginning 0 ))
272+ (looking-at-p " ~s\"\"\" " ))))
273+ (unless heredoc-p
274+ (forward-char 1 )
275+ (let* ((start-delim (char-after (1- (point ))))
276+ (end-delim (or (assoc-default start-delim elixir-sigil-delimiter-pair)
277+ (char-to-string start-delim)))
278+ (end (save-excursion
279+ (skip-chars-forward (concat " ^" end-delim))
280+ (point )))
281+ (word-syntax (string-to-syntax " w" )))
282+ (when (memq start-delim '(?' ?\" ))
283+ (setq end (1+ end))
284+ (forward-char -1 ))
285+ (while (re-search-forward " [\" ']" end t )
286+ (put-text-property (1- (point )) (point ) 'syntax-table word-syntax))))))
269287
270288(defun elixir-syntax-propertize-function (start end )
271289 (let ((case-fold-search nil ))
@@ -274,6 +292,8 @@ is used to limit the scan."
274292 (syntax-propertize-rules
275293 ((elixir-rx string-delimiter)
276294 (0 (ignore (elixir-syntax-stringify))))
295+ ((elixir-rx sigils)
296+ (0 (ignore (elixir-syntax-replace-property-in-sigil))))
277297 ((rx (group " #{" (0+ (not (any " }" ))) " }" ))
278298 (0 (ignore (elixir-syntax-propertize-interpolation)))))
279299 start end)))
0 commit comments