Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capitalised imports are organised last #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions scala-organise.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
(forward-line 1))

(delete-region start (point))
(let* ((keys (sort (delete-dups (mapcar #'car imports)) #'string<)))
(let* ((keys (sort (delete-dups (mapcar #'car imports)) #'string<))
deferred)
(dolist (setting scala-organise-first)
(let (done)
(dolist (key keys)
Expand All @@ -59,9 +60,17 @@
(when done
(insert "\n"))
(setq keys (seq-difference keys done))))
(dolist (key keys)
(insert (scala-organise--render (assoc key imports))))
(when keys
(dolist (key keys)
(if (let (case-fold-search)
(string-match-p (rx line-start upper) key))
(push key deferred)
(insert (scala-organise--render (assoc key imports)))))
(when (length> keys (length deferred))
(insert "\n")))
(when deferred
(dolist (key (reverse deferred))
(insert (scala-organise--render (assoc key imports))))
(insert "\n")))))
(when (re-search-forward (rx line-start (* space) "import ") nil t)
(message "Inline imports, starting at line %i, have not been organised." (line-number-at-pos))))))
Expand Down