project.clj formatting #4

Open
Fazerty opened this Issue Feb 3, 2012 · 2 comments

Comments

Projects
None yet
2 participants

Fazerty commented Feb 3, 2012

Hello,

I use lein-search frequently and it works well but

  • I loose all my comments
  • I loose the code formatting. All is on the same line.
    Can you fix it?

Thanks

Owner

Licenser commented Feb 4, 2012

Hi Fazerty,e
sadly the limits of what the reader gives back kick in here. When 'reading' the project.clj file, one only gets back a data structure, all formating and comments removed so printing them back in the same way is not done easiely.
While I won't say it is impossible to keep the stuff it would mean hand parsing all the data and adding some heuristics where what belongs to. I will think if I come up with a feasable solution to that but can't promise anything.

Fazerty commented Feb 4, 2012

Hi,
I thought that it could be possible to keep the reading step as it is but use regex to write modifications to the file instead of writing a new file. The comments and formatting will be kept except inside dependencies
but I think it's a very special case and comments within dependencies can be lost.
Example:
;; a comment
[ xxxx ;;an other comment

"version-number"]
;; [yyyy "123"] a third comment

will be replaced by

;; a comment
[xxxx "new-version-number]
;; [yyyy "123"] a third comment

a new step can be added to validate the modifications. If it fails the current way to write file can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment