Skip to content

Commit 514e434

Browse files
committed
Fix auto add dependencies in cabal
1 parent 3afc5d1 commit 514e434

File tree

2 files changed

+212
-86
lines changed

2 files changed

+212
-86
lines changed

haskell-cabal.el

+10-3
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ nil: no commas, e.g.
627627
Foo Bar
628628
629629
If the styles are mixed, the position of the first comma
630-
determines the style."
630+
determines the style. If there is only one element then `after'
631+
style is assumed."
631632
(let (comma-style)
632633
;; split list items on single line
633634
(goto-char (point-min))
@@ -647,6 +648,13 @@ determines the style."
647648
(unless (eq comma-style 'before)
648649
(setq comma-style 'after))
649650
(replace-match "" nil nil))
651+
652+
;; if there is just one line then set default as 'after
653+
(unless comma-style
654+
(goto-char (point-min))
655+
(forward-line)
656+
(when (eobp)
657+
(setq comma-style 'after)))
650658
(goto-char (point-min))
651659

652660
(haskell-cabal-each-line (haskell-cabal-chomp-line))
@@ -668,9 +676,8 @@ styles."
668676
(insert ", "))))
669677
('after
670678
(goto-char (point-max))
671-
(while (not (bobp))
679+
(while (equal 0 (forward-line -1))
672680
(unless (haskell-cabal-ignore-line-p)
673-
(forward-line -1)
674681
(end-of-line)
675682
(insert ",")
676683
(beginning-of-line))))

0 commit comments

Comments
 (0)