[Top][All Lists]

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

Re: Mule problem.

From: Stefan Monnier
Subject: Re: Mule problem.
Date: 20 Aug 2004 16:31:08 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> So I basically have to take the buffer line, convert it into a
> canonical form based on the byte sequence, take all the error
> messages, convert them into canonical form, too, correlate the errors
> in the messages with the canonical form, and then convert everything
> back.

> It would be most efficient if I could just place markers at the points
> of all error, and then call undo repeatedly until I arrive back at the
> original buffer line, then take a look at where the markers winded
> up.  Unfortunately, this does not work.

I don't think there's a good generic answer.  But in your case, IIUC you're
working on a single line, so maybe you can use something like:
- encode the buffer line to a sequence of bytes.
- figure out the error location(s).
- insert newlines at each error location.
- decode the sequence of bytes back to the "original buffer line"
  plus newlines.
Obviously, you can't use `undo' here, so encode+decode should be a nop
(which is sadly not always the case with Emacs coding-systems).

> If the conversion functions could be given a (sorted) array of string
> positions, and would record where those positions moved to upon
> conversion, this would help quite a bit.

Note that you won't be able to use `undo' in any case, because `undo' will
just replace the canonical string with the unencoded string that was there
before (which has the same effect as decoding, but is done with a single
insert+delete and no knowledge of coding-systems), so it cannot properly
track markers that are in the middle of the changed text: those will end up
either at the beginning or at the end of the changed text.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]