GNU bug report logs - #13122
transpose-subr defeats save-excursion

Previous Next

Package: emacs;

Reported by: Jyothis V <jyothisv <at> gmail.com>

Date: Sat, 8 Dec 2012 07:16:01 UTC

Severity: minor

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: martin rudalics <rudalics <at> gmx.at>
To: Jyothis V <jyothisv <at> gmail.com>
Cc: 13122 <at> debbugs.gnu.org
Subject: bug#13122: save-excursion not saving point
Date: Sat, 08 Dec 2012 12:21:08 +0100
> I wrote the following version of transpose-chars which is supposed to
> always transform the last two chars without moving the point.
> (defun gosmacs-tranpose-chars (n)
>   (interactive "p")
>   (save-excursion
>     (forward-char (- n))
>     (transpose-chars 1)))
>
> The trouble is, even though I have used save-excursion, the point does
> move 2 characters backwards when n=1! For other values of n, this seems to
> be working fine.

This is a limitation (or bug) in the code of `transpose-subr' and
`transpose-subr-1' due to the use of `delete-and-extract-region' (IIRC
transposing mangles `undo' as well.)

martin




This bug report was last modified 6 years and 23 days ago.

Previous Next


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