help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Font-Locking for Allout Mode


From: Stephen Berman
Subject: Re: Font-Locking for Allout Mode
Date: Sun, 11 Mar 2007 16:07:53 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux)

On Fri, 09 Mar 2007 17:50:52 +0100 Stephen Berman
<address@hidden> wrote:

> On Fri, 09 Mar 2007 15:27:13 +0100 Tassilo Horn
> <address@hidden> wrote: 
>
>> Stephen Berman <address@hidden> writes:
>>
>> Hi Stephen,
>>
>>> Our discussion convinced me that the code from the Emacs wiki wasn't
>>> playing well with Emacs lisp mode, so I fiddled with it and came up
>>> with a variant that works in Emacs lisp mode.  Replace your
>>> th-allout-font-lock-keywords with the following:
> [...]
>> Yes, now it works. But I get a lot of the messages below in *Messages*:
>>
>> ,----
>> | Invalid face reference: 2
>> | Invalid face reference: 1 [9 times]
>> | Invalid face reference: 2 [2 times]
>> `----
>
> I didn't notice them before, but I get them too.  The message comes
> from merge_face_ref in xfaces.c, and a comment there says: "FACE_REF
> ought to be a face name."  This apparently means that the face
> specification I gave is flawed, although the results look ok.  But I'm
> afraid I'm out of my depth here.  If we're lucky some font-lock guru
> will notice this thread and help us.

Font-Lock guru Stefan Monnier's post provided the necessary help,
though my first attempt to make use of it was wrong.  But the
following works and uses valid face references:

(defvar srb-allout-font-lock-keywords
  '((eval . (list (concat "^\\(?:" allout-regexp "\\).+")
                  0 '(cond ((= (allout-depth) 1)
                            font-lock-function-name-face)
                           ((= (allout-depth) 2)
                            font-lock-variable-name-face)
                           ((= (allout-depth) 3)
                            font-lock-keyword-face)
                           ((= (allout-depth) 4)
                            font-lock-builtin-face)
                           ((= (allout-depth) 5)
                            font-lock-comment-face)
                           ((= (allout-depth) 6)
                            font-lock-constant-face)
                           ((= (allout-depth) 7)
                            font-lock-type-face)
                           ((= (allout-depth) 8)
                            font-lock-string-face)
                           (t font-lock-warning-face))
                  t nil)))
  "Additional expressions to highlight in Allout mode.")

Steve Berman





reply via email to

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