unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: tkk@misasa.okayama-u.ac.jp, 37700@debbugs.gnu.org,
	homeros.misasa@gmail.com
Subject: bug#37700: 27.0.50; undo mouse-drag-and-drop-region ineffective
Date: Mon, 28 Oct 2019 16:01:54 -0400	[thread overview]
Message-ID: <jwvsgncodcv.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <37DDF48D-FC37-47A8-8CEC-C6EB66AB2BF7@acm.org> ("Mattias \=\?windows-1252\?Q\?Engdeg\=E5rd\=22's\?\= message of "Wed, 16 Oct 2019 17:27:05 +0200")

> > 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






  parent reply	other threads:[~2019-10-28 20:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 11:51 bug#37700: 27.0.50; undo mouse-drag-and-drop-region ineffective Mattias Engdegård
2019-10-11 12:19 ` martin rudalics
2019-10-11 12:51   ` Mattias Engdegård
2019-10-11 14:43     ` Eli Zaretskii
2019-10-11 17:18       ` Mattias Engdegård
2019-10-11 18:36         ` Eli Zaretskii
2019-10-11 18:51           ` Eli Zaretskii
2019-10-12  8:24           ` martin rudalics
2019-10-11 18:57         ` Eli Zaretskii
2019-10-11 18:26     ` martin rudalics
2019-10-11 19:12       ` Eli Zaretskii
2019-10-12  1:55       ` Tak Kunihiro
2019-10-12  8:24         ` martin rudalics
2019-10-12 16:42           ` Mattias Engdegård
2019-10-12 17:17             ` Eli Zaretskii
2019-10-12 17:53               ` Eli Zaretskii
2019-10-16 15:27                 ` Mattias Engdegård
2019-10-26 10:15                   ` Eli Zaretskii
2019-10-28 20:01                   ` Stefan Monnier [this message]
2019-10-30 19:09                     ` Mattias Engdegård
2019-10-30 19:56                       ` Stefan Monnier
2019-10-31 11:00                         ` Mattias Engdegård
2019-10-31 14:45                           ` Eli Zaretskii
2019-10-31 16:04                             ` Mattias Engdegård
2019-10-31 16:10                               ` Eli Zaretskii
2019-10-31 16:47                                 ` Mattias Engdegård
2019-10-11 12:26 ` Eli Zaretskii
2019-10-11 12:53   ` Mattias Engdegård

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvsgncodcv.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=37700@debbugs.gnu.org \
    --cc=homeros.misasa@gmail.com \
    --cc=mattiase@acm.org \
    --cc=tkk@misasa.okayama-u.ac.jp \
    /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 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).