bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#37700: 27.0.50; undo mouse-drag-and-drop-region ineffective


From: Stefan Monnier
Subject: bug#37700: 27.0.50; undo mouse-drag-and-drop-region ineffective
Date: Mon, 28 Oct 2019 16:01:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> > On revision of writing, I often want to move a sentence around to fit
> > into right place, without loosing the sentence from sight.  Most of the
> > time I cannot relocate the sentence to the best place by single
> > drag-and-drop operation thus I want to maintain region active.
> Thank you, very much my experience.

Indeed, that's also my experience [ and as a result I stay away from
text's drag-and-drop since I find C-w ... C-y to be easier since it
avoids this trial-and-error problem ;-) ]

> -                                   (overlay-end overlay)))))
> +                                   (overlay-end overlay))))
> +                ;; Since we will leave the destination text selected,
> +                ;; make sure an undo operation disregards the region
> +                ;; or the operation will only be partially undone.
> +                (when (consp buffer-undo-list)
> +                  (push 'unconfined buffer-undo-list)))

Rather than add a special new kind of entry you can use some version of
(apply DELTA BEG END FUN-NAME . ARGS), presumably with DELTA=0 and
BEG=END, so you don't need to modify the docstring of `buffer-undo-list`
nor the implementation of primitive-undo.

> @@ -2862,7 +2864,10 @@ undo-make-selective-list
>         ((null undo-elt)
>          ;; Don't put two nils together in the list
>          (when (car selective-list)
> -          (push nil selective-list)))
> +          (push nil selective-list))
> +        (setq unconfined nil))
> +       ((eq undo-elt 'unconfined)
> +        (setq unconfined t))
>         ((and (consp undo-elt) (eq (car undo-elt) t))
>          ;; This is a "was unmodified" element.  Keep it
>          ;; if we have kept everything thus far.
> @@ -2875,7 +2880,7 @@ undo-make-selective-list
>         (t
>          (let ((adjusted-undo-elt (undo-adjust-elt undo-elt
>                                                    undo-deltas)))
> -          (if (undo-elt-in-region adjusted-undo-elt start end)
> +          (if (or (undo-elt-in-region adjusted-undo-elt start end) 
> unconfined)
>                (progn
>                  (setq end (+ end (cdr (undo-delta adjusted-undo-elt))))
>                  (push adjusted-undo-elt selective-list)

As a user of undo-in-region, I think I'd be surprised if my undo started
to modify parts of the buffer outside the region, so I think a better
approach would be to only pay attention to the `unconfined' marker when
it appears at the top of the `buffer-undo-list` (i.e. only if the
drag-and-drop was the very last operation).  Also I think it would
deserve a message in the minibuffer explaining that the undo is not
confined to the region.


        Stefan






reply via email to

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