From: Alan Mackenzie <acm@muc.de>
To: Zhang Haijun <ccsmile2008@outlook.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, 35316@debbugs.gnu.org
Subject: bug#35316: 26.2; Emacs lags in c++-mode buffer when editing with iedit-mode on
Date: Thu, 16 May 2019 15:04:57 +0000 [thread overview]
Message-ID: <20190516150457.GA639@ACM> (raw)
In-Reply-To: <PS1PR06MB2759273EF4B58A8ED70D3C8CA8270@PS1PR06MB2759.apcprd06.prod.outlook.com>
Hello, Zhang.
On Fri, Apr 19, 2019 at 00:22:59 +0000, Zhang Haijun wrote:
> iedit.el(https://github.com/victorhge/iedit) is a multiple-cursors like
> package. It can setup more than one virtual cursors at different
> positions in the buffer. When you edit in the buffer, it clones changes
> at the main cursor to all other virtual cursors.
> The problem is that: Emacs lags too much when editing in c++-mode with
> iedit-mode on. Profiler shows that cpu are most used by
> c-after-change.
The problem is in the function iedit-update-occurrences-2. There,
inhibit-modification-hooks is bound to t, and the many changes are made.
The hook after-change-functions is called explicitly after each change.
But before-change-functions is not called in this loop. This is a very
bad idea. Unlike many modes, CC Mode has critical parts of its
functionality in the before-change-functions hook, and depends on this
hook and after-change-functions both being called for each change.
When CC Mode detects after-change-functions being called without
before-..., it enlarges the region to the whole buffer, calls
c-before-change with this enlarged region, finally proceding with the
rest of c-after-change. It does this to protect its buffer's integrity.
So, the lag with the multiple cursors is being caused by processing the
entire buffer for each cursor, rather than just part of the buffer
involved.
So, why are you binding inhibit-modification-hooks to t and calling
after-change-functions this way? Why not just let the modification hooks
run in the normal fashion? What is it about before-change-functions
which is bad in iedit-mode?
> The related issue: https://github.com/victorhge/iedit/issues/83
> In GNU Emacs 26.2 (build 1, x86_64-apple-darwin17.7.0, NS appkit-1561.60 Version 10.13.6 (Build 17G6030))
> of 2019-04-13 built on jundeMac
> Windowing system distributor 'Apple', version 10.3.1561
> Recent messages:
> For information about GNU Emacs and the GNU system, type C-h C-a.
[ .... ]
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2019-05-16 15:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5A24EADA-D920-4E1D-8CAE-511A6A74588C@outlook.com>
2019-04-19 0:22 ` bug#35316: 26.2; Emacs lags in c++-mode buffer when editing with iedit-mode on Zhang Haijun
2019-04-19 0:32 ` Zhang Haijun
2019-04-19 16:20 ` Stefan Monnier
2019-04-20 2:44 ` Zhang Haijun
2019-05-09 13:23 ` Zhang Haijun
2019-05-16 15:04 ` Alan Mackenzie [this message]
2019-05-16 15:46 ` Zhang Haijun
2019-05-16 16:17 ` Alan Mackenzie
2019-05-17 0:48 ` Zhang Haijun
2019-05-17 1:19 ` Amos Bird
2019-05-17 10:01 ` Alan Mackenzie
[not found] ` <20190517100118.GB5011@ACM>
2019-05-17 17:35 ` Amos Bird
2019-05-19 11:40 ` Alan Mackenzie
2019-05-19 13:20 ` Noam Postavsky
2019-05-19 14:26 ` Alan Mackenzie
2019-05-19 17:41 ` Noam Postavsky
2019-05-19 13:51 ` Zhang Haijun
2019-11-04 3:16 ` Zhang Haijun
2020-09-20 17:59 ` Lars Ingebrigtsen
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=20190516150457.GA639@ACM \
--to=acm@muc.de \
--cc=35316@debbugs.gnu.org \
--cc=ccsmile2008@outlook.com \
--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 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.