emacs-devel
[Top][All Lists]
Advanced

[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: Sat, 24 May 2008 16:38:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> I've converted nxml to font-lock. I used the existing fontification machinery 
> and put it inside a cc-mode-style matcher. Efficiency and output are the 
> same, but:

Looks pretty good.  See some comments below.

 
> +  "after-change book-keeping. returns a cons containing a
> +possibly-enlarged change region. you must still call
> +nxml-extend-region on this expanded region to obtain the full
> +extent of the area needing refontification.
> +
> +For book-keeping, call this function even when fontification is
> +disabled."
> +  ;; Work around bug in insert-file-contents, apparently
> +  (when (> end (1+ (buffer-size)))
> +    (setq start 1)
> +    (setq end (1+ (buffer-size))))

Please use (point-max) rather than (1+ (buffer-size)).
Could you expand on this "bug in insert-file-contents"?
Maybe we can fix it.

> +(defun nxml-fontify-matcher (bound)
> +  "Called as font-lock keyword matcher."
> +
> +  (unless nxml-degraded
> +    (nxml-debug-change "nxml-fontify-matcher" (point) bound)
> +
> +    (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.  
Either we should change nxml-fontify-prolog so it can be told to only
fontify some part of the prolog, or we need to extend the region
according in nxml-extend-region rather than in nxml-fontify-matcher.

> +    (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.  And it indeed seems
to be done there, so it should be removed.  If it's still needed here,
despite nxml-extend-region, then we probably have a bug somewhere (for
the same reason as above:
Fontifying outside of (point)...bound is likely to lead to problems.)


        Stefan




reply via email to

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