[Lazarus] Lazarus AutoSave package does not autosave all files....

Bo Berglund bo.berglund at gmail.com
Fri May 21 13:44:31 CEST 2021


On Wed, 12 May 2021 00:06:50 +0200, Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>Is there a way to make AutoSave save also the main project file?
>I have noted that when I build a more complex program I have an lpr (or dpr for
>Delphi compatibility) project file but if the project is a simple program the
>project file becomes a pas file.
>
>In both cases I have found that the AutoSave plug-in (available from OnLine
>Package Manager) does its job concerning the extra units in the project so when
>working on these there is regular disk saves happening.
>Not so with the dpr/lpr files or the pas file which contains the simple program.
>
>Have I missed something here or is there some hidden config which has to be
>enabled to get it to save ALL files?

So I decided to move "everything" out of the lpr file and put the program itself
as a procedure in the new mainprogram.pas file instead.
Basically I now have an empty lpr file with this:

program Myprogram;

uses
  {$IFDEF UNIX}
    cthreads,
    baseunix,
  {$ENDIF} 
  mainprogram;

{Main program start}

{$R *.res}

begin
  MainProg;
end.

Everything that was in the lpr has moved to mainprogram.pas

Now I have a question regarding uses in the lpr file:

Whenever I create a new unit in Lazarus it puts its name into the lpr file uses
clause. Why does it do this? Is it required that all units used by the program
must be listed in the lpr file uses clause?

It seems to work anyway, I moved all of the uses from dpr into mainprogram.pas
and now Lazarus "Hints" that there are lots of units not used by
mainprogram.pas.

Why were these not hinted when they were in the lpr file?

Now at least I am not losing my code edits the next time Lazarus crashes on
me...
Autosaved every 5 seconds.

-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list