* Font-Locking for Allout Mode @ 2007-03-07 20:07 Tassilo Horn 2007-03-08 13:23 ` Stephen Berman [not found] ` <mailman.654.1173360249.7795.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 18+ messages in thread From: Tassilo Horn @ 2007-03-07 20:07 UTC (permalink / raw) To: help-gnu-emacs Hello, I'm a new user of allout-mode and I really like it. The only thing that has to be improved is the readability of the headings. I would like to use font locking to adjust the faces like the AUCTeX sectioning faces. On EmacsWiki [1] I found some snippets for doing that, although the first one seems to be outline-mode specific. So I adapted it for allout mode and came up with this: ,----[ ~/.emacs ] | (defvar th-allout-font-lock-keywords | '(;; Highlight headings according to the level. | (eval . (list (concat "^\\(" allout-regexp "\\).+") | 0 '(or (cdr (assq (allout-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 Allout mode.") | | (defun th-font-lock-allout () | (interactive) | (font-lock-add-keywords nil th-allout-font-lock-keywords)) | | (add-hook 'allout-mode-hook | 'th-font-lock-allout) `---- But it seems to have no effect. The regexp from above is "^\\(\\(;;;_[ ]*[\\.,\\*\\+--=>()\\[{}&!\\?#%\"X@\\$~_\\\\:;\\^;;;_]\\)\\|\\(;;;_\\|;;;_\\)+ ?[^;;;_]\\|\f\\).+" It is for allout mode in a emacs lisp buffer. If I enter it in `re-builder' it matches the allout topic headings just fine. Can anyone see what's wrong with the code? Thanks in advance, Tassilo Footnotes: [1] http://www.emacswiki.org/cgi-bin/wiki/AllOut -- The glass is neither half-full nor half-empty: it's twice as big as it needs to be. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-07 20:07 Font-Locking for Allout Mode Tassilo Horn @ 2007-03-08 13:23 ` Stephen Berman [not found] ` <mailman.654.1173360249.7795.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-08 13:23 UTC (permalink / raw) To: help-gnu-emacs On Wed, 07 Mar 2007 21:07:24 +0100 Tassilo Horn <tassilo@member.fsf.org> wrote: > I'm a new user of allout-mode and I really like it. The only thing that > has to be improved is the readability of the headings. I would like to > use font locking to adjust the faces like the AUCTeX sectioning faces. > > On EmacsWiki [1] I found some snippets for doing that, although the > first one seems to be outline-mode specific. So I adapted it for allout > mode and came up with this: [...] > But it seems to have no effect. [...] It works for me. However, I found that I have to add `mode: allout' to the Local Variables section in order for the fontification to be seen upon visiting the file. If allout-mode isn't specified as a file local variable, then calling font-lock-fontify-buffer makes the fontification show up. I don't know if this indicates a bug in that code. Steve Berman ^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <mailman.654.1173360249.7795.help-gnu-emacs@gnu.org>]
* Re: Font-Locking for Allout Mode [not found] ` <mailman.654.1173360249.7795.help-gnu-emacs@gnu.org> @ 2007-03-08 14:03 ` Tassilo Horn 2007-03-08 16:06 ` Stephen Berman [not found] ` <mailman.663.1173370034.7795.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 18+ messages in thread From: Tassilo Horn @ 2007-03-08 14:03 UTC (permalink / raw) To: help-gnu-emacs Stephen Berman <Stephen.Berman@gmx.net> writes: Hi Stephen, > It works for me. Strange. > However, I found that I have to add `mode: allout' to the Local > Variables section in order for the fontification to be seen upon > visiting the file. My local variable section looks like ,----[ ~/.emacs ] | ;;Local variables: | ;;allout-layout: 0 | ;;End: `---- If I add ";;mode: allout" the allout-layout won't be applied -- nothing is collapsed/narrowed. And fontification of the headings isn't applied, too. > If allout-mode isn't specified as a file local variable, then calling > font-lock-fontify-buffer makes the fontification show up. Has no effect here. The fontification is still emacs lisp, but the special allout headings are still fontified as normal comments. > 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? And could you test my snippet with your emacs? BTW, what version do you use? It's 22.0.95 here, maybe it's a version specific thing... Bye, Tassilo -- * delYsid has mortgage, opportunity and penis in his score file. <delYsid> thats pretty effective against spam <Luke> aren't you worried about missing opportunities to mortgage your penis? ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-08 14:03 ` Tassilo Horn @ 2007-03-08 16:06 ` Stephen Berman [not found] ` <mailman.663.1173370034.7795.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-08 16:06 UTC (permalink / raw) To: help-gnu-emacs On Thu, 08 Mar 2007 15:03:50 +0100 Tassilo Horn <tassilo@member.fsf.org> wrote: > My local variable section looks like > > ,----[ ~/.emacs ] > | ;;Local variables: > | ;;allout-layout: 0 > | ;;End: > `---- > > If I add ";;mode: allout" the allout-layout won't be applied -- nothing > is collapsed/narrowed. And fontification of the headings isn't applied, > too. > >> If allout-mode isn't specified as a file local variable, then calling >> font-lock-fontify-buffer makes the fontification show up. > > Has no effect here. The fontification is still emacs lisp, but the > special allout headings are still fontified as normal comments. You cannot see the fontified allout headings in emacs lisp mode because the emacs lisp comment fontification overrides it. If you use allout with a text-mode file, then you'll see the fontification. 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 `;;;_'. >> 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. > And could you test my snippet with your emacs? BTW, what version do you > use? It's 22.0.95 here, maybe it's a version specific thing... I'm using CVS Emacs 22.0.93.1 (i686-pc-linux-gnu, GTK+ Version 2.10.6) of 2007-02-08. 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? Steve Berman ^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <mailman.663.1173370034.7795.help-gnu-emacs@gnu.org>]
* Re: Font-Locking for Allout Mode [not found] ` <mailman.663.1173370034.7795.help-gnu-emacs@gnu.org> @ 2007-03-08 16:42 ` Tassilo Horn 2007-03-08 22:38 ` Peter Dyballa ` (3 more replies) 0 siblings, 4 replies; 18+ messages in thread From: Tassilo Horn @ 2007-03-08 16:42 UTC (permalink / raw) To: help-gnu-emacs Stephen Berman <Stephen.Berman@gmx.net> 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. Bye, Tassilo -- 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. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-08 16:42 ` Tassilo Horn @ 2007-03-08 22:38 ` Peter Dyballa 2007-03-08 22:45 ` Stephen Berman ` (2 subsequent siblings) 3 siblings, 0 replies; 18+ messages in thread From: Peter Dyballa @ 2007-03-08 22:38 UTC (permalink / raw) To: Tassilo Horn; +Cc: help-gnu-emacs Am 08.03.2007 um 17:42 schrieb Tassilo Horn: > ;;; -*- mode: text -*- -*-coding: utf-8 -*- You can simplify this as: ;; -*- mode: text; coding: utf-8; -*- I think the final ``;´´ is needed. -- Greetings Pete This is a signature virus. Add me to your signature and help me to live ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-08 16:42 ` Tassilo Horn 2007-03-08 22:38 ` Peter Dyballa @ 2007-03-08 22:45 ` Stephen Berman [not found] ` <mailman.686.1173393546.7795.help-gnu-emacs@gnu.org> [not found] ` <mailman.687.1173393945.7795.help-gnu-emacs@gnu.org> 3 siblings, 0 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-08 22:45 UTC (permalink / raw) To: help-gnu-emacs On Thu, 08 Mar 2007 17:42:18 +0100 Tassilo Horn <tassilo@member.fsf.org> wrote: > Stephen Berman <Stephen.Berman@gmx.net> writes: > >> 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. I forgot about this possibility. I guess I really have no idea then; hopefully someone who understands font-locking well will chime in. >> 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 meant you should add the file local variable `mode: allout' to a file you are visiting in the major mode Text Mode. However, if the file you are visiting in Text Mode is ~/.emacs, presumably your allout headings beginning with `;;;_' and if so, they won't match allout-regexp for Text Mode, so won't get fontified. 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: >> 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'. > | ^^^^^^^^^^^^^^^ > `---- I also get "2.2.1" for allout-version. But I did not mean that I need to use "mode: allout" to get hiding, navigation, etc. in allout-mode to work, but only that I need it to get fontification upon visiting a suitable file using the code adapted from the Emacs Wiki. That's why I speculated that that code may be buggy, since indeed, you don't normally need to have the file local variable "mode: allout". >> 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. In my allout.el (2.2.1) the docstring of allout-init ends: "To prime your Emacs session for full auto-outline operation, include the following two lines in your Emacs init file: (require 'allout) (allout-init t)" Since you have it in yours, I'm at a loss to explain the different behaviors you and I are observing. Steve Berman ^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <mailman.686.1173393546.7795.help-gnu-emacs@gnu.org>]
* Re: Font-Locking for Allout Mode [not found] ` <mailman.686.1173393546.7795.help-gnu-emacs@gnu.org> @ 2007-03-08 22:49 ` Tassilo Horn 0 siblings, 0 replies; 18+ messages in thread From: Tassilo Horn @ 2007-03-08 22:49 UTC (permalink / raw) To: help-gnu-emacs Peter Dyballa <Peter_Dyballa@Web.DE> writes: Hi Peter, >> ;;; -*- mode: text -*- -*-coding: utf-8 -*- > > You can simplify this as: > > ;; -*- mode: text; coding: utf-8; -*- > > I think the final ``;´´ is needed. Thanks. I've fixed that, but it doesn't change anything. No fontification at all and the contents are not outlined, although allout mode is activated. But I guess that's because allout uses different allout indicatrors, not the ";;;_"-Lisp ones. Bye, Tassilo -- "DRM manages rights in the same way a jail manages freedom" ^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <mailman.687.1173393945.7795.help-gnu-emacs@gnu.org>]
* Re: Font-Locking for Allout Mode [not found] ` <mailman.687.1173393945.7795.help-gnu-emacs@gnu.org> @ 2007-03-08 23:18 ` Tassilo Horn 2007-03-09 11:28 ` Stephen Berman [not found] ` <mailman.704.1173439750.7795.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 18+ messages in thread From: Tassilo Horn @ 2007-03-08 23:18 UTC (permalink / raw) To: help-gnu-emacs Stephen Berman <Stephen.Berman@gmx.net> writes: Hi Stephen, > I meant you should add the file local variable `mode: allout' to a > file you are visiting in the major mode Text Mode. However, if the > file you are visiting in Text Mode is ~/.emacs, presumably your allout > headings beginning with `;;;_' and if so, they won't match > allout-regexp for Text Mode, so won't get fontified. Indeed, I forgot about the different regexps. :) > 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"... > In my allout.el (2.2.1) the docstring of allout-init ends: > > "To prime your Emacs session for full auto-outline operation, include > the following two lines in your Emacs init file: > > (require 'allout) > (allout-init t)" > > Since you have it in yours, I'm at a loss to explain the different > behaviors you and I are observing. Does fontification work for you in elisp files? Bye, Tassilo -- 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. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-08 23:18 ` Tassilo Horn @ 2007-03-09 11:28 ` Stephen Berman [not found] ` <mailman.704.1173439750.7795.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-09 11:28 UTC (permalink / raw) To: help-gnu-emacs 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <mailman.704.1173439750.7795.help-gnu-emacs@gnu.org>]
* Re: Font-Locking for Allout Mode [not found] ` <mailman.704.1173439750.7795.help-gnu-emacs@gnu.org> @ 2007-03-09 14:27 ` Tassilo Horn 2007-03-09 16:50 ` Stephen Berman 2007-03-09 20:36 ` Stefan Monnier 1 sibling, 1 reply; 18+ messages in thread From: Tassilo Horn @ 2007-03-09 14:27 UTC (permalink / raw) To: help-gnu-emacs Stephen Berman <Stephen.Berman@gmx.net> writes: Hi Stephen, > 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.") Yes, now it works. But I get a lot of the messages below in *Messages*: ,---- | Invalid face reference: 2 | Invalid face reference: 1 [9 times] | Invalid face reference: 2 [2 times] `---- > I still don't understand why the other version doesn't work with Emacs > lisp mode while the above does. I don't, too. > 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. I can confirm this behavior. > So there are still some problems with the code, but we've made > progress. :-) Indeed. Thanks a lot. Bye, Tassilo ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-09 14:27 ` Tassilo Horn @ 2007-03-09 16:50 ` Stephen Berman 2007-03-11 15:07 ` Stephen Berman 0 siblings, 1 reply; 18+ messages in thread From: Stephen Berman @ 2007-03-09 16:50 UTC (permalink / raw) To: help-gnu-emacs On Fri, 09 Mar 2007 15:27:13 +0100 Tassilo Horn <tassilo@member.fsf.org> wrote: > Stephen Berman <Stephen.Berman@gmx.net> writes: > > Hi Stephen, > >> 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: [...] > Yes, now it works. But I get a lot of the messages below in *Messages*: > > ,---- > | Invalid face reference: 2 > | Invalid face reference: 1 [9 times] > | Invalid face reference: 2 [2 times] > `---- I didn't notice them before, but I get them too. The message comes from merge_face_ref in xfaces.c, and a comment there says: "FACE_REF ought to be a face name." This apparently means that the face specification I gave is flawed, although the results look ok. But I'm afraid I'm out of my depth here. If we're lucky some font-lock guru will notice this thread and help us. Steve Berman ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-09 16:50 ` Stephen Berman @ 2007-03-11 15:07 ` Stephen Berman 0 siblings, 0 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-11 15:07 UTC (permalink / raw) To: help-gnu-emacs On Fri, 09 Mar 2007 17:50:52 +0100 Stephen Berman <Stephen.Berman@gmx.net> wrote: > On Fri, 09 Mar 2007 15:27:13 +0100 Tassilo Horn > <tassilo@member.fsf.org> wrote: > >> Stephen Berman <Stephen.Berman@gmx.net> writes: >> >> Hi Stephen, >> >>> 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: > [...] >> Yes, now it works. But I get a lot of the messages below in *Messages*: >> >> ,---- >> | Invalid face reference: 2 >> | Invalid face reference: 1 [9 times] >> | Invalid face reference: 2 [2 times] >> `---- > > I didn't notice them before, but I get them too. The message comes > from merge_face_ref in xfaces.c, and a comment there says: "FACE_REF > ought to be a face name." This apparently means that the face > specification I gave is flawed, although the results look ok. But I'm > afraid I'm out of my depth here. If we're lucky some font-lock guru > will notice this thread and help us. Font-Lock guru Stefan Monnier's post provided the necessary help, though my first attempt to make use of it was wrong. But the following works and uses valid face references: (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.") Steve Berman ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode [not found] ` <mailman.704.1173439750.7795.help-gnu-emacs@gnu.org> 2007-03-09 14:27 ` Tassilo Horn @ 2007-03-09 20:36 ` Stefan Monnier 2007-03-09 21:44 ` Tassilo Horn 2007-03-09 23:34 ` Stephen Berman 1 sibling, 2 replies; 18+ messages in thread From: Stefan Monnier @ 2007-03-09 20:36 UTC (permalink / raw) To: help-gnu-emacs > (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? Stefan ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-09 20:36 ` Stefan Monnier @ 2007-03-09 21:44 ` Tassilo Horn 2007-03-09 23:34 ` Stephen Berman 1 sibling, 0 replies; 18+ messages in thread From: Tassilo Horn @ 2007-03-09 21:44 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier <monnier@iro.umontreal.ca> writes: Hi Stefan, >> (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? What, the "ctio"? I think I don't get you right. The purpose is to fontify allout headings with different faces according to the depth of the topic. Bye, Tassilo ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-09 20:36 ` Stefan Monnier 2007-03-09 21:44 ` Tassilo Horn @ 2007-03-09 23:34 ` Stephen Berman 2007-03-09 23:47 ` Stephen Berman 2007-03-11 15:07 ` Stephen Berman 1 sibling, 2 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-09 23:34 UTC (permalink / raw) To: help-gnu-emacs 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-09 23:34 ` Stephen Berman @ 2007-03-09 23:47 ` Stephen Berman 2007-03-11 15:07 ` Stephen Berman 1 sibling, 0 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-09 23:47 UTC (permalink / raw) To: help-gnu-emacs On Sat, 10 Mar 2007 00:34:26 +0100 Stephen Berman <Stephen.Berman@gmx.net> wrote: Copy-n-paste error, should be this: (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.") Steve Berman ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Font-Locking for Allout Mode 2007-03-09 23:34 ` Stephen Berman 2007-03-09 23:47 ` Stephen Berman @ 2007-03-11 15:07 ` Stephen Berman 1 sibling, 0 replies; 18+ messages in thread From: Stephen Berman @ 2007-03-11 15:07 UTC (permalink / raw) To: help-gnu-emacs On Sat, 10 Mar 2007 00:34:26 +0100 Stephen Berman <Stephen.Berman@gmx.net> wrote: > The proper adaptation should be the following, right? Wrong, but how about this? (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.") Steve Berman ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2007-03-11 15:07 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-03-07 20:07 Font-Locking for Allout Mode Tassilo Horn 2007-03-08 13:23 ` Stephen Berman [not found] ` <mailman.654.1173360249.7795.help-gnu-emacs@gnu.org> 2007-03-08 14:03 ` Tassilo Horn 2007-03-08 16:06 ` Stephen Berman [not found] ` <mailman.663.1173370034.7795.help-gnu-emacs@gnu.org> 2007-03-08 16:42 ` Tassilo Horn 2007-03-08 22:38 ` Peter Dyballa 2007-03-08 22:45 ` Stephen Berman [not found] ` <mailman.686.1173393546.7795.help-gnu-emacs@gnu.org> 2007-03-08 22:49 ` Tassilo Horn [not found] ` <mailman.687.1173393945.7795.help-gnu-emacs@gnu.org> 2007-03-08 23:18 ` Tassilo Horn 2007-03-09 11:28 ` Stephen Berman [not found] ` <mailman.704.1173439750.7795.help-gnu-emacs@gnu.org> 2007-03-09 14:27 ` Tassilo Horn 2007-03-09 16:50 ` Stephen Berman 2007-03-11 15:07 ` Stephen Berman 2007-03-09 20:36 ` Stefan Monnier 2007-03-09 21:44 ` Tassilo Horn 2007-03-09 23:34 ` Stephen Berman 2007-03-09 23:47 ` Stephen Berman 2007-03-11 15:07 ` Stephen Berman
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.