>Hope now it's more clear. I already said that the first thing I'd do is to adjust the comments to mention the difference between normal buffers and buffers in embedded workareas.
Moreover, a function called "mainBuffer()" with a comment "returns the document buffer" is not very helpful. Then I'd think that the function should have been called "documentBuffer()", which is supported by the variable names "doc_buffer = mainBuffer()". Last, I'd have to think for myself what a non-document buffer could be and how I could select a buffer that's not the document buffer. Vincent