@@ -484,7 +484,7 @@ in the file."
484
484
(ws+ (concat spaces " +" ))
485
485
(upcase " [A-Z][A-Za-z0-9_]*" )
486
486
(lowcase " [a-z][A-Za-z0-9_]*" )
487
- (as-form (concat ws+ " as" ws+ upcase))
487
+ (as-form (concat ws+ " as" ws+ " \\ ( " upcase " \\ ) " ))
488
488
(exposing-union-type
489
489
(concat upcase
490
490
(re-? ws
@@ -511,13 +511,28 @@ in the file."
511
511
" )" )))
512
512
(concat " ^import"
513
513
ws+
514
- (concat upcase (re-* " \\ ." upcase))
514
+ (concat " \\ ( " upcase (re-* " \\ ." upcase) " \\ ) " )
515
515
(re-? (re-or (concat as-form (re-? exposing-form))
516
516
(concat exposing-form (re-? as-form)))))))
517
517
" Regex to match elm import (including multiline).
518
518
Import consists of the word \" import\" , real package name, and optional
519
519
\" as\" part, and \" exposing\" part, which may be ordered in either way." )
520
520
521
+ (defun elm-imports-list ()
522
+ " Find all imports in the current buffer.
523
+ Return a list of pairs of (NAME . FULL_NAME)."
524
+ (save-excursion
525
+ (save-match-data
526
+ (let ((matches ()))
527
+ (goto-char (point-min ))
528
+ (while (re-search-forward elm-import--pattern nil t )
529
+ (let ((full (match-string 1 ))
530
+ (as (match-string 2 )))
531
+ (push (cons full full) matches)
532
+ (when as
533
+ (push (cons as full) matches))))
534
+ matches))))
535
+
521
536
;;;### autoload
522
537
(defun elm-sort-imports ()
523
538
" Sort the import list in the current buffer."
0 commit comments