Recent

Author Topic: Exclude Jedi Code Formatter on code section  (Read 3984 times)

rpetges

  • Jr. Member
  • **
  • Posts: 98
    • Attribute Changer Website
Exclude Jedi Code Formatter on code section
« on: November 03, 2018, 04:24:24 pm »
Hi,

I use the built-in Code Formatter to beautify my source code and would like to exclude a part of my source code from formatting.

Is there any directive I can use in source code to instruct Jedi Code Formatter to not process a part of the source code ?

Like $formatcode=off at the beginning of the block and $formatcode=on at the end of the section ?

I searched in the forums but did not find anything.

Romain

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
Re: Exclude Jedi Code Formatter on code section
« Reply #1 on: November 03, 2018, 04:29:52 pm »
AFAIK: NO it's all or nothing. In my case nothing since it makes too many mistakes on new syntax. Unless it gets maintained it becomes less and less useful with every new release of FPC.
But I am sure they don't want the Trumps back...

rpetges

  • Jr. Member
  • **
  • Posts: 98
    • Attribute Changer Website
Re: Exclude Jedi Code Formatter on code section
« Reply #2 on: November 03, 2018, 05:04:45 pm »
Thanks for the confirmation ... I think, I will switch to a 'manual' code formatting  :D

BrunoK

  • Hero Member
  • *****
  • Posts: 666
  • Retired programmer
Re: Exclude Jedi Code Formatter on code section
« Reply #3 on: November 05, 2018, 11:52:33 am »
@Romain

What I do when I want to clarify procedure structures is :

1 Create a new unit. (File->New->Unit)
2 Select/copy syntactically coherent full procedure/function block(s) from the source you are working on and you want to JEDI CF (From procedure SomeProc(etc... to the matching end;)
3 Paste selection it in the unit (1) at the correct position, that is in implementation for complete procedure/function(s).
4 Ctrl-D (JCF) on the unit (1).
5 If worked, paste back reformatted code to the working unit.
6 Close and discard unit created in (1)

BrunoK

  • Hero Member
  • *****
  • Posts: 666
  • Retired programmer
Re: Exclude Jedi Code Formatter on code section
« Reply #4 on: January 23, 2025, 03:36:23 pm »
Since I had to search again how to do it today, JCF can be deactivated locally like in the following code :
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. const
  4.   //jcf:format=off // <--- deactivate formatting <<<<
  5.   a                     = byte(5);
  6.   b                     = smallint(6);
  7.   CP210x_CP2101_VERSION = byte($FF and $01);    ///< CP2101
  8.   //jcf:format=on
  9.  
  10. begin
  11.   writeln(a, ' ', SizeOf(a), ' ', b, ' ', SizeOf(b));
  12.   writeln(CP210x_CP2101_VERSION, ' ', SizeOf(CP210x_CP2101_VERSION));
  13.  
  14. end.


More options were described 4 months ago in file : components\jcf2\docs\special_comments.md


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4552
  • I like bugs.
Re: Exclude Jedi Code Formatter on code section
« Reply #5 on: January 24, 2025, 06:13:54 am »
AFAIK: NO it's all or nothing.
No, it formats only the selected part when there is one. Select a function, then press Ctrl-D.
It can also be guided by special comments as BrunoK mentioned.

Quote
In my case nothing since it makes too many mistakes on new syntax. Unless it gets maintained it becomes less and less useful with every new release of FPC.
It is maintained by DomingoGP. He has fixed many issues about the new FPC syntax. It is worth reporting the ones that do not work.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018