Subject: bug#4835: 23.1;Improper `Invalid face reference' messages. Performance degraded.

From: "Drew Adams" <[email-masked]>
Date: Wed, 9 Dec 2009 10:23:37 -0800

In hopes of getting some new attention to this bug, I've included a simple test
case in the attached file.

Just use emacs -Q, then load the file.
Then `C-x 5 b *Messages*'.
Then `M-x column-marker-1'.
Then click the *Messages* frame to select it.

At the last step, you will see zillions of messages logged. No messages are
logged when the highlighting occurs, however. They appear only when you do
something else (e.g. choose the *Messages* window). And they keep on coming, as
you interact with Emacs. I assume they are coming from the display engine.

[I followed the above recipe with point in column 21. See the comments at the
end of the attached file - you will see that they reference "column 22".]

The relevant part of `font-lock-keywords' is this:
(column-marker-move-to-22 (0 column-marker-1 prepend t))

Function `column-marker-move-to-22' has this as its `symbol-function' when the
highlighting is turned on:

(lambda (end)
  (let ((start (point)))
    (when (> end (point-max))
      (setq end (point-max)))
    (unless (< (current-column) 22) (forward-line 1))
    (when (< (current-column) 22) (move-to-column 22))
    (while (and (< (current-column) 22)
                (< (point) end)
                (= 0 (+ (forward-line 1)(current-column))))
      (move-to-column 22))
    (if (and (= 22 (current-column))
	     (<= (point) end)
	     (> (point) start))
        (progn
          (set-match-data
           (list (1- (point)) (point)))
          t)
      (goto-char start)
      nil)))

[Note: The issue of using a `lambda' form in `font-lock-keywords' was removed
from the bug recipe: I instead now use a symbol that has a function definition.
This unfortunately changes nothing wrt the bug.]

The code works fine: column 22 is highlighted as expected. (You can turn off
highlighting with `C-u M-x column-marker-1'.)

The only problem is the zillions of messages that are logged to *Messages*
endlessly. That degrades performance so much that it brings Emacs to a crawl.
This is the case for both Emacs 22 and 23. It seems that each redisplay causes
this sequence of four messages to be logged many times, over and over:

 Invalid face reference: prepend
 Invalid face reference: 0
 Invalid face reference: column-marker-move-to-22
 Invalid face reference: t

Again, I *hope* I am simply doing something wrong, and you will help me by
letting me know what is wrong and how to fix it. As far as I can tell, however,
this is a serious bug.