GNU bug report logs -
#635
Adding font-lock keywords results in no font-lock at all
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 635 in the body.
You can then email your comments to 635 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#635
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Klaus Zeitler <kzeitler <at> alcatel-lucent.com>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
For many years I had the following statement in my .emacs file:
(defun show-tabs () "Show tabs with a slightly changed background"
(font-lock-add-keywords nil '(("\t" (0 'tab-face t))) t))
(add-hook 'font-lock-mode-hook 'show-tabs)
This has worked without any problems up to 22.1.
In version 22.2 and 23 I do have problems with syntax highlighting due
to these few lines above in some modes, e.g. when I try M-x list-faces-display
all colors are gone.
To reproduce:
1. start "emacs -Q"
2. in scratch buffer evaluate
(defun show-tabs () "Show tabs with a slightly changed background"
(font-lock-add-keywords nil '(("\t" (0 'font-lock-constant-face t))) t))
(add-hook 'font-lock-mode-hook 'show-tabs)
3. M-x list-faces-display
=> everything's displayed in default face
In GNU Emacs 22.2.2 (sparc-sun-solaris2.8, Motif Version 2.1.0)
of 2008-04-09 on sfsws4
Windowing system distributor `Sun Microsystems, Inc.', version 11.0.6410
configured using `configure '--with-gcc' '--prefix=/vol/freeware/SunOS-5.8/emacs/22.2' '--sharedstatedir=/vol/freeware/SunOS-5.8/emacs/22.2/share' '--with-x-toolkit=motif' '--x-includes=/usr/openwin/include:/usr/local/gnu/include:/opt/exp/gnu/include:/opt/exp/include:/opt/exp/lib/xpm/include' '--x-libraries=/usr/openwin/lib:/usr/local/gnu/lib:/opt/exp/gnu/lib:/opt/exp/lib:/opt/exp/lib/xpm/lib' '--with-pop' 'CC=gcc' 'XMKMF=/usr/openwin/bin/xmkmf''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: C
locale-coding-system: nil
default-enable-multibyte-characters: t
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
tool-bar-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
unify-8859-on-encoding-mode: t
utf-translate-cjk-mode: t
auto-compression-mode: t
line-number-mode: t
Recent input:
<help-echo> <help-echo> <menu-bar> <help-menu> <se
nd-emacs-bug-report>
Recent messages:
("emacs" "-Q")
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#635
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
> For many years I had the following statement in my .emacs file:
>
> (defun show-tabs () "Show tabs with a slightly changed background"
> (font-lock-add-keywords nil '(("\t" (0 'tab-face t))) t))
> (add-hook 'font-lock-mode-hook 'show-tabs)
>
> This has worked without any problems up to 22.1.
> In version 22.2 and 23 I do have problems with syntax highlighting due
> to these few lines above in some modes, e.g. when I try M-x list-faces-display
> all colors are gone.
The behavior you observe seems due to the change
2007-06-11 Stefan Monnier <monnier <at> iro.umontreal.ca>
* font-lock.el (font-lock-add-keywords): In case font-lock was only
half-activated, forcefully activate it completely.
which added the following lines to `font-lock-add-keywords'
(when (and font-lock-mode
(not (or font-lock-keywords font-lock-defaults)))
;; The major mode has not set any keywords, so when we enabled
;; font-lock-mode it only enabled the font-core.el part, not the
;; font-lock-mode-internal. Try again.
(font-lock-mode -1)
(set (make-local-variable 'font-lock-defaults) '(nil t))
(font-lock-mode 1))
What happens appears to be that in any mode that does not specify
`font-lock-keywords' (like `help-mode' or `view-mode' in your case),
(font-lock-mode -1) unfontifies the entire buffer thus removing any
faces assigned earlier by, for example, `list-faces-display'. Since
these faces are not reassigned by font-lock you won't get them back
either :-(
AFAICT, this change also broke `hi-lock-mode' in such buffers.
Get your original behavior back by writing something like
(defun show-tabs () "Show tabs with a slightly changed background"
(unless (or font-lock-keywords font-lock-defaults)
(set (make-local-variable 'font-lock-defaults) '(nil t)))
(font-lock-add-keywords nil '(("\t" (0 'tab-face t))) t))
(add-hook 'font-lock-mode-hook 'show-tabs)
or by removing the offending lines from font-lock.el ;-(
martin
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#635
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#635
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
kzeitler <at> alcatel-lucent.com
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #20 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
>>>>> "martin" == martin rudalics <rudalics <at> gmx.at> writes:
martin>
martin> Get your original behavior back by writing something like
martin>
martin> (defun show-tabs () "Show tabs with a slightly changed background"
martin> (unless (or font-lock-keywords font-lock-defaults)
martin> (set (make-local-variable 'font-lock-defaults) '(nil t)))
martin> (font-lock-add-keywords nil '(("\t" (0 'tab-face t))) t))
martin> (add-hook 'font-lock-mode-hook 'show-tabs)
Yes, it works now again as expected.
martin> or by removing the offending lines from font-lock.el ;-(
I can live with your workaround till it's fixed :-).
Thanks a lot for your help.
Klaus
--
--------------------------------------------------
| Klaus Zeitler Alcatel-Lucent |
| Email: kzeitler <at> alcatel-lucent.com |
--------------------------------------------------
---
Biology is the only science in which multiplication
means the same thing as division.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#635
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
kzeitler <at> alcatel-lucent.com
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
bug closed, send any further explanations to Klaus Zeitler <kzeitler <at> alcatel-lucent.com>
Request was from
Chong Yidong <cyd <at> stupidchicken.com>
to
control <at> emacsbugs.donarmstrong.com
.
(Mon, 01 Sep 2008 20:20:03 GMT)
Full text and
rfc822 format available.
bug reopened, originator not changed.
Request was from
Chong Yidong <cyd <at> stupidchicken.com>
to
control <at> emacsbugs.donarmstrong.com
.
(Mon, 01 Sep 2008 20:20:05 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#635
; Package
emacs
.
(Thu, 13 Aug 2009 23:50:06 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Chong Yidong <cyd <at> stupidchicken.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 13 Aug 2009 23:50:06 GMT)
Full text and
rfc822 format available.
Message #34 received at 635 <at> emacsbugs.donarmstrong.com (full text, mbox):
> 2007-06-11 Stefan Monnier <monnier <at> iro.umontreal.ca>
> * font-lock.el (font-lock-add-keywords): In case font-lock was only
> half-activated, forcefully activate it completely.
>
> which added the following lines to `font-lock-add-keywords'
> (when (and font-lock-mode
> (not (or font-lock-keywords font-lock-defaults)))
> ;; The major mode has not set any keywords, so when we enabled
> ;; font-lock-mode it only enabled the font-core.el part, not the
> ;; font-lock-mode-internal. Try again.
> (font-lock-mode -1)
> (set (make-local-variable 'font-lock-defaults) '(nil t))
> (font-lock-mode 1))
>
> What happens appears to be that in any mode that does not specify
> `font-lock-keywords' (like `help-mode' or `view-mode' in your case),
> (font-lock-mode -1) unfontifies the entire buffer thus removing any
> faces assigned earlier by, for example, `list-faces-display'. Since
> these faces are not reassigned by font-lock you won't get them back
> either :-(
>
> AFAICT, this change also broke `hi-lock-mode' in such buffers.
Maybw we should do away with the optimization where font-lock-mode
avoids calling font-lock-internal when font-lock-defaults is empty. The
performance benefit is probably negligible.
Stefan, WDYT?
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#635
; Package
emacs
.
(Thu, 20 Aug 2009 20:37:44 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 20 Aug 2009 20:37:44 GMT)
Full text and
rfc822 format available.
Message #39 received at 635 <at> emacsbugs.donarmstrong.com (full text, mbox):
>>>>> "Chong" == Chong Yidong <cyd <at> stupidchicken.com> writes:
>> 2007-06-11 Stefan Monnier <monnier <at> iro.umontreal.ca>
>> * font-lock.el (font-lock-add-keywords): In case font-lock was only
>> half-activated, forcefully activate it completely.
>>
>> which added the following lines to `font-lock-add-keywords'
>> (when (and font-lock-mode
>> (not (or font-lock-keywords font-lock-defaults)))
>> ;; The major mode has not set any keywords, so when we enabled
>> ;; font-lock-mode it only enabled the font-core.el part, not the
>> ;; font-lock-mode-internal. Try again.
>> (font-lock-mode -1)
>> (set (make-local-variable 'font-lock-defaults) '(nil t))
>> (font-lock-mode 1))
>>
>> What happens appears to be that in any mode that does not specify
>> `font-lock-keywords' (like `help-mode' or `view-mode' in your case),
>> (font-lock-mode -1) unfontifies the entire buffer thus removing any
>> faces assigned earlier by, for example, `list-faces-display'. Since
>> these faces are not reassigned by font-lock you won't get them back
>> either :-(
>>
>> AFAICT, this change also broke `hi-lock-mode' in such buffers.
> Maybe we should do away with the optimization where font-lock-mode
> avoids calling font-lock-internal when font-lock-defaults is empty.
> The performance benefit is probably negligible.
Maybe that would work, although I'm a bit worried about turn it on in
buffers where font-lock doesn't belong.
E.g. list-faces-display shouldn't be combined with font-lock, IIUC (or
we'd have to change it to use font-lock-face first).
I don't know in which way hi-lock-mode was broken "in such buffers", so
it's hard to say more. Clearly the current situation is not very
satisfactory, with its many hacks, workarounds, and corner cases, but
I'm not sure this would improve the situation, really.
Stefan
Reply sent
to
Chong Yidong <cyd <at> stupidchicken.com>
:
You have taken responsibility.
(Sat, 09 Oct 2010 04:09:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Klaus Zeitler <kzeitler <at> alcatel-lucent.com>
:
bug acknowledged by developer.
(Sat, 09 Oct 2010 04:09:03 GMT)
Full text and
rfc822 format available.
Message #44 received at 635-done <at> debbugs.gnu.org (full text, mbox):
I've just checked in a patch by David Koppelman which should fix this:
http://lists.gnu.org/archive/html/emacs-devel/2010-10/msg00239.html
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 06 Nov 2010 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 225 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.