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: Sun, 19 May 2019 11:40:19 +0000 Message-ID: <20190519114019.GA5262@ACM> References: <20190516150457.GA639@ACM> <20190516161704.GA527@ACM> <871s0xop2o.fsf@gmail.com> <20190517100118.GB5011@ACM> <87lfz5c7b5.fsf@gmail.com> 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="3768"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 35316@debbugs.gnu.org To: Amos Bird , Zhang Haijun Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 19 13:41:17 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 1hSKBo-0000rt-TQ for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 May 2019 13:41:17 +0200 Original-Received: from localhost ([127.0.0.1]:47360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSKBn-0000Sk-QX for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 May 2019 07:41:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:34851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSKBe-0000Oz-9X for bug-gnu-emacs@gnu.org; Sun, 19 May 2019 07:41:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSKBc-0000YV-Tp for bug-gnu-emacs@gnu.org; Sun, 19 May 2019 07:41:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSKBa-0000X2-9T; Sun, 19 May 2019 07:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hSKBa-0007i3-4r; Sun, 19 May 2019 07:41: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: Sun, 19 May 2019 11:41: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.155826603229589 (code B ref 35316); Sun, 19 May 2019 11:41:02 +0000 Original-Received: (at 35316) by debbugs.gnu.org; 19 May 2019 11:40:32 +0000 Original-Received: from localhost ([127.0.0.1]:34031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hSKB6-0007hA-09 for submit@debbugs.gnu.org; Sun, 19 May 2019 07:40:32 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:11669 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hSKB4-0007gy-BP for 35316@debbugs.gnu.org; Sun, 19 May 2019 07:40:31 -0400 Original-Received: (qmail 53083 invoked by uid 3782); 19 May 2019 11:40:24 -0000 Original-Received: from acm.muc.de (p2E5D561D.dip0.t-ipconnect.de [46.93.86.29]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 19 May 2019 13:40:23 +0200 Original-Received: (qmail 6220 invoked by uid 1000); 19 May 2019 11:40:19 -0000 Content-Disposition: inline In-Reply-To: <87lfz5c7b5.fsf@gmail.com> 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:159532 Archived-At: Hello, Amos and Zhang. First thing, apologies for the patch I sent you a few days ago. It was based on a misunderstanding, and it is total garbage! The misunderstanding was the assumption that `inhibit-modification-hooks' would be nil on entry to `iedit-update-occurrences-2', and that leaving it nil would allow the `before-change-functions' and `after-change-functions' hooks to run normally. In actual fact `inhibit-modification-hooks' is t at that point, and cannot successfully be bound to nil. So, both `before-change-functions' and `after-change-functions' need to be called explicitly for successful processing. So, please disregard that previous patch from me, and try out instead the patch below. In C++ Mode it is somewhat slower, since it is actually doing the change processing, but not unusably so. Undo seems to be working a bit faster too, though it is often not instantaneous as one would wish (see below). On Sat, May 18, 2019 at 01:35:58 +0800, Amos Bird wrote: > Hi Alan! > > Are we still talking about C++ Mode > Yeah it's c++ mode but it can also be reproduced with c mode. > The minute long frozen is caused mainly by the lsp-mode, howeveer > it's still laggy after turning lsp off. > > How big is your file? Can you characterise it in any way? > You can try emacs/src/xdisp.c . iediting all "make_fixnum", > turning them into "make_fixnum_why_undo_redo_is_so_slow", and > undo. > It's about 10-20 seconds freezing time here. When I do this now (with the patch in place), undo works in two stages, taking about 0.4s and 2.4s respectively on my machine. > > It seems I have more work to do on this in any case. As a matter of interest, could one of you please give me the name and email address of the iedit-mode maintainer. I haven't got a github account, and don't want to create one, so I don't think I can get in touch with her/him that way. > Looking forward to it! OK, here goes! --- iedit-lib.el.orig 2019-05-19 10:55:31.681959998 +0000 +++ iedit-lib.el 2019-05-19 11:08:27.549988930 +0000 @@ -490,7 +490,9 @@ (defun iedit-update-occurrences-2 (occurrence after beg end &optional change) "" - (let ((inhibit-modification-hooks t) + (let (;; (inhibit-modification-hooks t) + ;; Note: `inhibit-modification-hook' will already be non-nil when this + ;; function is called. Setting it to nil here doesn't work. (offset (- beg (overlay-start occurrence))) (value (buffer-substring-no-properties beg end))) (save-excursion @@ -501,6 +503,9 @@ (ending (+ beginning (- end beg)))) (when (not (eq another-occurrence occurrence)) (goto-char beginning) + (run-hook-with-args 'before-change-functions + beginning + (+ beginning change)) (insert-and-inherit value) ;; todo: reconsider this change Quick fix for ;; multi-occur occur-edit-mode: multi-occur depend on @@ -517,13 +522,17 @@ ;; deletion (dolist (another-occurrence (remove occurrence iedit-occurrences-overlays)) (let ((beginning (+ (overlay-start another-occurrence) offset))) + (goto-char beginning) + (run-hook-with-args 'before-change-functions + beginning + (+ beginning change)) (delete-region beginning (+ beginning change)) (unless (eq beg end) ;; replacement (goto-char beginning) (insert-and-inherit value)) (run-hook-with-args 'after-change-functions beginning - (+ beginning (- beg end)) + (+ beginning (- end beg)) change))))))) (defun iedit-next-occurrence () > regards, > -- > Amos Bird > amosbird@gmail.com -- Alan Mackenzie (Nuremberg, Germany).