* bug#20698: 25.0.50; REGRESSION in `transpose-sexps' introduced in Emacs 24.4
@ 2015-05-30 17:12 Drew Adams
0 siblings, 0 replies; only message in thread
From: Drew Adams @ 2015-05-30 17:12 UTC (permalink / raw)
To: 20698
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@gnu.org-20141020195941-icp42t8ttcnud09g
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
`configure --enable-checking=yes,glyphs CPPFLAGS=-DGLYPH_DEBUG=1'
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-05-30 17:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-30 17:12 bug#20698: 25.0.50; REGRESSION in `transpose-sexps' introduced in Emacs 24.4 Drew Adams
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).