[Top][All Lists]

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

Re: "Font-lock is limited to text matching" is a myth

From: Daniel Colascione
Subject: Re: "Font-lock is limited to text matching" is a myth
Date: Tue, 11 Aug 2009 10:53:13 -0400

On Aug 11, 2009, at 10:37 AM, Miles Bader wrote:
Daniel Colascione <address@hidden> writes:
Note: diagnostic messages in js2-mode are highlighted using overlays.
I tried using overlays for all highlighting but it was unacceptably
slow and had a tendency to crash Emacs.

I've had the same thought. Just as in aside, overlays seem like a much
better conceptual fit for fontification than text properties do.


AIUI, text properties are considered *part* of the document being edited, which is why modifying text properties modifies the buffer modified flag, why they appear in the undo list, and so on, whereas overlays are for transient, regenerable information *about* the text in the document. Fontification is definitely regenerable, transient information, and so should use overlays. I'm also not particularly fond of fontification being carried around when I kill and yank.

But like you said, these are minor issues and can be worked around. It's no big deal, and text properties perform much better on GNU Emacs. (IIRC, each overlay actually uses a pair of markers. It's no wonder that using hundreds or thousands of them is slow.)

[Aside from the "changing text-properties affect buffer-modified status"
silliness, which I think is probably a mistake, but that's easy enough
to work around.]

Don't forget the undo entries too. Actually, the full list comes from font-lock.el:

(defmacro save-buffer-state (varlist &rest body)
"Bind variables according to VARLIST and eval BODY restoring buffer state."
    (declare (indent 1) (debug let))
    (let ((modified (make-symbol "modified")))
      `(let* ,(append varlist
                      `((,modified (buffer-modified-p))
                        (buffer-undo-list t)
                        (inhibit-read-only t)
                        (inhibit-point-motion-hooks t)
                        (inhibit-modification-hooks t)
         (unless ,modified
           (restore-buffer-modified-p nil)))))

reply via email to

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