all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: An idea: combine-change-calls
Date: Sat, 31 Mar 2018 19:38:03 -0400	[thread overview]
Message-ID: <jwvvadb3k1t.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20180331210052.GB5003@ACM> (Alan Mackenzie's message of "Sat, 31 Mar 2018 21:00:52 +0000")

> >     (defun wrap-and-run-primitive-undo (beg end list)
> >       (combine-change-calls
> That's a refinement I haven't managed to get around to, yet.

Any difficulty there?
Naively, I'd expect that it's just a matter of:

    (defun undo--wrap-and-run-primitive-undo (beg end list)
      (combine-change-calls
        (while list
          (setq list (primitive-undo 1 list)))))
  
[ and of course, making sure this function is defined after the
  combine-change-calls macro.  ]

>>     (defmacro combine-change-calls (beg end &rest forms)
>>       `(combine-change-calls-function ,beg ,end (lambda () ,@forms)))
> DONE, at least with the name combine-change-calls-1.

Good.

> I don't really like "...-function", since that suggests
> a hook variable.

I'm not too fond of those either for the same reason, although I must
admit to using such names occasionally.

> Not only can, but does.  I spent around 2 hours yesterday waiting for
> this infinite loop to terminate.  ;-(

I'm sure it was just a question of time.

> It is, of course, garbage collection which lops off the element we're
> looking for, particularly when commenting out a large region.

Yes, that should be the most common reason.

> So, I think this exercise is worthwhile.  I have added some doc strings
> to the functions.  I have introduced a variable to hinder a "recursive"
> undo--wrap-and-run-primitive-undo appearing in the undo list.  This
> happened with uncomment-region calling comment-region.

That's weird: shouldn't the inhibit-modification-hooks already play this role?

Oh, wait, I see you don't test inhibit-modification-hooks any more but
you test undo--combining-change-calls instead.  Any particular reason
for this change?

> Sometimes, point ends up at the wrong place after an undo (probably
> because of primitive-undo removing POSITION elements from undo-lists, as
> we've already discussed.)

The code that removes those "position" elements is in `undo`, not in
`primitive-undo`, so what you're describing must come from something
else (unless you're seeing this when *redoing* or *reundoing*).


        Stefan



  reply	other threads:[~2018-03-31 23:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=jwvvadb3k1t.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /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.