[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Advice on how to save/restore editor buffers



    Date: Friday, 1 July 1983, 11:13-EDT
    From: Henry Lieberman <Henry@MIT-OZ>
    I would like to "save the state of the buffer" at some point, 
    then allow some editing operations, then later optionally
    restore the saved state [edited text, point and mark].
A more extensive explanation of what it is you're trying to do
would be helpful, but I'll do my best without this information.

    - Save the buffer by COPY-INTERVAL, POINT and MARK by
    COPY-BP. 

Well, depends on exactly what you're trying to do.  But copy-bp will
create a second bp pointing into the same original buffer, not into
the copy produced by copy-interval.  There really ought to be a way
to copy an interval and create analogous copied BPs with it, now that
you mention it; this never came up in Zwei's implementation so I never
did it.

    - As above, but make strings instead and use indices into strings.

Well, given the lack of the facility I mentioned, yeah, this might
be the best way.  There is a way to convert a BP into a numerical
index somewhere (I think m-X Revert uses this), and to go the other
way you can just use forward-char.

    - In the case I don't change buffers, but some buffer text
    has been edited, can I avoid save/restore on the buffer interval?

I don't understand this.

    - When do I need MOVES type bp's vs. NIL type bp's?

There are three kinds: normal, moves, and nil.  The nil kind do not
relocate when text is inserted or deleted; they are invalid after
an insert or delete has happened and should not be used, since they
might point into a deleted line, or off the end of a line.  Normal
and moves relocate properly and are almost identical, the only
difference being what happens if text is inserted at exactly the
place that the BP points: normal ones end up before the inserted
text and moves ones end up after it.