From: Ihor Radchenko <yantar92@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 51766@debbugs.gnu.org
Subject: bug#51766: 29.0.50; Return value of buffer-chars-modified-tick changes when buffer text is not yet changed before inserting a character for non-latin input methods
Date: Fri, 12 Nov 2021 21:39:54 +0800 [thread overview]
Message-ID: <87wnldpk5x.fsf@localhost> (raw)
In-Reply-To: <831r3lzfk4.fsf@gnu.org>
Eli Zaretskii <eliz@gnu.org> writes:
>> quail changes the buffer after org-element--after-change-function call,
>> but before org-element--before-change-function. So, all Org can see is
>> that something has been changed in buffer, but there is no way to tell
>> what it was. Org cannot distinguish between harmless buffer edits by
>> quail (they do not change buffer text) and other kinds of "silent"
>> changes.
>
> OK, but why does this invalidate what Org does? All it means, AFAIU,
> is that in some cases Org will do unnecessary processing. Those cases
> are probably not too frequent.
Normally, buffer changes under inhibit-modification-hooks are not
frequent indeed. But not with quail + non-latin input methods. Every
single self-insert-command triggers such change.
> IOW, why invalidating the cache unnecessarily is such a big deal?
It is critical for Org to know which part of buffer was changed (i.e.
beg, end, length that are normally passed as arguments of
after-change-functions). org-element-cache can contain >100k elements
for especially large buffers. Manually checking which elements are
changed without knowing the changed region is inefficient. Clearing the
cache is not too much of a big deal, but causes slowdown when user runs
a query on Org buffers (i.e. in agenda or sparse trees) - the buffer has
to be re-parsed. When every edit triggers cache invalidation (that's
what happens when user uses non-latin input method), the slowdown is
pretty much guaranteed. Moreover, too frequent cache resets increase the
load on Emacs' garbage collector (cache size is typically a multiple of
buffer size). Overloading garbage collector leads to overall Emacs
slowdown.
>> The hooks are called, but after quail already triggered
>> buffer-chars-modified-tick increase. If quail called
>> before-change-functions before buffer-chars-modified-tick increases, it
>> would be useful for my scenario. Though I am not sure how feasible it
>> is. Just an idea.
>
> Would it help if Org looked at both buffer-modified-tick and
> buffer-chars-modified-tick?
When buffer-chars-modified-tick is changed, buffer-modified-tick is also
changed. AFAIU, buffer-chars-modified-tick registers a subset of buffer
modifications that actually change buffer text. buffer-modified-tick
also registers text property changes. So, I do not see how
buffer-modified-tick can help.
Best,
Ihor
next prev parent reply other threads:[~2021-11-12 13:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 13:56 bug#51766: 29.0.50; Return value of buffer-chars-modified-tick changes when buffer text is not yet changed before inserting a character for non-latin input methods Ihor Radchenko
2021-11-11 15:19 ` Eli Zaretskii
2021-11-11 15:50 ` Ihor Radchenko
2021-11-11 17:35 ` Eli Zaretskii
2021-11-12 12:06 ` Ihor Radchenko
2021-11-12 12:15 ` Eli Zaretskii
2021-11-12 12:53 ` Ihor Radchenko
2021-11-12 13:09 ` Eli Zaretskii
2021-11-12 13:39 ` Ihor Radchenko [this message]
2021-11-12 15:17 ` Eli Zaretskii
2021-11-13 9:10 ` Ihor Radchenko
2021-11-13 10:11 ` Eli Zaretskii
2021-11-13 11:29 ` Ihor Radchenko
2021-11-13 13:38 ` Eli Zaretskii
2021-11-13 14:43 ` Ihor Radchenko
2021-11-13 15:24 ` Eli Zaretskii
2022-06-17 2:54 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-17 5:36 ` Eli Zaretskii
2022-06-17 13:16 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-17 10:05 ` Ihor Radchenko
2022-06-17 10:50 ` Eli Zaretskii
2022-06-21 4:13 ` bug#51766: string-pixel-width limitations (was: bug#51766: 29.0.50; Return value of buffer-chars-modified-tick changes when buffer text is not yet changed before inserting a character for non-latin input methods) Ihor Radchenko
2022-06-21 10:16 ` Eli Zaretskii
2022-06-21 11:00 ` Ihor Radchenko
2022-06-21 12:17 ` Eli Zaretskii
2022-06-21 12:39 ` Ihor Radchenko
2022-06-21 12:47 ` Eli Zaretskii
2022-06-21 13:03 ` Ihor Radchenko
2022-06-22 23:49 ` bug#51766: string-pixel-width limitations Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-17 13:28 ` bug#51766: 29.0.50; Return value of buffer-chars-modified-tick changes when buffer text is not yet changed before inserting a character for non-latin input methods Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-21 4:14 ` Ihor Radchenko
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=87wnldpk5x.fsf@localhost \
--to=yantar92@gmail.com \
--cc=51766@debbugs.gnu.org \
--cc=eliz@gnu.org \
/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.