* font-lock and text mode
@ 2003-02-24 12:40 Oliver Scholz
2003-02-24 13:46 ` Kai Großjohann
2003-02-24 14:10 ` John Paul Wallington
0 siblings, 2 replies; 6+ messages in thread
From: Oliver Scholz @ 2003-02-24 12:40 UTC (permalink / raw)
I noticed that `hi-lock-mode' doesn't work properly in text mode (CVS
Emacs): after I have added a regexp with `C-x w h', matches already
in the buffer are highlighted, but matching text that I insert after
that is not.
Also it seems to be impossible to add highlighting via
font-lock-keywords to text mode.
(font-lock-add-keywords nil
'(("\\<lirum larum\\>" . font-lock-warning-face)))
I tried a lot to find the reason for this. Finally I tested whether
font-locking works with a derived mode of text-mode.
(defvar test-mode-font-lock-keywords
'(("lirum-larum" . font-lock-warning-face)))
(define-derived-mode test-mode text-mode
"FIXME"
(set (make-local-variable 'font-lock-defaults)
'(test-mode-font-lock-keywords t)))
This is fine. My guess was that this has something to do with the
implementation of `global-font-lock-mode', so I tried to call
`global-font-lock-mode-cmmh' manually, but to no avail. Looking at the
expansion of `define-derived-mode' above and experimenting with it, I
found that `kill-all-local-variables' is critical here. This is enough
to enable font-locking:
(progn (kill-all-local-variables)
(set (make-local-variable 'font-lock-defaults)
'((("\\<lirum-larum\\>" . font-lock-warning-face))
t)))
So I looked at the code of `kill-all-local-variables'. But I can't
find anything there relating to `font-lock' (except the hook
`change-major-modes', but calling `global-font-lock-mode-cmmh' should
amount to the same).
I am puzzled. What am I missing?
Oliver
--
6 Ventôse an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock and text mode
2003-02-24 12:40 font-lock and text mode Oliver Scholz
@ 2003-02-24 13:46 ` Kai Großjohann
2003-02-24 15:19 ` Oliver Scholz
2003-02-24 14:10 ` John Paul Wallington
1 sibling, 1 reply; 6+ messages in thread
From: Kai Großjohann @ 2003-02-24 13:46 UTC (permalink / raw)
Oliver Scholz <alkibiades@gmx.de> writes:
> I noticed that `hi-lock-mode' doesn't work properly in text mode (CVS
> Emacs): after I have added a regexp with `C-x w h', matches already
> in the buffer are highlighted, but matching text that I insert after
> that is not.
I think it works as intended.
> Also it seems to be impossible to add highlighting via
> font-lock-keywords to text mode.
>
> (font-lock-add-keywords nil
> '(("\\<lirum larum\\>" . font-lock-warning-face)))
>
> I tried a lot to find the reason for this.
I think the deeper reason is that text-mode has no font-lock support.
Maybe it is easiest to just use your derived mode.
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock and text mode
2003-02-24 12:40 font-lock and text mode Oliver Scholz
2003-02-24 13:46 ` Kai Großjohann
@ 2003-02-24 14:10 ` John Paul Wallington
2003-02-24 15:21 ` Oliver Scholz
1 sibling, 1 reply; 6+ messages in thread
From: John Paul Wallington @ 2003-02-24 14:10 UTC (permalink / raw)
Oliver Scholz <alkibiades@gmx.de> wrote:
> Also it seems to be impossible to add highlighting via
> font-lock-keywords to text mode.
>
> (font-lock-add-keywords nil
> '(("\\<lirum larum\\>" . font-lock-warning-face)))
Does M-g M-g fontify it ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock and text mode
2003-02-24 13:46 ` Kai Großjohann
@ 2003-02-24 15:19 ` Oliver Scholz
2003-02-24 17:21 ` Kai Großjohann
0 siblings, 1 reply; 6+ messages in thread
From: Oliver Scholz @ 2003-02-24 15:19 UTC (permalink / raw)
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> Oliver Scholz <alkibiades@gmx.de> writes:
>
>> I noticed that `hi-lock-mode' doesn't work properly in text mode (CVS
>> Emacs): after I have added a regexp with `C-x w h', matches already
>> in the buffer are highlighted, but matching text that I insert after
>> that is not.
>
> I think it works as intended.
I don't know for sure, of course, but I don't think
so. `highlight-regexp' adds to `font-lock-keywords'. So in every mode
that comes with font-lock support, text that matches the regexp is
highlighted even if it was typed _after_ defining the regexp. For
example in `lisp-interaction-mode':
emacs -q --no-site-file
M-x hi-lock-mode RET
C-x w h hello RET RET
hello
But:
C-x b *tmp* RET
M-x text-mode RET
C-x w h hello RET RET
hello
>> Also it seems to be impossible to add highlighting via
>> font-lock-keywords to text mode.
>>
>> (font-lock-add-keywords nil
>> '(("\\<lirum larum\\>" . font-lock-warning-face)))
>>
>> I tried a lot to find the reason for this.
>
> I think the deeper reason is that text-mode has no font-lock support.
Yes, but how do I add it "manually"? (I mean: without modifying
text-mode itself.)
> Maybe it is easiest to just use your derived mode.
Well, actually I think this is a bug in `hi-lock-mode' and I want to
fix it.
And even if there is an easy workaround, I'd like to understand the
deeper mysteries of the Mighty Font Lock.
Oliver
--
6 Ventôse an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock and text mode
2003-02-24 14:10 ` John Paul Wallington
@ 2003-02-24 15:21 ` Oliver Scholz
0 siblings, 0 replies; 6+ messages in thread
From: Oliver Scholz @ 2003-02-24 15:21 UTC (permalink / raw)
John Paul Wallington <jpw@gnu.org> writes:
> Oliver Scholz <alkibiades@gmx.de> wrote:
>
>> Also it seems to be impossible to add highlighting via
>> font-lock-keywords to text mode.
>>
>> (font-lock-add-keywords nil
>> '(("\\<lirum larum\\>" . font-lock-warning-face)))
>
> Does M-g M-g fontify it ?
Yes, and so does M-x font-lock-fontify-buffer.
Oliver
--
6 Ventôse an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock and text mode
2003-02-24 15:19 ` Oliver Scholz
@ 2003-02-24 17:21 ` Kai Großjohann
0 siblings, 0 replies; 6+ messages in thread
From: Kai Großjohann @ 2003-02-24 17:21 UTC (permalink / raw)
Oliver Scholz <alkibiades@gmx.de> writes:
> I don't know for sure, of course, but I don't think
> so. `highlight-regexp' adds to `font-lock-keywords'.
Ah. You're right.
So maybe the problem really is that text-mode doesn't normally
support font-lock. (I think.)
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-02-24 17:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-24 12:40 font-lock and text mode Oliver Scholz
2003-02-24 13:46 ` Kai Großjohann
2003-02-24 15:19 ` Oliver Scholz
2003-02-24 17:21 ` Kai Großjohann
2003-02-24 14:10 ` John Paul Wallington
2003-02-24 15:21 ` Oliver Scholz
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.