Skip to content

Commit e0818a3

Browse files
committed
Change haskell-cabal-enum-targets
1 parent 8fe0bb6 commit e0818a3

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

haskell-cabal.el

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -445,23 +445,19 @@ OTHER-WINDOW use `find-file-other-window'."
445445
(plist-get section :data-start-column))
446446

447447
(defun haskell-cabal-enum-targets ()
448-
"Enumerate targets from .cabal file."
449-
(defvar haskell-cabal-source-bearing-sections)
448+
"Enumerate .cabal targets."
450449
(let ((cabal-file (haskell-cabal-find-file)))
451450
(when (and cabal-file (file-readable-p cabal-file))
452451
(with-temp-buffer
453452
(insert-file-contents cabal-file)
454-
(let* ((targets (mapcar (lambda (arg) (haskell-cabal--all-instances arg))
455-
haskell-cabal-source-bearing-sections)))
456-
(apply #'append targets))))))
457-
458-
(defun haskell-cabal--all-instances (target)
459-
"Return list of all instances of TARGET section."
460-
(goto-char (point-min))
461-
(let (matches)
462-
(while (re-search-forward (concat target " +\\([[:word:]-]+\\)") nil t)
463-
(push (match-string 1) matches))
464-
(sort matches 'string<)))
453+
(haskell-cabal-mode)
454+
(let (matches)
455+
(goto-char (point-min))
456+
(haskell-cabal-next-section)
457+
(while (not (eobp))
458+
(push (haskell-cabal-section-value (haskell-cabal-section)) matches)
459+
(haskell-cabal-next-section))
460+
(reverse matches))))))
465461

466462
(defmacro haskell-cabal-with-subsection (subsection replace &rest funs)
467463
"Copy subsection data into a temporary buffer, save indentation

0 commit comments

Comments
 (0)