Bug 70630 - Better file cleanup or tidying
Summary: Better file cleanup or tidying
Status: RESOLVED FIXED
Alias: None
Product: kile
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Jeroen Wijnhout
URL:
Keywords:
: 70650 70688 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-12-16 19:41 UTC by Sean Clarke
Modified: 2004-05-14 13:43 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Clarke 2003-12-16 19:41:58 UTC
Version:            (using KDE KDE 3.1.94)
Installed from:    SuSE RPMs
OS:          Linux

I notice that using kile (read Latex) heavily creates a load of temp/interim files that aren't needed (.toc, .aux, .log etc. etc.) what would be really nice is an option to tidy up those interim files.. something like :-

1. Cleanup interims on kile exit.
2. Select a directory to keep all interim files (/tmp/kileInterims etc.)

What do you think?

Perhaps something similar exists and I haven't discovered it?
Comment 1 Jeroen Wijnhout 2003-12-21 11:52:51 UTC
You can do Build->Clean, this will clean most intermediate files for you. I don't think it is possible to save the intermediates in a specified directory, since many LaTeX tools require the source files to be in the same dir as the intermediate.

best,
Jeroen
Comment 2 Jeroen Wijnhout 2003-12-21 11:53:08 UTC
*** Bug 70650 has been marked as a duplicate of this bug. ***
Comment 3 Jeroen Wijnhout 2003-12-21 11:53:18 UTC
*** Bug 70688 has been marked as a duplicate of this bug. ***
Comment 4 David Grant 2004-01-08 19:30:39 UTC
It would be cool to have an option whereby Kile would run Clean after exiting Kile...  Would certainly save on diskspace.
Comment 5 Sean Clarke 2004-01-15 11:17:04 UTC
Excellent idea David, this should be made a config option..

"clean temp files on document close"

I state document close here, this will also clean when you close a document as well as exit kile.

I'm actually an experienced developer, if I can get my KDE development environment setup at home (and I have the disk space!!) I'll set about doing this simple change. Of course, it might be implemented by then anyway :-)
Comment 6 Jeroen Wijnhout 2004-01-15 11:43:01 UTC
Subject: Re:  Better file cleanup or tidying

On Thursday 15 January 2004 11:17, you wrote:
> "clean temp files on document close"
>
> I state document close here, this will also clean when you close a document
> as well as exit kile.
>
> I'm actually an experienced developer, if I can get my KDE development
> environment setup at home (and I have the disk space!!) I'll set about
> doing this simple change. Of course, it might be implemented by then anyway
> :-)

Please do, I love patches! Let me know if you start working on this, so we can 
be 100% sure nobody else is trying to implement the same feature.

best,
Jeroen

Comment 7 Sean Clarke 2004-01-16 11:09:33 UTC
OK.. did the implementation at 01:30 this morning :-) - quite simple change really, once I got to grips with the "KDE/QT" way. Kdevelop was very useful.

How do you want to handle projects, I notice under the Kile::CleanAll() method you mention that projects are not handles yet. I suggest one of the following options:-

1. I take on the project CleanAll() (I might need a little guidence here as it may be more involved), so each file is not cleaned up when closed, but when the project is closed or the last file of the project is closed then a ProjectCleanAll() is executed.

2. Leave the project handling for you to plan later - so do I clean up files of a file in a project when that file is closed? or don't clean any files for any file in a project? 

Comment 8 Jeroen Wijnhout 2004-01-16 11:59:53 UTC
Subject: Re:  Better file cleanup or tidying

On Friday 16 January 2004 11:09, you wrote:
> 11:09 ------- OK.. did the implementation at 01:30 this morning :-) - quite
> simple change really, once I got to grips with the "KDE/QT" way. Kdevelop
> was very useful.

Kile is an excellent cure for insomnia, right?

> How do you want to handle projects, I notice under the Kile::CleanAll()
> method you mention that projects are not handles yet. I suggest one of the
> following options:-
>
> 1. I take on the project CleanAll() (I might need a little guidence here as
> it may be more involved), so each file is not cleaned up when closed, but
> when the project is closed or the last file of the project is closed then a
> ProjectCleanAll() is executed.

Cleaning up a project file when the project is still open will lead to 
unwanted side effects (such as removing files that are needed by other files 
in the project). 

Create functions like this:
void Kile::cleanUp()
	Kate::Document	*doc = activeDocument();

	if (doc)
	{
		KileDocumentInfo *docinfo = infoFor(doc);
		if (docinfo)
		{
			docinfo->cleanUp();
		}
	}
}

void KileDocumentInfo::cleanUp()
{
	//do the actual clean-up here
	//only clean files directly related to this file
	//leave master documents alone
}

In Kile::fileClose() you do, just after if (doc->closeURL() ):
if (m_bCleanUpAfterClose)
	docinfo->cleanUp();

If you close a project, all open documents are closed too, so cleaning up is 
done automatically. Unless you want to clean un-opened files as well (doesn't 
seem very sensible to me). However is it probably a nice idea to add a Clean 
Up action to the Project menu (and ProjectView context menu), but I will take 
care of that.

best,
Jeroen

Comment 9 Jeroen Wijnhout 2004-01-16 12:08:37 UTC
Subject: Re:  Better file cleanup or tidying

And of course, we should think about how Kile is going to decide which files 
to delete. Perhaps we can make a configuration dialog that enables the user 
to control which files are deleted. Right now the user is presented with a 
rather cumbersome dialog. It would be very annoying if the user would be 
presented with these dialogs if the users closes a file.

If you have no experience with creating config dialogs, you can hard-code the 
file-extensions in KileDocumentInfo::cleanUp(), we can make it configurable 
later.

best,
Jeroen

Comment 10 Sean Clarke 2004-01-16 19:32:00 UTC
Hmm.. I've implemented it differently (perhaps that's why it was easy?)

I've added a new option to the KileConfigDialog, under the "Reopen files and projects on startup." called something like "Clean temp files on document/project close". This sets a new option in the KConfig object under "Files", "AutoCleanUp" etc.

Then in Kile::fileClose() I check to see if this file is part of a project, if not I call the Kile::CleanAll()... you are right, presently I get the confirmation dialog box (hey it is WIP :-) ), what I was going to do is pass a parameter into CleanAll that determines if the dialog box is displayed. The default would be true, but when I "auto" tidy up it would be false and hence no dialog appears.

Note with this method even when the user is not asked what files to delete it still uses the same list of file extensions, so I could implement a user selectable list (series of checkboxes? or other QT widget) and that would set the CleanUp configuration for both the file close and manual clean up.

I thought about KileDocumentInfo, but thought the "Automatic cleanup" was a kile configuration rather than document configuration issue.

Is this not acceptable/incorrect?
Comment 11 Jeroen Wijnhout 2004-01-16 19:49:49 UTC
Subject: Re:  Better file cleanup or tidying

On Friday 16 January 2004 19:32, Sean Clarke wrote:
> 19:32 ------- Hmm.. I've implemented it differently (perhaps that's why it
> was easy?)

My suggestions do not differ that much, really. Basically you can copy & paste 
the Kile::cleanAll() code to KileDocumentInfo::cleanUp().

> I've added a new option to the KileConfigDialog, under the "Reopen files
> and projects on startup." called something like "Clean temp files on
> document/project close". This sets a new option in the KConfig object under
> "Files", "AutoCleanUp" etc.

This is ok.

> Then in Kile::fileClose() I check to see if this file is part of a project,
> if not I call the Kile::CleanAll()... you are right, presently I get the
> confirmation dialog box (hey it is WIP :-) ), what I was going to do is
> pass a parameter into CleanAll that determines if the dialog box is
> displayed. The default would be true, but when I "auto" tidy up it would be
> false and hence no dialog appears.

