From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs 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 Message-ID: <20190516150457.GA639@ACM> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="136562"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Stefan Monnier , 35316@debbugs.gnu.org To: Zhang Haijun Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 16 17:06:32 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRHxn-000ZJ4-2i for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 May 2019 17:06:31 +0200 Original-Received: from localhost ([127.0.0.1]:59712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRHxl-0002sb-VN for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 May 2019 11:06:29 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:34260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRHxg-0002ry-D9 for bug-gnu-emacs@gnu.org; Thu, 16 May 2019 11:06:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRHxX-0002J9-RT for bug-gnu-emacs@gnu.org; Thu, 16 May 2019 11:06:21 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRHxK-0001nl-Hz; Thu, 16 May 2019 11:06:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hRHxK-0000tn-97; Thu, 16 May 2019 11:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 16 May 2019 15:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35316 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 35316-submit@debbugs.gnu.org id=B35316.15580191133380 (code B ref 35316); Thu, 16 May 2019 15:06:02 +0000 Original-Received: (at 35316) by debbugs.gnu.org; 16 May 2019 15:05:13 +0000 Original-Received: from localhost ([127.0.0.1]:56074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hRHwX-0000sS-AU for submit@debbugs.gnu.org; Thu, 16 May 2019 11:05:13 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:52222 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hRHwS-0000sB-VS for 35316@debbugs.gnu.org; Thu, 16 May 2019 11:05:10 -0400 Original-Received: (qmail 74442 invoked by uid 3782); 16 May 2019 15:04:58 -0000 Original-Received: from acm.muc.de (p4FE15BED.dip0.t-ipconnect.de [79.225.91.237]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 16 May 2019 17:04:57 +0200 Original-Received: (qmail 803 invoked by uid 1000); 16 May 2019 15:04:57 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159399 Archived-At: 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).