unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: martin rudalics <rudalics@gmx.at>
Cc: 37700@debbugs.gnu.org
Subject: bug#37700: 27.0.50; undo mouse-drag-and-drop-region ineffective
Date: Fri, 11 Oct 2019 14:51:01 +0200	[thread overview]
Message-ID: <94D2DE0C-8BD0-4CCF-B77D-5606A1D227DD@acm.org> (raw)
In-Reply-To: <dc143df4-981e-6965-8e3d-20fb80337231@gmx.at>

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]

11 okt. 2019 kl. 14.19 skrev martin rudalics <rudalics@gmx.at>:
> 
> I suppose this the effect of undo working on the active region only.
> A very nasty invention.  Try deactivating the region right after 3.

Right, thank you. I wonder if anything would break if that were changed.

Proof-of-concept patch attached. (Manual and NEWS changes not included.) It does solve this particular problem.

Do you know of any drawbacks for someone whose editing habits are not dependent on the region confinement of undo?


[-- Attachment #2: 0001-Make-undo-confinement-to-active-region-user-settable.patch --]
[-- Type: application/octet-stream, Size: 2424 bytes --]

From e2e3a60fcc42eea4703c6f7b2877eae7188a73bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Fri, 11 Oct 2019 14:42:48 +0200
Subject: [PATCH] Make undo confinement to active region user-settable
 (bug#37700)

* lisp/simple.el (undo-confined-to-active-region, undo):
Add defcustom `undo-confined-to-active-region' that controls whether
the effects of `undo' are confined to the region when it is active.
The default value is t.
---
 lisp/simple.el | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 597278ae2b..10dec26200 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2464,6 +2464,14 @@ minibuffer-error-function
 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
 (define-obsolete-function-alias 'advertised-undo 'undo "23.2")
 
+(defcustom undo-confined-to-active-region t
+  "If non-nil, the effects of `undo' without argument are confined to
+the active region when there is one.  If nil, the effects of `undo'
+are independent of the region."
+  :type 'boolean
+  :group 'undo
+  :version "27.1")
+
 (defconst undo-equiv-table (make-hash-table :test 'eq :weakness t)
   "Table mapping redo records to the corresponding undo one.
 A redo record for undo-in-region maps to t.
@@ -2485,7 +2493,9 @@ undo
 A numeric ARG serves as a repeat count.
 
 In Transient Mark mode when the mark is active, only undo changes within
-the current region.  Similarly, when not in Transient Mark mode, just \\[universal-argument]
+the current region; this behaviour can be changed by customizing
+the variable `undo-confined-to-active-region'.
+Similarly, when not in Transient Mark mode, just \\[universal-argument]
 as an argument limits undo to changes within the current region."
   (interactive "*P")
   ;; Make last-command indicate for the next command that this was an undo.
@@ -2517,7 +2527,8 @@ undo
 		       ;; it shows nothing else happened in between.
 		       (gethash list undo-equiv-table))))
       (setq undo-in-region
-	    (or (region-active-p) (and arg (not (numberp arg)))))
+	    (or (and (region-active-p) undo-confined-to-active-region)
+                (and arg (not (numberp arg)))))
       (if undo-in-region
 	  (undo-start (region-beginning) (region-end))
 	(undo-start))
-- 
2.21.0 (Apple Git-122)


  reply	other threads:[~2019-10-11 12:51 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 [this message]
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
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=94D2DE0C-8BD0-4CCF-B77D-5606A1D227DD@acm.org \
    --to=mattiase@acm.org \
    --cc=37700@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /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).