Licenser / lein-search

A lein plugin that allows searching, and adding dependencies from clojars.
Eclipse Public License 1.0
38 stars 8 forks source link

project.clj formatting #4

Open Fazerty opened 12 years ago

Fazerty commented 12 years ago

Hello,

I use lein-search frequently and it works well but

Thanks

Licenser commented 12 years ago

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 12 years ago

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.