unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 56637@debbugs.gnu.org, monnier@iro.umontreal.ca
Subject: bug#56637: 28.1.90; [FR] Allow a way around font-lock-mode being unconditionally disabled in " *hidden*" buffers
Date: Thu, 21 Jul 2022 21:18:34 +0800	[thread overview]
Message-ID: <87o7xi1u51.fsf@localhost> (raw)
In-Reply-To: <83tu7amxzx.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> If fontification is done in temporary throwaway buffers that are closed
>> immediately after fontification, next portion of text that should be
>> fontified in the same major mode will need to create a new throwaway
>> buffer, turn on the relevant major mode, and perform fontification.
>> Hence, major mode will need to be loaded every single time we need to
>> fontify a text fragment.
>
> It is not "loaded", it is "activated".  "Loading" in Emacs means
> loading the Lisp package that implements the mode, and that is done
> only once.  We don't unload packages when buffers are killed.

Thanks for the clarification.

>> > And why do you assume that erasing a buffer and then inserting some
>> > text into it will be significantly faster than turning on a mode in
>> > it?  It sounds like another fragile assumption.
>> 
>> It is usually true from my experience.
>
> Well, "usually" is not a guarantee it will always be so.

We do not need such a guarantee. The choice between temporary throwaway
buffers and single major-mode buffer where we insert/remove text is
about speed. Even if reusing the buffer is faster in 90% of major modes
and not 100%, it is a big improvement.

> Anyway, if this is the issue, we could add another way of marking a
> buffer as "invisible for user", one that is not based on the buffer's
> name.
>
>> (5.531764251 0 0.0)
>> (0.012424528 0 0.0)
>> 
>> Over 400x difference.
>
> Sorry, but this proves nothing, and I'm sure you know it.

It was an _illustration_. The decision to reuse buffer was not
arbitrary. Org mode developers and users tested the throwaway buffer
approach, found it too slow and changed to reusing a single major-mode
buffer. The latter is faster in practice.

> To me, this is just one more fragile assumption on which Org code is
> based that is bound to be broken some day.

It is a heuristic. If it is broken, nothing terrible will happen.
Fontification will still work, albeit slower. If the slowdown will be
reported widely, we can always change to the alternative approach.

Also, I am not sure why you are making such a strong claim about "that
is bound to be broken some day". Throwaway buffer will require (1)
creating buffer; (2) activating major-mode; (3) fontification. Reusable
buffer will require (1) Handling major mode's
before/after-change-functions; (2) fontification.

Before/after-change-functions are fast. If not, the relevant major mode
is a terrible mode anyway and should not be used. There is no such
pressure to optimize the activation time, in comparison.

Best,
Ihor





  reply	other threads:[~2022-07-21 13:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19  4:15 bug#56637: 28.1.90; [FR] Allow a way around font-lock-mode being unconditionally disabled in " *hidden*" buffers Ihor Radchenko
2022-07-19 12:55 ` Eli Zaretskii
2022-07-20  4:13   ` Ihor Radchenko
2022-07-20 11:32     ` Eli Zaretskii
2022-07-21 12:09       ` Ihor Radchenko
2022-07-21 12:26         ` Eli Zaretskii
2022-07-21 12:44           ` Ihor Radchenko
2022-07-21 12:49             ` Eli Zaretskii
2022-07-21 13:18               ` Ihor Radchenko [this message]
2022-07-21 15:13         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-24  6:40           ` Ihor Radchenko
2022-07-19 16:13 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 16:36   ` Eli Zaretskii
2022-07-19 17:01     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 18:05       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 19:02       ` Eli Zaretskii
2022-07-19 19:21         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 19:32           ` Eli Zaretskii
2022-07-19 21:12             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 11:12               ` Eli Zaretskii
2022-07-20 15:15                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 16:09                   ` Eli Zaretskii
2022-07-20 19:15                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20  4:15   ` Ihor Radchenko
2022-07-20 14:58     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-21 12:11       ` Ihor Radchenko
2022-07-21 18:39         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-24  6:47           ` Ihor Radchenko
2022-07-24 14:25             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-25  9:23               ` Ihor Radchenko
2022-07-25 15:56                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-26  5:21                   ` Ihor Radchenko
2022-07-23  7:53       ` Lars Ingebrigtsen
2022-07-23  8:55         ` Eli Zaretskii
2022-07-23 13:46         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=87o7xi1u51.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=56637@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).