all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Amos Bird <amosbird@gmail.com>, Zhang Haijun <ccsmile2008@outlook.com>
Cc: 35316@debbugs.gnu.org
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	[thread overview]
Message-ID: <20190519114019.GA5262@ACM> (raw)
In-Reply-To: <87lfz5c7b5.fsf@gmail.com>

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





  reply	other threads:[~2019-05-19 11:40 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
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 [this message]
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=20190519114019.GA5262@ACM \
    --to=acm@muc.de \
    --cc=35316@debbugs.gnu.org \
    --cc=amosbird@gmail.com \
    --cc=ccsmile2008@outlook.com \
    /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.