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

project.clj formatting #4

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

project.clj formatting #4

Fazerty opened this issue Feb 3, 2012 · 2 comments

Comments

@Fazerty
Copy link

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

@Licenser
Copy link
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
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants