... and a question.

Some initial points:
* it would be nice if insets were buffer agnostic
* we have tried not to store a Buffer ptr in the insets and have largely 
succeeded, but not quite. That biggie insettabular stores the buffer.
* cut and paste still makes use of current_view.

It seems to me that difficulties arise because we haven't separated cleanly 
the concept of copying an inset and inserting it into a buffer.

Implementation 1
============
Store a Buffer ptr in the inset, but do not copy it when the inset is copied. 
An inset with (Buffer * buffer_ == 0) is perfectly valid but not operational, 
something that can be enforced by Assert(buffer_) in all methods using it.

The inset would become "active" after a call to Inset::insert(Buffer *).

We could lose the buffer parameter passed to so many of these methods.

Implementation 2
============
Similar to (1) but don't store the Buffer *. Instead have a flag bool active 
that is set after a call to Inset::insert(Buffer *) which would now 
initialise all those things that need to know the buffer. Eg, MakeAbsPath to 
insets storing the relative path to a file but needing to know it's absolute 
path to do anything useful.

Personally I prefer (1), but they could be identical to the outside world; 
that's just an implementation detail. But either implementations could get 
rid of current_view from CutAndPaste. Only InsetInsert on paste.

What do people think of this?

I've been thinking about this because I played a little with my BibtexCache 
last night. The cache stores bibtex databases and these could/should be added 
as bibtex insets are created. However, the inset c-tors do not know the 
Buffer that they belong to, so we can't add to the cache because we don't 
know the abs path to the bibtex file. Hence the desire for an explicit 
Inset::insert(Buffer *) method that would be used here to add bibtex 
databases to the cache. It's a good thing to set the cache as early as 
possible so that it can fork the process to run bibtex on the file in the 
background so that the .bbl file is ready to use as soon as possible. Gives 
us elegant labels on citation insets. With a little care also gives us a 
references list of cited references in ascii or docbook export.

Angus

Reply via email to