This is not bad, but it just doesn't make a lot of sense to ask confirmation 
is one case (manual clean up) and not in the automatic case (after closing a 
file). Therefore I think it is better just have one behaviour and to 
configure the list of extensions in the configuration dialog.

> Note with this method even when the user is not asked what files to delete
> it still uses the same list of file extensions, so I could implement a user
> selectable list (series of checkboxes? or other QT widget) and that would
> set the CleanUp configuration for both the file close and manual clean up.

This is also a way to go. You can probably use a KListBox with some special 
KListBoxItems. We can, of course, let the user decide whether or not to show 
the pop-ups (yes, another config option).

> I thought about KileDocumentInfo, but thought the "Automatic cleanup" was a
> kile configuration rather than document configuration issue.
>
> Is this not acceptable/incorrect?

It is just cleaner (no pun intended). In principle the list of files to delete 
can vary for different documents. So if we later to decide to have subclasses 
of KileDocumentInfo we can just make cleanUp() virtual and reimplement it for 
each subclass. But the biggest advantage is that we can call 
KileDocumentInfo::cleanUp() from the KileProject class. This makes it easy to 
make a KileProject::cleanUp() method.

best,
Jeroen

Comment 12 Sean Clarke 2004-01-17 00:50:53 UTC
Okey dokey... done in KileDocumentInfo etc.

How/where do you wish the delete file extension list to be implemented.

1. A dialog launched from a button in Kile config.
2. The list directly placed on the config dialog, if so under what section (General, Build, Latex etc.).
3. A completly new section in the config dialog.
4. Somewhere else?
Comment 13 Jeroen Wijnhout 2004-01-17 14:05:54 UTC
Subject: Re:  Better file cleanup or tidying

On Saturday 17 January 2004 00:50, Sean Clarke wrote:
> 1. A dialog launched from a button in Kile config.
> 2. The list directly placed on the config dialog, if so under what section
> (General, Build, Latex etc.). 

It is probably best to put it in the general section (in a QGroupBox), with a 
KLineEdit for the list of extensions and a QCheckBox for the auto-clean 
feature.

best,
Jeroen

Comment 14 Sean Clarke 2004-01-18 20:23:14 UTC
Ok.. final question

When a new user starts he won't have any file extensions in his confi so I'll need to create defaults, where should I do this. I have seen 2 places where this sort of thing goes on..

Kile::readConfig()

and 

Kile::ReadSettings()

What I am going to do is use the "if (!config->hasGroup("XYZ")) and then create the defaults (.aux, .toc etc. etc.)
Comment 15 Sean Clarke 2004-01-19 01:33:11 UTC
Ok.. done and tested.

I don't yet have KDE CVS access, how do you want the changes?
Comment 16 Jeroen Wijnhout 2004-01-19 09:46:54 UTC
Subject: Re:  Better file cleanup or tidying

On Sunday 18 January 2004 20:23, you wrote:
> When a new user starts he won't have any file extensions in his confi so
> I'll need to create defaults, where should I do this. I have seen 2 places
> where this sort of thing goes on..
>
> Kile::readConfig()
>
> and
>
> Kile::ReadSettings()
>
> What I am going to do is use the "if (!config->hasGroup("XYZ")) and then
> create the defaults (.aux, .toc etc. etc.)

Defaults are set as follows:
config->readEntry("entryname", "defaultvalue");
i.e.
extensions = config->readConfig("extensions", ".log,.aux,.bbl,.......");

best,
Jeroen
Comment 17 Jeroen Wijnhout 2004-01-19 09:51:20 UTC
Subject: Re:  Better file cleanup or tidying

> Ok.. done and tested.

Great!

> I don't yet have KDE CVS access, how do you want the changes?

Do a 'cvs diff' in the kdeextragear-2/kile/kile directory:
cvs diff -cu > autoclean.diff
And send me the patch. I will apply, test and commit it.

thanks,
Jeroen

Comment 18 Jeroen Wijnhout 2004-05-14 13:43:26 UTC
Implemented by you know who ;-)