unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* An idea: combine-change-calls
@ 2018-03-24 13:50 Alan Mackenzie
  2018-03-24 22:18 ` Stefan Monnier
  0 siblings, 1 reply; 32+ messages in thread
From: Alan Mackenzie @ 2018-03-24 13:50 UTC (permalink / raw)
  To: emacs-devel

Hello, Emacs.

We have the macro combine-after-change-calls, which does more or less
what it says - the executions of after-change-functions is postponed to
the end of the macro, and then they are all executed at once.  This is
all very well, but suffers from the severe restriction that it doesn't
work with before-change-functions at all.

How about combine-change-calls, which combine the b-c-f calls and a-c-f
calls of some function which makes many primitive changes into just one
b-c-f call and one a-c-f call.  It might look something like this:

    (defmacro combine-change-calls (beg end &rest form)
      `(if (not inhibit-modification-hooks)
         (let* ((-beg- ,beg) (-end- ,end)
                (end-marker (copy-marker -end-)))
           (run-hook-with-args before-change-functions beg end)
           (let ((inhibit-modification-hooks t))
             ,@form)
           (run-hook-with-args after-change-functions
                               beg (marker-position end-marker)
                               (- -end- -beg-)))))

.

The motivation is bug #30735, where executing comment-region on a large
region is slow.  It is slow because of the high number of calls to
before/after-change-functions caused by the many individual changes made
by comment-region.

The final part of comment-region could be amended from:

      (save-excursion
        ;; FIXME: maybe we should call uncomment depending on ARG.
        (funcall comment-region-function beg end arg)))

to

      (save-excursion
        ;; FIXME: maybe we should call uncomment depending on ARG.
        (if comment-region-combine-change-calls
            (combine-change-calls beg end
                                  (funcall comment-region-function beg end arg))
          (funcall comment-region-function beg end arg))))

, where comment-region-combine-change-calls would be a new buffer local
variable.

What do people think?

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-04-03  3:15 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-24 13:50 An idea: combine-change-calls Alan Mackenzie
2018-03-24 22:18 ` Stefan Monnier
2018-03-25 19:14   ` Alan Mackenzie
2018-03-25 20:05     ` Stefan Monnier
2018-03-26 20:17       ` Alan Mackenzie
2018-03-26 21:07         ` Stefan Monnier
2018-03-27 16:58           ` Alan Mackenzie
2018-03-27 18:30             ` Stefan Monnier
2018-03-27 19:45               ` Alan Mackenzie
2018-03-27 20:24                 ` Stefan Monnier
2018-03-28 20:42                   ` Alan Mackenzie
2018-03-28 21:26                     ` Stefan Monnier
2018-03-29 15:10                       ` Alan Mackenzie
2018-03-29 15:40                         ` Stefan Monnier
2018-03-29 17:11                           ` Alan Mackenzie
2018-03-29 19:10                             ` Stefan Monnier
2018-03-30 11:46                               ` Alan Mackenzie
2018-03-30 15:05                                 ` Stefan Monnier
2018-03-31 21:00                                   ` Alan Mackenzie
2018-03-31 23:38                                     ` Stefan Monnier
2018-04-01 14:24                                       ` Alan Mackenzie
2018-04-01 19:22                                         ` Stefan Monnier
2018-03-30  9:12           ` Johan Bockgård
2018-03-30 13:04             ` Stefan Monnier
2018-04-02 16:25               ` Alan Mackenzie
2018-04-02 17:52                 ` Johan Bockgård
2018-04-03  0:41                 ` Stefan Monnier
2018-04-03  1:43                 ` Clément Pit-Claudel
2018-04-03  3:15                 ` Richard Stallman
2018-03-26 21:09         ` Stefan Monnier
2018-03-27  0:36         ` Stefan Monnier
2018-03-27 17:00           ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).