Subject: Re: bug#8925: 23.2; all syntax highlighting disappears from ERC mode when I M-x toggle-show-tabs-show-ws

From: Daniel Colascione <[email-masked]>
Date: Sat, 25 Jun 2011 10:34:53 -0700

On 6/24/11 6:23 PM, Glenn Morris wrote:
> "Zooko O'Whielacronx" wrote:
> 
>> ERC normally shows all sorts of useful information by changing the
>> fonts, for example, nicks are in different colors. However recently I
>> ran M-x toggle-show-tabs-show-ws, and now when I start an ERC buffer
>> (for example by joining a new IRC channel), it shows the normal
>> syntax-highlighted view, but then whenever I hit a key (or maybe
>> whenever someone else posts a message to the channel? I'm not sure) all
>> the syntax highlighting disappears, and it becomes a very boring black
>> and white rendering of the channel.
> 
> Probably you should report this to the authors of whatever package
> provides the function `toggle-show-tabs-show-ws' (it's not part of Emacs).

The problem is more general. ERC inserts strings with face properties
into its buffer. When _anything_ that uses font-lock also runs in this
buffer, font-lock will clear all face attributes and undo ERC's
highlighting. This highlighting can't be easily reconstructed because it
depends on information no longer present in the buffer, such as the
membership list of a channel at the time a particular message was received.

There are two approaches to solving the issue:

1) Have ERC use overlays instead of text properties for its highlighting, or

2) Transform ERC face properties to another property (e.g., erc-face),
and create a custom font-lock matcher that applies the highlights stored
in these erc-face properties to face, allowing the highlighting scheme
to be reconstructed on demand.

The first is arguably cleaner, but without setting face, text yanked to
another buffer from an ERC buffer will be unhighlighted.