dummzeuch 1505 Posted October 4, 2020 When I see formatting like this (generated by the Delphi formatter, if "Keep user line breaks" is turned on): type TSomeRecord = record a, b, { bla } c, d: integer; end; I wonder whether the Delphi formatter is based on DelForExp like GExperts'. But in the latter this bug has been fixed: type TSomeRecord = record a, b, { bla } c, d: integer; end; On the other hand, this is an interesting formatting: type TSomeRecord = record a, b, // bla c, d: integer; end; This was generated by the Delphi formatter from this input, with the default setting "Keep user line breaks" turned off: type TSomeRecord = record a, b, // bla c, d: integer; end; It would never have occurred to me. Share this post Link to post
Uwe Raabe 2057 Posted October 4, 2020 I often use this double slash comments at the end of a line to force a line break. const cArr: TArray<string> = [ // 'SELECT *', // 'FROM EMPLOYEE', // 'WHERE EMP_NO > 2', // 'ORDER BY EMP_NO', // '']; (Align line end comments is active here) Without these comments the formatter will produce this: const cArr: TArray<string> = ['SELECT *', 'FROM EMPLOYEE', 'WHERE EMP_NO > 2', 'ORDER BY EMP_NO', '']; Share this post Link to post
Fr0sT.Brutal 900 Posted October 5, 2020 21 hours ago, dummzeuch said: I wonder whether the Delphi formatter is based on DelForExp like GExperts'. But in the latter this bug has been fixed: type TSomeRecord = record a, b, { bla } c, d: integer; end; Isn't it a bug as well? b-c-d should go right below a Share this post Link to post
dummzeuch 1505 Posted October 5, 2020 1 hour ago, Fr0sT.Brutal said: Isn't it a bug as well? b-c-d should go right below a Not sure about that. I have seen that kind of formatting with the additional indentation for the second and later field very often. Personally I prefer explicitly giving the type for each field: type TSomeRecord = record a: integer; b: integer; { bla } c: integer; d: integer; end; even if that means a bit more typing. Share this post Link to post
limelect 48 Posted October 12, 2020 (edited) @dummzeuch Kind of off-topic What I liked very much with DelForExp that you could format the whole project. Edited October 12, 2020 by limelect Share this post Link to post
Uwe Raabe 2057 Posted October 12, 2020 1 hour ago, limelect said: What I liked very much with DelForExp that you could format the whole project. The Delphi integrated formatter offers that as well. 1 Share this post Link to post
limelect 48 Posted October 13, 2020 (edited) @Uwe Raabe The only thing that I dislike is that the Formater options are all over. when you triggered DelForExp it opens a form asking what you want to do much simpler and more user friendly. Or am I old fashion? P.S I also have it as a stand-alone Edited October 13, 2020 by limelect Share this post Link to post
Uwe Raabe 2057 Posted October 13, 2020 15 minutes ago, limelect said: P.S I also have it as a stand-alone Formatter.EXE, the Command Line Formatter 1 Share this post Link to post
Vincent Parrett 750 Posted October 26, 2020 I'm just trying to format the code for a project.. the GExperts formatter does a much better job than the built in one (in 10.4 at least) - one thing that bugs me (with both) is how it indents guid attributes on interfaces so ICompiler = interface ['{4A56BA53-6ACD-4A5D-8D55-B921D6CDC8A0}'] becomes ICompiler = interface ['{4A56BA53-6ACD-4A5D-8D55-B921D6CDC8A0}'] There doesn't seem to be any way to control this. Also some comment formatting gets messed up const //options for IACList2 ACLO_NONE = 0; // don't enumerate anything ACLO_CURRENTDIR = 1; // enumerate current directory ACLO_MYCOMPUTER = 2; // enumerate MyComputer ACLO_DESKTOP = 4; // enumerate Desktop Folder ACLO_FAVORITES = 8; // enumerate Favorites Folder ACLO_FILESYSONLY = 16; // enumerate only the file system gets changed to const //options for IACList2 ACLO_NONE = 0; // don't enumerate anything ACLO_CURRENTDIR = 1; // enumerate current directory ACLO_MYCOMPUTER = 2; // enumerate MyComputer ACLO_DESKTOP = 4; // enumerate Desktop Folder ACLO_FAVORITES = 8; // enumerate Favorites Folder ACLO_FILESYSONLY = 16; // enumerate only the file system I turned on Align var/const statements at position 30 and it comes close const //options for IACList2 ACLO_NONE = 0; // don't enumerate anything ACLO_CURRENTDIR = 1; // enumerate current directory ACLO_MYCOMPUTER = 2; // enumerate MyComputer ACLO_DESKTOP = 4; // enumerate Desktop Folder ACLO_FAVORITES = 8; // enumerate Favorites Folder ACLO_FILESYSONLY = 16; // enumerate only the file system use At position will not always work. I tend to use tabs to align them manually after the longest line in the block. So in the original (pre format) version there are tabs before the = and before the // - not sure if this is possible in the formatter without doing some block analysis. Share this post Link to post
Vincent Parrett 750 Posted October 26, 2020 You know what would be nice for the formatter - an option to format on save. Not sure how hard this would be to implement but I'd love to see this. Share this post Link to post
Vincent Parrett 750 Posted October 27, 2020 Another issue. Right now there is a single setting for Math operators, unfortunately that leads to ICompiler = interface function GetSearchPaths : IList<string>; getting formatted as ICompiler = interface function GetSearchPaths : IList < string >; which is rather unfortunate. If GExperts was on github I would fork it, try to fix and submit a pull request.. not sure how that works with sourceforge? Share this post Link to post
Guest Posted October 27, 2020 7 hours ago, Vincent Parrett said: I turned on Align var/const statements at position 30 and it comes close Controlling this based on group of consts will be hard or the result will be not optimal. So a suggestion in order to manually control the format, like format it once and forget about it, and it will be very helpful with "case", as some parts better be manually formatted per ones taste. Let there be a mechanism to disable the formatter for specific code region, like using magic word in an comment, example Quote // DFTbegin and dftEND are case insensitive identifier // DFTbegin Code here will be formatted // dftEND Quote const //options for IACList2 (dftbegin) ACLO_NONE = 0; // don't enumerate anything ACLO_CURRENTDIR = 1; // enumerate current directory ACLO_MYCOMPUTER = 2; // enumerate MyComputer dftend ACLO_DESKTOP = 4; // enumerate Desktop Folder ACLO_FAVORITES = 8; // enumerate Favorites Folder ACLO_FILESYSONLY = 16; // enumerate only the file system Share this post Link to post
Fr0sT.Brutal 900 Posted October 27, 2020 7 hours ago, Vincent Parrett said: not sure how that works with sourceforge? Good old patch (aka diff) files )) Share this post Link to post
dummzeuch 1505 Posted October 27, 2020 (edited) 1 hour ago, Kas Ob. said: Let there be a mechanism to disable the formatter for specific code region, like using magic word in an comment, example Such a mechanism already exists: Everything between {(*} and {*)} does not get formatted. Edited October 27, 2020 by dummzeuch Share this post Link to post
dummzeuch 1505 Posted October 27, 2020 7 hours ago, Vincent Parrett said: If GExperts was on github I would fork it, try to fix and submit a pull request.. not sure how that works with sourceforge? The simplest way is a patch file, as @Fr0sT.Brutal already suggested. Another option is to simply send me the changed sources (I prefer patches). And if you want to be involved deeper, I could give you write access to the repository. But a good start would be to submit a bug report (or feature request) on SourceForge providing input and desired output examples as attachments. I could then easily add those to the unit tests which would increase the likelihood to get them fixed. Share this post Link to post
Guest Posted October 27, 2020 8 minutes ago, dummzeuch said: Such a mechanism already exists: Everything between {(*} and {*)} does not get formatted. I didn't know that ! Share this post Link to post
Guest Posted October 27, 2020 1 hour ago, dummzeuch said: Everything between {(*} and {*)} does not get formatted. Laughing while i am getting angry more and more, it looks cnWizards also does have the same functionality and usage, also like GExperts that information is hidden in the settings form ! Share this post Link to post
dummzeuch 1505 Posted October 27, 2020 21 minutes ago, Kas Ob. said: Laughing while i am getting angry more and more, it looks cnWizards also does have the same functionality and usage, also like GExperts that information is hidden in the settings form ! I'm not surprised that cnWizards is using the same character sequence. But that probably did not come from GExperts but from DelForEx which was the base of the GExperts code formatter. Share this post Link to post
Fr0sT.Brutal 900 Posted October 27, 2020 4 hours ago, Kas Ob. said: it looks cnWizards also does have the same functionality and usage There's quite simple logic behind - block comments of one possible style inside comments of another possible style. Share this post Link to post