bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35316: 26.2; Emacs lags in c++-mode buffer when editing with iedit-m


From: Alan Mackenzie
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
User-agent: Mutt/1.10.1 (2018-07-13)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]