[Lazarus] Format code on Save

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Feb 23 10:08:59 CET 2017


On Thu, 23 Feb 2017 08:41:06 +0000
Graeme Geldenhuys via Lazarus <lazarus at lists.lazarus-ide.org> wrote:

>[...]
> > Check parameter SaveStep.  
> 
> I tried both sefsBeforeWrite and sefsAfterWrite - it made no difference
> to the issue of the method being called twice.
> 
> Also, what does the AddHandlerOnSaveEditorFile()'s "AtLast" parameter
> mean and do?

Prepend or append to the list of handlers.

 
> I also set the Return result to mrOK.

Good.


> Here is the whole implementation of the event handler and Register call.
> 
> 
> ==========================
> procedure Register;
> begin
>   LazarusIDE.AddHandlerOnSaveEditorFile(@uJCFHandler.BeforeSaveCallJCF,
>     False);
> end;
> 
> function TJCFHandler.BeforeSaveCallJCF(Sender: TObject;
>    aFile: TLazProjectFile; SaveStep: TSaveEditorFileStep;
>    TargetFilename: string): TModalResult;
> var
>   cmd: TIDECommand;
> begin
>   SaveStep := sefsBeforeWrite;

You set a non var parameter? Think again.

Mattias


More information about the Lazarus mailing list