ghc-merge-lines.
This commit is contained in:
parent
ce87ab328a
commit
a6f6dbffe4
@ -51,7 +51,31 @@
|
|||||||
(lambda ()
|
(lambda ()
|
||||||
(re-search-forward "^import\\( *qualified\\)? *" nil t)
|
(re-search-forward "^import\\( *qualified\\)? *" nil t)
|
||||||
nil)
|
nil)
|
||||||
'end-of-line)))))
|
'end-of-line))
|
||||||
|
(ghc-merge-lines))))
|
||||||
|
|
||||||
|
(defun ghc-merge-lines ()
|
||||||
|
(let ((case-fold-search nil))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (not (eolp))
|
||||||
|
(if (looking-at "^import *\\([A-Z][^ \n]+\\) *(\\(.*\\))$")
|
||||||
|
(let ((mod (match-string-no-properties 1))
|
||||||
|
(syms (match-string-no-properties 2))
|
||||||
|
(beg (point)))
|
||||||
|
(forward-line)
|
||||||
|
(ghc-merge-line beg mod syms))
|
||||||
|
(forward-line)))))
|
||||||
|
|
||||||
|
(defun ghc-merge-line (beg mod syms)
|
||||||
|
(let ((regex (concat "^import *" (regexp-quote mod) " *(\\(.*\\))$"))
|
||||||
|
duplicated)
|
||||||
|
(while (looking-at regex)
|
||||||
|
(setq duplicated t)
|
||||||
|
(setq syms (concat syms ", " (match-string-no-properties 1)))
|
||||||
|
(forward-line))
|
||||||
|
(when duplicated
|
||||||
|
(delete-region beg (point))
|
||||||
|
(insert "import " mod " (" syms ")\n"))))
|
||||||
|
|
||||||
(defun ghc-save-buffer ()
|
(defun ghc-save-buffer ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
Loading…
Reference in New Issue
Block a user