[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] use font-lock
From: |
Stefan Monnier |
Subject: |
Re: [patch] use font-lock |
Date: |
Mon, 26 May 2008 10:52:59 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
>> Looks pretty good. See some comments below.
> ...
>> > + ;; Work around bug in insert-file-contents, apparently
> ...
>> Could you expand on this "bug in insert-file-contents"?
>> Maybe we can fix it.
> I think the only person who can comment on this piece is the person
> who wrote it.
Sorry, I didn't notice it came from the original code.
>> > + (when (< (point) nxml-prolog-end)
>> > + (goto-char (point-min))
>> > + (nxml-fontify-prolog)
>> > + (goto-char nxml-prolog-end))
>>
>> Fontifying outside of (point)...bound is likely to lead to problems.
> I think this code is okay though, since nxml-extend-region *does* snap the
> fontification region to (point-min), and nxml is written to fontify the
> prolog by moving forward over the whole thing, fontifying along the way.
I see, then please add a comment explaining it. You could also replace
the (goto-char (point-min)) by (assert (bobp)) to make sure that
nxml-extend-region did its job.
>> > + (when (not (eq nxml-last-fontify-end (point)))
>> > + (when (not (equal (char-after) ?\<))
>> > + (search-backward "<" nxml-prolog-end t))
>> > + (nxml-ensure-scan-up-to-date)
>> > + (nxml-move-outside-backwards))
>>
>> This should be done in nxml-extend-region instead.
> OTOH, this chunk shouldn't be there. You're right.
Great! I love it when I'm right!
> (let (xmltok-dependent-regions
> xmltok-errors)
> (while (and (< (point) bound)
> (nxml-tokenize-forward))
> (nxml-apply-fontify-rule)))
> will cause problems if the last nxml token extends beyond bound.
> nxml-extend-region ensures that it doesn't, but can we count on it?
Presumably you can count on it. Especially since no other
region-extend-function is run after nxml-extend-region.
You could also change the code to
(let (xmltok-dependent-regions
xmltok-errors)
(while (and (nxml-tokenize-forward)
(< (point) bound))
(nxml-apply-fontify-rule)))
so that in case of an error, the result is to fontify too-little rather
than too-much. This tends to be more visible, so such a bug would
presumably be caught earlier.
Stefan