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: Sat, 10 Mar 2007 00:34:26 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux)

On Fri, 09 Mar 2007 15:36:29 -0500 Stefan Monnier
<monnier@iro.umontreal.ca> wrote:

>> (defvar th-allout-font-lock-keywords
>>   '((eval . (list (concat "^\\(?:" allout-regexp "\\).+")
>>                0 '(cond ((= (allout-depth) 1)
>>                          '(1 . font-lock-function-name-face))
>                            ^^^^
> WTH is this for?

Thanks for the heads up.  To my embarassment, I blindly retained the
conses while fiddling with the following code from
http://www.emacswiki.org/cgi-bin/wiki/AllOut, to try and get it to
work in Emacs lisp mode:

(defvar rf-allout-font-lock-keywords
  '(;;
    ;; Highlight headings according to the level.
    (eval . (list (concat "^\\(" outline-regexp "\\).+")
                0 '(or (cdr (assq (outline-depth)
                                  '((1 . font-lock-function-name-face)
                                    (2 . font-lock-variable-name-face)
                                    (3 . font-lock-keyword-face)
                                    (4 . font-lock-builtin-face)
                                    (5 . font-lock-comment-face)
                                    (6 . font-lock-constant-face)
                                    (7 . font-lock-type-face)
                                    (8 . font-lock-string-face))))
                       font-lock-warning-face)
                nil t)))
  "Additional expressions to highlight in Outline mode.")

The proper adaptation should be the following, right?

(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 nil)))
  "Additional expressions to highlight in Allout mode.")

While I have your attention, do you have any answers to the questions
I raised in this thread, namely (i) why does
rf-allout-font-lock-keywords, unlike srb-allout-font-lock-keywords,
not work in Emacs lisp mode, and (ii) why does a file visited in Text
mode require `mode: allout' as a file local variable when using
srb-allout-font-lock-keywords in order to get the fontification
automatically, why a file visited in Emacs lisp mode does not need
this file local variable?  I'd appreciate any insight you have on
these questions.

Steve Berman





reply via email to

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