Ok, after thinking about it for a bit, I decided to go ahead and implement
the "customizable leading whitespace" thing right away, as a lot of people
seemed to want it, and also because I just realized that it would not be
difficult at all to do.

So, that said, my Github fork branch
<https://github.com/Akira13641/freepascal> of the compiler now contains a
{$MultiLineStringTrimLeft} directive, that does precisely what you might
think. Here's one of my compiler tests, which I think demonstrates it
fairly well:

program tmultilinestring14;

{$modeswitch MultiLineStrings}

{$MultiLineStringTrimLeft 2}

const A = `
  A
  B
  C
  D
`;

{$MultiLineStringTrimLeft 4}

const B = `
    A
    B
    C
    D
`;

begin
  Write(A);
  Write(B);

  { The number-to-trim being larger, (even much larger) than the amount of
whitespace is not a problem,
    as it stops immediately when it is no longer actually *in* whitespace
regardless. }

  {$MultiLineStringTrimLeft 10000}

  { Non-leading whitespace is preserved properly, of course. }

  Write(`
        sdfs
        sd fs fs
        sd  fsfs  sdfd sfdf
        sdfs fsd
  `);
end.

The output looks like this, showing that everything appears as though it
was written at the "far left" of the file without indentation:

A
B
C
D

A
B
C
D

sdfs
sd fs fs
sd  fsfs  sdfd sfdf
sdfs fsd

Hopefully this will quell some of the uncertainties people may still have
had about the feature, and also ultimately make it easier to use overall!
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to