f



how to insert 'artificial' text with font-lock

What I want to accomplish is that font-lock, besides putting a face on
certain part of the buffer, also inserts text just for display, i.e.
text which is not part of the underlying file.

E.g. I want that every occurrence of the literal string "(C)" is
displayed with the face adoc-replacement, followed by an inserted copy
right sign "\u00A9".

This is the font lock keyword I tried, but it doesn't work. It applies
the face, but doesn't insert the text.

(list "\\((C)\\)"  '(1 '(face adoc-replacement after-string
"\u00A9")))

The next question would then be how I could make that inserted text
also intangible & read-only.
0
Florian
7/14/2010 2:35:18 PM
comp.emacs 4822 articles. 1 followers. Post Follow

1 Replies
594 Views

Similar Articles

[PageSpeed] 26

On Jul 14, 9:35=A0am, Florian Kaufmann <sensor...@gmail.com> wrote:
> What I want to accomplish is that font-lock, besides putting a face on
> certain part of the buffer, also inserts text just for display, i.e.
> text which is not part of the underlying file.
>
> E.g. I want that every occurrence of the literal string "(C)" is
> displayed with the face adoc-replacement, followed by an inserted copy
> right sign "\u00A9".
>
> This is the font lock keyword I tried, but it doesn't work. It applies
> the face, but doesn't insert the text.
>
> (list "\\((C)\\)" =A0'(1 '(face adoc-replacement after-string
> "\u00A9")))
>
> The next question would then be how I could make that inserted text
> also intangible & read-only.

whitespace-mode does something very similar to what you want.  It does
it with display-tables.

(setq buffer-display-table (make-display-table))
(aset buffer-display-table ?! [?! ??]) ; make all '!' display as '!?'
0
jpkotta
7/17/2010 1:50:13 AM
Reply: