all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: 635@emacsbugs.donarmstrong.com
Subject: bug#635: Adding font-lock keywords results in no font-lock at all
Date: Tue, 18 Aug 2009 20:14:53 -0400	[thread overview]
Message-ID: <jwvab21g9js.fsf-monnier+emacsbugreports@gnu.org> (raw)
In-Reply-To: <87bpmjnux1.fsf@cyd.mit.edu> (Chong Yidong's message of "Thu, 13 Aug 2009 19:41:46 -0400")

>>>>> "Chong" == Chong Yidong <cyd@stupidchicken.com> writes:

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

> 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	other threads:[~2009-08-19  0:14 UTC|newest]

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

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvab21g9js.fsf-monnier+emacsbugreports@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=635@emacsbugs.donarmstrong.com \
    --cc=cyd@stupidchicken.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 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.