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: Fri, 09 Mar 2007 12:28:15 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux)

On Fri, 09 Mar 2007 00:18:42 +0100 Tassilo Horn <tassilo@member.fsf.org> wrote:

> Stephen Berman <Stephen.Berman@gmx.net> writes:
>
>> Try saving the following as `allout-test.txt'; I would be surprised,
>> and mystified, if you still don't see the fontification.
>>
>> * test
>> .. test
>>    test
>> . , test
>>     test
>> .  . test
>> .   , test
>> .    . test
>>        test
>> .     , test
>> .      . test
>> .       , test
>>
>> * file local variables list
>> Local variables:
>> allout-layout: (+ :)
>> mode: allout
>> End:
>
> Wow, it works! And really, the "mode: allout" is required. But it still
> doesn't work with emacs lisp files regardless of the presence of the
> "mode: allout"...

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:

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

I still don't understand why the other version doesn't work with Emacs
lisp mode while the above does.  Another puzzling thing is that with
the above, allout fontification works in Emacs lisp mode even without
the file local variable "mode: allout"; however, in text mode that
file local variable is still needed to get the allout fontification.
So there are still some problems with the code, but we've made
progress. :-)

Steve Berman





reply via email to

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