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: Tino Calancha <tino.calancha <at> gmail.com>
To: 13122 <at> debbugs.gnu.org
Subject: bug#13122: save-excursion not saving point
Date: Sat, 27 Apr 2019 04:53:56 +0900

;; Following expression should eval as non-nil
(let ((pos 3))
  (with-temp-buffer
    (insert "abcdef")
    (goto-char pos)
    (save-excursion (transpose-chars 2))
    (= pos (point))))
=> nil

In GNU Emacs 27.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2019-04-23 built on calancha-pc.dy.bbexcite.jp
Repository revision: 981470e3590534a4d2947dfe5626cae832c6502d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description: Debian GNU/Linux 9 (stretch)


Jyothis V <jyothisv <at> gmail.com> writes:


> 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.
>
> Regards,
> Jyothis V
>
> In GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.6.2)
>  of 2012-11-18 on eric
> Windowing system distributor `The X.Org Foundation', version 11.0.11300000




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.