unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Klaus Zeitler <kzeitler@alcatel-lucent.com>,
	635@emacsbugs.donarmstrong.com
Cc: bug-gnu-emacs@gnu.org
Subject: bug#635: Adding font-lock keywords results in no font-lock at all
Date: Tue, 05 Aug 2008 15:12:46 +0200	[thread overview]
Message-ID: <489851CE.1030105@gmx.at> (raw)
In-Reply-To: <200808010621.m716LUC22179@sfsw51.de.lucent.com>

 > 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@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







  reply	other threads:[~2008-08-05 13:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-01  6:21 bug#635: Adding font-lock keywords results in no font-lock at all Klaus Zeitler
2008-08-05 13:12 ` martin rudalics [this message]
2008-08-12  6:43   ` Klaus Zeitler
2010-10-09  4:11 ` Chong Yidong
  -- strict thread matches above, loose matches on Subject: below --
2009-08-13 23:41 Chong Yidong
2009-08-19  0:14 ` Stefan Monnier

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=489851CE.1030105@gmx.at \
    --to=rudalics@gmx.at \
    --cc=635@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=kzeitler@alcatel-lucent.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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