all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: 9919@debbugs.gnu.org
Subject: bug#9919: 24.0.91; font-lock broken in dired
Date: Mon, 09 Jan 2012 17:36:51 -0500	[thread overview]
Message-ID: <jwv8vlgpl7x.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <7F9343C4FA564C29BE7E8576E5A25183@us.oracle.com> (Drew Adams's message of "Mon, 9 Jan 2012 10:59:58 -0800")

>> > I am still getting reports about this wrt dired+.el from users on
>> > GNU/Linux.  So perhaps my workaround is not sufficient there - dunno.
>> Whenever you change font-lock-defaults, you need to cause
>> font-lock-keywords (and the text already font-locked) to be refreshed,
>> unless you know for sure that font-lock-mode has not yet been started.
> Your "whenever" obviously does not apply to Emacs 20-22, since
> `font-lock-refresh-defaults' does not even exist in those releases.

It does: notice I don't mention font-lock-refresh-defaults which merely
makes it easy (it was introduced just to make it easier to solve this
problem).

> And at least for my code, "whenever" is true only for Emacs 24, not
> Emacs 23 (which also has `font-lock-refresh-defaults').  And the
> problem did not exist in Emacs 24 either, until the build where
> I reported the bug.

No, your code was wrong and always has been: you change
only font-lock-defaults, whereas you do not know for a fact that
font-lock-mode has not yet been enabled.
In earlier Emacsen, in normal circumstances, you just got lucky.

> I have this code, which has always worked and still works with Emacs
> 20 through 23.3:

Code that works in practice doesn't mean correct code.

> (add-hook
>   'dired-mode-hook
>   (lambda ()
>     (set (make-local-variable 'font-lock-defaults)
>          (cons '(dired-font-lock-keywords diredp-font-lock-keywords-1)
>                (cdr font-lock-defaults)))

Great.  Now after running the above code, the user adds

  (add-hook 'dired-mode-hook (lambda () (font-lock-mode 1)))

and suddenly the bug shows up even in Emacs-23.

>> I don't see any evidence of a performance problem.
> This means, in effect, that fontification must now be done twice, or
> else it is incorrect.  That's the performance hit I meant:
> font-locking twice.

Evidence of a performance problem requires measures, times, things
like that.  You're talking about some hypothetical problem based on your
understanding of how things work.  Things don't always work the way we
think they do.  We have plenty of hypothetical performance problems in
Emacs that I'm not going to worry about them.

> What's the cause of this change/regression?

Nothing very deep.  The moment when font-lock-mode gets enabled
has changed.  I'm not convinced the new time is really much better, but
I'm not convinced the old time was better either.  Basically it used to
be enabled after running the mode hook, which made it
difficult to disable font-lock-mode via a mode-hook check, wherea now it
gets enabled before, so you can just do

  (add-hook 'dired-mode-hook (lambda () (if foo (font-lock-mode -1))))


-- Stefan





  reply	other threads:[~2012-01-09 22:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-31 15:11 bug#9919: 24.0.91; font-lock broken in dired Drew Adams
2011-10-31 22:06 ` Drew Adams
2011-10-31 22:29   ` Drew Adams
2011-11-05  1:34 ` Christoph Scholtes
2011-11-05 15:30   ` Drew Adams
2012-01-09 15:52     ` Drew Adams
2012-01-09 17:04       ` Stefan Monnier
2012-01-09 18:59         ` Drew Adams
2012-01-09 22:36           ` Stefan Monnier [this message]
2012-01-10  0:04             ` Drew Adams
2012-01-10  1:26               ` Stefan Monnier
2012-01-10  1:35                 ` Drew Adams
2012-01-10  3: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

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

  git send-email \
    --in-reply-to=jwv8vlgpl7x.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=9919@debbugs.gnu.org \
    --cc=drew.adams@oracle.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.