GNU bug report logs - #21885
24.5; Transposing things with a negative argument

Previous Next

Package: emacs;

Reported by: Eli Barzilay <eli <at> barzilay.org>

Date: Thu, 12 Nov 2015 08:13:02 UTC

Severity: normal

Merged with 14037, 20698

Found in versions 24.3.50, 24.5, 25.0.50

Fixed in version 25.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#20698: closed (25.0.50; REGRESSION in `transpose-sexps'
 introduced in Emacs 24.4)
Date: Fri, 13 Nov 2015 09:49:03 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 13 Nov 2015 11:47:54 +0200
with message-id <83y4e2fcxh.fsf <at> gnu.org>
and subject line Re: bug#21885: 24.5; Transposing things with a negative argument
has caused the debbugs.gnu.org bug report #21885,
regarding 25.0.50; REGRESSION in `transpose-sexps' introduced in Emacs 24.4
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
21885: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21885
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; REGRESSION in `transpose-sexps' introduced in Emacs 24.4
Date: Sat, 30 May 2015 10:12:00 -0700 (PDT)
I say regression, but perhaps there was a good reason for the change in
behavior.  I couldn't find anything about it, checking NEWS and looking
through some bug reports.

In all Emacs versions prior to 24.4 (back through Emacs 20, at least),
when you use a negative prefix arg with `transpose-sexps' point ends up
after the sexp that moved.  Starting with 24.4, point does not move.

For example:

((s1) (s2) (s3) (s4) | (s5))

With point at |, `C-- C-M-t' gives you this prior to 24.4:

((s1) (s2) (s4) | (s3) (s5))

For 24.4+ it gives you this:

((s1) (s2) (s4) (s3) | (s5))

With `C-- 2', you get this:

< 24.4:

((s1) (s4) | (s2) (s3) (s5))

24.4+:

((s1) (s4) (s2) (s3) | (s5))

Is this by design or a mistake (regression)?  There is no change in the
code of `transpose-sexps' itself.  Perhaps that is a sign that this is
an unplanned side effect (bug)?  Or perhaps it was planned (why?).

It would be good, I think, if the doc mentioned what happens to point.

It would be good, I think - unless there is some great reason for this
change in behavior, to fix this bug.

As an example, the bug interferes with using repetition with a negative
prefix arg.  With the change (bug), repeating a negative prefix arg just
reverses the prefix transposition.

E.g., prior to this bug, you can effectively use `C-- C-M-t' repeatedly
to move a sexp backward:

((s1) (s2) (s3) (s4) | (s5))

C-- C-M-t

((s1) (s2) (s4) | (s3) (s5))

C-- C-M-t

((s1) (s4) | (s2) (s3) (s5))

After this bug:

((s1) (s2) (s3) (s4) | (s5))

C-- C-M-t

((s1) (s2) (s4) (s3) | (s5))

C-- C-M-t  ; Back to where we started.

((s1) (s2) (s3) (s4) | (s5))

Here is a command I use, for example, that lets you repeatedly
transpose and use a negative arg to reverse the direction.
Note the hack to compensate for this bug (I don't claim it is
the best hack for this).

(defun reversible-transpose-sexps (arg)
  "Reversible and repeatable `transpose-sexp'.
Like `transpose-sexps', but:
 1. Leaves point after the moved sexp.
 2. When repeated, a negative prefix arg flips the direction."
  (interactive "p")
  (when (eq last-command 'rev-transp-sexps-back) (setq arg  (- arg)))
  (transpose-sexps arg)
  (unless (natnump arg)
    (when (or (> emacs-major-version 24)
              (and (= emacs-major-version 24)  (> emacs-minor-version 3))) ; Emacs 24.4+
      (backward-sexp (abs arg))
      (skip-syntax-backward " ."))
    (setq this-command 'rev-transp-sexps-back)))


In GNU Emacs 25.0.50.1 (i686-pc-mingw32)
 of 2014-10-20 on LEG570
Bzr revision: 118168 rgm <at> gnu.org-20141020195941-icp42t8ttcnud09g
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking=yes,glyphs CPPFLAGS=-DGLYPH_DEBUG=1'


[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Eli Barzilay <eli <at> barzilay.org>
Cc: 21885-done <at> debbugs.gnu.org, stephen_leake <at> stephe-leake.org, rudalics <at> gmx.at
Subject: Re: bug#21885: 24.5; Transposing things with a negative argument
Date: Fri, 13 Nov 2015 11:47:54 +0200
> Date: Thu, 12 Nov 2015 14:27:07 -0500
> From: Eli Barzilay <eli <at> barzilay.org>
> Cc: Stephen Leake <stephen_leake <at> stephe-leake.org>, 21885 <at> debbugs.gnu.org, 
> 	martin rudalics <rudalics <at> gmx.at>
> 
> On Thu, Nov 12, 2015 at 1:24 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> >> From: Stephen Leake <stephen_leake <at> stephe-leake.org>
> >> Date: Thu, 12 Nov 2015 12:11:42 -0600
> >> Cc: 21885 <at> debbugs.gnu.org
> >>
> >> Eli Barzilay <eli <at> 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.


This bug report was last modified 9 years and 195 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.