emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: An idea: combine-change-calls


From: Stefan Monnier
Subject: Re: An idea: combine-change-calls
Date: Fri, 30 Mar 2018 11:05:24 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> (defun wrap-and-run-primitive-undo (beg end list)
>   (let ((old-bul buffer-undo-list)
>       (end-marker (copy-marker end)))

I'd have expected it to start with:

    (defun wrap-and-run-primitive-undo (beg end list)
      (combine-change-calls

also this is an internal function that will only be useful for
combine-change-calls, so it needs to have a "--" in its name.

>     (let ((inhibit-modification-hooks t))
>       (funcall #'primitive-undo 1 list))

I think you want something like

    (while list
      (setq list (primitive-undo 1 list))

in case there are some undo-boundaries in `list`.

> (defmacro combine-change-calls (beg end &rest forms)
>   `(let ((-beg- ,beg)

It now occurs to me that it's probable preferable to do:

    (defmacro combine-change-calls (beg end &rest forms)
      `(combine-change-calls-function ,beg ,end (lambda () ,@forms)))

and then

    (defun combine-change-calls-function (beg rest body)
      ... do the heavy lifting here ...)

>              (while (not (eq (cdr ptr) old-bul))
>                (setq ptr (cdr ptr)))

This can inf-loop if the new buffer-undo-list happens not to be an
extension of the old list any more.

>> I could imagine a macro `with-inhibit-read-only` which would bind
>> inhibit-read-only to t and then tweak the buffer-undo-list similarly to
>> what you're doing such that the undo is also performed with
>> inhibit-read-only bound to t.
> OK, thanks.  The above code hasn't taken this into account

That was for the case that you decided not to use (apply ...) but some
new undo-element.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]