unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21885: 24.5; Transposing things with a negative argument
@ 2015-11-12  8:12 Eli Barzilay
  2015-11-12 16:18 ` Eli Zaretskii
  2015-11-12 18:11 ` Stephen Leake
  0 siblings, 2 replies; 10+ messages in thread
From: Eli Barzilay @ 2015-11-12  8:12 UTC (permalink / raw)
  To: 21885

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 627 bytes --]

In the past (IIRC, up to around v24.3) transposing things (chars,
words, sexprs, lines) would always leave the point after the
transposed thing.  This means that I could always use a `C--' prefix
to "drag" the current thing backwards in the same way that the default
action drags it forwards.  This is no longer happenning.

After a few trials the thing that seems to fix it is adding this line
at the end of the `transpose-subr' definition:

    (goto-char (+ (car pos2) (- (cdr pos1) (car pos1))))

To be clear, this is not a backward incompatible change -- it fixes
the *current* incompatible change.

Patch file attached.


[-- Attachment #2: 0001-Fix-transpose-subr-with-a-negative-argument.patch --]
[-- Type: application/octet-stream, Size: 918 bytes --]

From 84a951fa309ff45c033428c7cb8c32290ab13168 Mon Sep 17 00:00:00 2001
From: Eli Barzilay <eli@barzilay.org>
Date: Thu, 12 Nov 2015 03:00:33 -0500
Subject: [PATCH] Fix `transpose-subr' with a negative argument

Make the cursor go to the end of the transposed text, in the same way it
does with a positive argument.
---
 lisp/simple.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 1f2f4fe..86fa16d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6497,7 +6497,8 @@ current object."
       (setq pos1 (funcall aux -1))
       (goto-char (car pos1))
       (setq pos2 (funcall aux arg))
-      (transpose-subr-1 pos1 pos2)))))
+      (transpose-subr-1 pos1 pos2)
+      (goto-char (+ (car pos2) (- (cdr pos1) (car pos1))))))))
 
 (defun transpose-subr-1 (pos1 pos2)
   (when (> (car pos1) (cdr pos1)) (setq pos1 (cons (cdr pos1) (car pos1))))
-- 
2.6.3


[-- Attachment #3: .signature --]
[-- Type: text/plain, Size: 151 bytes --]


-- 
                    ((x=>x(x))(x=>x(x)))                   Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-12  8:12 bug#21885: 24.5; Transposing things with a negative argument Eli Barzilay
@ 2015-11-12 16:18 ` Eli Zaretskii
  2015-11-12 18:00   ` martin rudalics
  2015-11-12 18:11 ` Stephen Leake
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2015-11-12 16:18 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: 21885

> From: Eli Barzilay <eli@barzilay.org>
> Date: Thu, 12 Nov 2015 03:12:07 -0500
> 
> In the past (IIRC, up to around v24.3) transposing things (chars,
> words, sexprs, lines) would always leave the point after the
> transposed thing.  This means that I could always use a `C--' prefix
> to "drag" the current thing backwards in the same way that the default
> action drags it forwards.  This is no longer happenning.

Could you please describe in more detail what do you see vs what you
expected?  I'm not sure I understand the problem; in particular, I do
see point "after the transposed thing", but maybe I don't understand
what you meant by that.

Thanks.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-12 16:18 ` Eli Zaretskii
@ 2015-11-12 18:00   ` martin rudalics
  2015-11-12 18:17     ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: martin rudalics @ 2015-11-12 18:00 UTC (permalink / raw)
  To: Eli Zaretskii, Eli Barzilay; +Cc: 21885

> Could you please describe in more detail what do you see vs what you
> expected?  I'm not sure I understand the problem; in particular, I do
> see point "after the transposed thing", but maybe I don't understand
> what you meant by that.

Bug#20698?

martin






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-12  8:12 bug#21885: 24.5; Transposing things with a negative argument Eli Barzilay
  2015-11-12 16:18 ` Eli Zaretskii
@ 2015-11-12 18:11 ` Stephen Leake
  2015-11-12 18:24   ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Stephen Leake @ 2015-11-12 18:11 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: 21885

Eli Barzilay <eli@barzilay.org> writes:

> In the past (IIRC, up to around v24.3) transposing things (chars,
> words, sexprs, lines) would always leave the point after the
> transposed thing. ...  This is no longer happenning.

I can't reproduce this. In Emacs 24.3, emacs -Q, in *scratch* buffer,
where | is point:

fob|ar

invoke C-t transpose-char gives:

foab|r

Same behavior in emacs master.

Please post a recipe.

-- 
-- Stephe





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-12 18:00   ` martin rudalics
@ 2015-11-12 18:17     ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2015-11-12 18:17 UTC (permalink / raw)
  To: martin rudalics; +Cc: eli, 21885

> Date: Thu, 12 Nov 2015 19:00:35 +0100
> From: martin rudalics <rudalics@gmx.at>
> CC: 21885@debbugs.gnu.org
> 
> > Could you please describe in more detail what do you see vs what you
> > expected?  I'm not sure I understand the problem; in particular, I do
> > see point "after the transposed thing", but maybe I don't understand
> > what you meant by that.
> 
> Bug#20698?

Looks like that, thanks.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-12 18:11 ` Stephen Leake
@ 2015-11-12 18:24   ` Eli Zaretskii
  2015-11-12 19:27     ` Eli Barzilay
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2015-11-12 18:24 UTC (permalink / raw)
  To: Stephen Leake; +Cc: eli, 21885

> From: Stephen Leake <stephen_leake@stephe-leake.org>
> Date: Thu, 12 Nov 2015 12:11:42 -0600
> Cc: 21885@debbugs.gnu.org
> 
> Eli Barzilay <eli@barzilay.org> writes:
> 
> > In the past (IIRC, up to around v24.3) transposing things (chars,
> > words, sexprs, lines) would always leave the point after the
> > transposed thing. ...  This is no longer happenning.
> 
> I can't reproduce this. In Emacs 24.3, emacs -Q, in *scratch* buffer,
> where | is point:
> 
> fob|ar
> 
> invoke C-t transpose-char gives:
> 
> foab|r
> 
> Same behavior in emacs master.

I think I know the answer: the difference is visible only if you
invoke C-t with a negative argument, as in "C-- C-t".





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-12 18:24   ` Eli Zaretskii
@ 2015-11-12 19:27     ` Eli Barzilay
  2015-11-13  9:47       ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Barzilay @ 2015-11-12 19:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stephen Leake, 21885

On Thu, Nov 12, 2015 at 1:24 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Stephen Leake <stephen_leake@stephe-leake.org>
>> Date: Thu, 12 Nov 2015 12:11:42 -0600
>> Cc: 21885@debbugs.gnu.org
>>
>> Eli Barzilay <eli@barzilay.org> writes:
>>
>> > In the past (IIRC, up to around v24.3) transposing things (chars,
>> > words, sexprs, lines) would always leave the point after the
>> > transposed thing. ...  This is no longer happenning.
> [...]
>
> I think I know the answer: the difference is visible only if you
> invoke C-t with a negative argument, as in "C-- C-t".

Yes, exactly -- and yes, this is the same bug as #20698.  I looked at
the code a bit more since then, and I think that my patch is a fine fix.

-- 
                    ((x=>x(x))(x=>x(x)))                   Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-12 19:27     ` Eli Barzilay
@ 2015-11-13  9:47       ` Eli Zaretskii
  2015-11-13 13:13         ` Juanma Barranquero
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2015-11-13  9:47 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: 21885-done, stephen_leake

> Date: Thu, 12 Nov 2015 14:27:07 -0500
> From: Eli Barzilay <eli@barzilay.org>
> Cc: Stephen Leake <stephen_leake@stephe-leake.org>, 21885@debbugs.gnu.org, 
> 	martin rudalics <rudalics@gmx.at>
> 
> On Thu, Nov 12, 2015 at 1:24 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> From: Stephen Leake <stephen_leake@stephe-leake.org>
> >> Date: Thu, 12 Nov 2015 12:11:42 -0600
> >> Cc: 21885@debbugs.gnu.org
> >>
> >> Eli Barzilay <eli@barzilay.org> writes:
> >>
> >> > In the past (IIRC, up to around v24.3) transposing things (chars,
> >> > words, sexprs, lines) would always leave the point after the
> >> > transposed thing. ...  This is no longer happenning.
> > [...]
> >
> > I think I know the answer: the difference is visible only if you
> > invoke C-t with a negative argument, as in "C-- C-t".
> 
> Yes, exactly -- and yes, this is the same bug as #20698.  I looked at
> the code a bit more since then, and I think that my patch is a fine fix.

Thanks, pushed.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-13  9:47       ` Eli Zaretskii
@ 2015-11-13 13:13         ` Juanma Barranquero
  2015-11-13 13:36           ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Juanma Barranquero @ 2015-11-13 13:13 UTC (permalink / raw)
  To: Eli Zaretskii, 21885, Eli Barzilay; +Cc: 21885-done, Stephen Leake

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

On Fri, Nov 13, 2015 at 10:47 AM, Eli Zaretskii <eliz@gnu.org> wrote:

> Thanks, pushed.

Commit a731c2f163071ed6efe7d93fa9585dd66ddf2fbb adds a test for this bug
(based on the use case in bug#20698).

[-- Attachment #2: Type: text/html, Size: 301 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#21885: 24.5; Transposing things with a negative argument
  2015-11-13 13:13         ` Juanma Barranquero
@ 2015-11-13 13:36           ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2015-11-13 13:36 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 21885-done, eli, stephen_leake, 21885

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Fri, 13 Nov 2015 14:13:37 +0100
> Cc: 21885-done@debbugs.gnu.org, Stephen Leake <stephen_leake@stephe-leake.org>
> 
> On Fri, Nov 13, 2015 at 10:47 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > Thanks, pushed.
> 
> Commit a731c2f163071ed6efe7d93fa9585dd66ddf2fbb adds a test for this bug (based
> on the use case in bug#20698).

Thanks!





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-11-13 13:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-12  8:12 bug#21885: 24.5; Transposing things with a negative argument Eli Barzilay
2015-11-12 16:18 ` Eli Zaretskii
2015-11-12 18:00   ` martin rudalics
2015-11-12 18:17     ` Eli Zaretskii
2015-11-12 18:11 ` Stephen Leake
2015-11-12 18:24   ` Eli Zaretskii
2015-11-12 19:27     ` Eli Barzilay
2015-11-13  9:47       ` Eli Zaretskii
2015-11-13 13:13         ` Juanma Barranquero
2015-11-13 13:36           ` Eli Zaretskii

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