[Top][All Lists]

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

Re: Font-Locking for Allout Mode

From: Tassilo Horn
Subject: Re: Font-Locking for Allout Mode
Date: Thu, 08 Mar 2007 17:42:18 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux)

Stephen Berman <address@hidden> writes:

Hi Stehen,

> You cannot see the fontified allout headings in emacs lisp mode
> because the emacs lisp comment fontification overrides it.

No, I don't think so. I fontify TODO and FIXME, too, even though they're
fontified with camment-face by default. And I add the new allout
keywords with

,----[ ~/.emacs ]
| (defun th-font-lock-allout ()
|   (interactive)
|   (font-lock-add-keywords nil th-allout-font-lock-keywords))

and calling `font-lock-add-keywords' with omitted optional variable HOW
should add the new keywords to the beginning of the fontification list,
which normally should overwrite mode-specific fontification. At least
that's my understanding of the docs.

,----[ C-h f font-lock-add-keywords RET ]
| font-lock-add-keywords is a compiled Lisp function in `font-lock.el'.
| (font-lock-add-keywords MODE KEYWORDS &optional HOW)


| By default they are added at the beginning of the current highlighting list.
| If optional argument HOW is `set', they are used to replace the current
| highlighting list.  If HOW is any other non-nil value, they are added at the
| end of the current highlighting list.

> If you use allout with a text-mode file, then you'll see the
> fontification.

Nope, I changed the first line of my .emacs to 

  ;;; -*- mode: text -*-  -*-coding: utf-8 -*-

but when I opened it no fontification was done, although allout was
activated automatically.

> I don't know if it's possible to see it in emacs lisp mode; perhaps by
> modifying font-locking of lisp comments to exclude lines beginning
> with `;;;_'.

It has to work. I highlight TODO and FIXME in all programming modes I
use with

,----[ ~/.emacs ]
| (defvar th-font-lock-modes
|   '(c-mode c++-mode emacs-lisp-mode lisp-mode ruby-mode haskell-mode))
| (eval-at-startup
|  (dolist (mode th-font-lock-modes)
|    (font-lock-add-keywords
|     mode
|     '(("\\<\\(FIXME\\|TODO\\):" 1 font-lock-warning-face t)))))

and that works flawlessly.

>>> I don't know if this indicates a bug in that code.
>> I don't get you here. Does that mean that you use a different code
>> snippet for allout fontification? If yes, could you post your working
>> snippet?
> I use the same code you do (I had also found it on emacswiki and
> modified it as you did).  What I meant is that I don't know why it's
> necessary to add the file local variable for allout-mode (or
> alternatively, invoke font-lock-fontify-buffer) to see the
> fontification using that code, so maybe the code isn't quite right.

Hm, maybe. But I think the "mode: allout" can be omitted nowadays. I
guess I use a newer allout-version than you and it switches on if it
finds the local variable "allout-layout".

| allout-version is a variable defined in `allout.el'.
| Its value is "2.2.1"

,----[ C-h f allout-init RET ]
| allout-init is an interactive compiled Lisp function in `allout.el'.
| (allout-init &optional MODE)
| Prime `allout-mode' to enable/disable auto-activation, wrt
| `allout-layout'.
| ^^^^^^^^^^^^^^^

> BTW, when I add ";;mode: allout" to an the Local Variables section of
> an Emacs lisp file with an allout-layout specification, I still get
> the expected hiding, so it puzzles me that you don't.  Did you eval
> (allout-init t) before visiting the file?

That's in my .emacs. I think that's omitted in the new allout version
with respect to allout-layout.

       People say that if you play Microsoft CD's backwards, you
        hear satanic things, but that's nothing, because if you
               play them forwards, they install Windows.

reply via email to

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