* Is it safe to use the combine-after-change-calls like this?
@ 2019-04-17 0:21 Zhang Haijun
2019-04-17 1:14 ` Stefan Monnier
2019-04-17 18:28 ` Stefan Monnier
0 siblings, 2 replies; 7+ messages in thread
From: Zhang Haijun @ 2019-04-17 0:21 UTC (permalink / raw
To: emacs-devel@gnu.org
I want to use it with multiple-cursors.el(https://github.com/magnars/multiple-cursors.el) like this:
1. When multiple-cursors activates, set combine-after-change-calls to t
2. Edit the buffer with multiple active cursors
3. Before multiple-cursors deactivates, call combine-after-change-execute and set combine-after-change-calls back to nil.
I’m using the package iedit.el(https://github.com/victorhge/iedit). It works like multiple-cursors.el, which has multiple active cursors.
The problem is that: when editing with multiple active cursors, emacs lags too much. It seems that most of cpu is used by functions in after-change-functions.
The issue: https://github.com/victorhge/iedit/issues/83
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is it safe to use the combine-after-change-calls like this?
@ 2019-04-18 5:34 Zhang Haijun
2019-04-18 12:21 ` Stefan Monnier
2019-04-26 10:31 ` Alan Mackenzie
0 siblings, 2 replies; 7+ messages in thread
From: Zhang Haijun @ 2019-04-18 5:34 UTC (permalink / raw
To: emacs-devel@gnu.org
> combine-after-change-calls is ignored when before-change-functions is non-nil.
I just recognize this. It is not nil in c++-mode buffers.
> Also, regarding interaction with non-CC-mode buffers: you might be able
> to improve the efficiency of the code by executing the command of the
> various cursors starting with the one closest to point-max and finishing
> with the one closest to point-min.
I don’t understand this well. I see that when iedit-mode is on, it calls after-change-functions on change around every active cursors for every char inputing.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is it safe to use the combine-after-change-calls like this?
2019-04-18 5:34 Zhang Haijun
@ 2019-04-18 12:21 ` Stefan Monnier
2019-04-26 10:31 ` Alan Mackenzie
1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2019-04-18 12:21 UTC (permalink / raw
To: emacs-devel
>> Also, regarding interaction with non-CC-mode buffers: you might be able
>> to improve the efficiency of the code by executing the command of the
>> various cursors starting with the one closest to point-max and finishing
>> with the one closest to point-min.
> I don’t understand this well.
If you're currently operating (via Iedit or MC) at positions 10, 42 and
347, then I think it's going to be slightly more efficient if Iedit/MC
runs your command (e.g. self-insert-command, delete-char, you name it)
in the order
run at 347
run at 42
run at 10
then if it does it in the order
run at 10
run at 42
run at 347
> I see that when iedit-mode is on, it calls after-change-functions on
> change around every active cursors for every char inputing.
Yes, of course, that's what after-change-functions is for.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is it safe to use the combine-after-change-calls like this?
2019-04-18 5:34 Zhang Haijun
2019-04-18 12:21 ` Stefan Monnier
@ 2019-04-26 10:31 ` Alan Mackenzie
2019-04-26 12:09 ` Stefan Monnier
1 sibling, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2019-04-26 10:31 UTC (permalink / raw
To: Zhang Haijun; +Cc: emacs-devel@gnu.org
Hello, Zhang.
On Thu, Apr 18, 2019 at 05:34:56 +0000, Zhang Haijun wrote:
> > combine-after-change-calls is ignored when before-change-functions is non-nil.
> I just recognize this. It is not nil in c++-mode buffers.
CC Mode maintains several caches of state information, which are updated
in the before-change-functions and after-change-functions hooks. This
is on the assumption that successive buffer changes are usually close to
eachother. Obviously, this is less true in iedit-mode, and it is likely
that these caches hinder rather than help in this case.
> > Also, regarding interaction with non-CC-mode buffers: you might be able
> > to improve the efficiency of the code by executing the command of the
> > various cursors starting with the one closest to point-max and finishing
> > with the one closest to point-min.
> I don’t understand this well. I see that when iedit-mode is on, it
> calls after-change-functions on change around every active cursors for
> every char inputing.
One thing which might help in the future is the macro
combine-change-calls, which is a bit like combine-after-change-calls,
but also works when before-change-functions isn't nil.
combine-change-calls is in the Emacs repository master, and should be
getting released with Emacs 27.1 in the medium future (maybe about a
year from now).
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is it safe to use the combine-after-change-calls like this?
2019-04-26 10:31 ` Alan Mackenzie
@ 2019-04-26 12:09 ` Stefan Monnier
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2019-04-26 12:09 UTC (permalink / raw
To: emacs-devel
>> I don’t understand this well. I see that when iedit-mode is on, it
>> calls after-change-functions on change around every active cursors for
>> every char inputing.
>
> One thing which might help in the future is the macro
> combine-change-calls, which is a bit like combine-after-change-calls,
> but also works when before-change-functions isn't nil.
I think in the case of iedit this is problematic, because
combine-change-calls can't be used around code which internally depends
on those before/after functions (e.g. in the present case, it could
misbehave if its behavior depends on the text-properties that are
updated via before/after-change-functions, like syntax-table).
For comment-combine-change-calls, we think it's OK because we hope that
(un)comment-region will not be affected by those stale data, but with
iedit there's much less knowledge/control of the range of code that would
be run within the combine-change-calls, making it more problematic.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-04-26 12:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-17 0:21 Is it safe to use the combine-after-change-calls like this? Zhang Haijun
2019-04-17 1:14 ` Stefan Monnier
2019-04-17 18:28 ` Stefan Monnier
-- strict thread matches above, loose matches on Subject: below --
2019-04-18 5:34 Zhang Haijun
2019-04-18 12:21 ` Stefan Monnier
2019-04-26 10:31 ` Alan Mackenzie
2019-04-26 12:09 ` Stefan Monnier
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.