unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* allout and font-locking
@ 2012-03-06 17:27 Marc Croteau
  2012-03-07 20:13 ` Stephen Berman
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Croteau @ 2012-03-06 17:27 UTC (permalink / raw)
  To: help-gnu-emacs

Hello folks. 
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.

I created a simple file (allout-test.txt), based on the emacswiki
============ 
* test
.. test
   test
. , test
    test
.  . test
.   , test
.    . test
       test
.     , test
.      . test
.       , test

* file local variables list
Local variables:
allout-layout: (+ :)
mode: allout
End:
================
and, while the outline/allout keys work as expected, I don't have any
colors.

I have the following in my init.el file
(require 'allout)
(require 'allout-widgets)
(allout-init t)

Toggling (global-font-lock) does not change anything.

Note that fontification is happening in other files I edit.

Any help would be greatly appreciated.
Thank you in advance
Marc



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: allout and font-locking
  2012-03-06 17:27 allout and font-locking Marc Croteau
@ 2012-03-07 20:13 ` Stephen Berman
  2012-03-07 20:52   ` Marc Croteau
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Berman @ 2012-03-07 20:13 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: allout and font-locking
  2012-03-07 20:13 ` Stephen Berman
@ 2012-03-07 20:52   ` Marc Croteau
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Croteau @ 2012-03-07 20:52 UTC (permalink / raw)
  To: Stephen Berman; +Cc: help-gnu-emacs

Hi Stephen,
As you suggested, the color highlights came through.
My mistake was that in tracking down the code suggestions various people
had made, I put your code in but did not add the very necessary code:
(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)
to my .init file.
Once again,
Thanks a bunch and sorry to have wasted your time.
Regards,
Marc

> 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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-07 20:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-06 17:27 allout and font-locking Marc Croteau
2012-03-07 20:13 ` Stephen Berman
2012-03-07 20:52   ` Marc Croteau

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