unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: help-gnu-emacs@gnu.org
Subject: Re: allout and font-locking
Date: Wed, 07 Mar 2012 21:13:08 +0100	[thread overview]
Message-ID: <8762eg5fvv.fsf@escher.home> (raw)
In-Reply-To: 87zkbthc6d.wl%mdcroteau@gmail.com

On Tue, 06 Mar 2012 12:27:54 -0500 Marc Croteau <mdcroteau@gmail.com> wrote:

> I'm having problems getting the font-locking features to work. I hope
> someone can help me.
> I have allout (version 2.3) working just fine but the color highlighting is NOT
> working.
>
> I'm running emacs 23.3 on a ubuntu box running 11.10.
> I've tried the suggestions made in (1) the emacswiki with respect to
> (defvar rf-allout-font-lock-keywords...
> and (2) suggestions in this mailing list by Stephen Berman and also
> Tassilo Horn and don't seem to get the color highlighting I'm
> expecting.

The code I posted here five years ago still works for me on openSUSE's
Emacs 23.3 (as well as with the current trunk).  I tested by saving your
test file, starting emacs with -Q and evaluating the following:

--8<---------------cut here---------------start------------->8---
(require 'allout)
(require 'allout-widgets)
(allout-init t)

(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.")

(defun srb-allout-font-lock-mode ()
  (font-lock-add-keywords nil srb-allout-font-lock-keywords))

(add-hook 'allout-mode-hook 'srb-allout-font-lock-mode)
--8<---------------cut here---------------end--------------->8---

Then I visited the test file and each instance of "test" had a different
color.  Can you try the same test?

Steve Berman




  reply	other threads:[~2012-03-07 20:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06 17:27 allout and font-locking Marc Croteau
2012-03-07 20:13 ` Stephen Berman [this message]
2012-03-07 20:52   ` Marc Croteau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8762eg5fvv.fsf@escher.home \
    --to=stephen.berman@gmx.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).