Subject: bug#14486: 24.3.50; A very subtle/obscure bug - with-temp-buffer + pop-to-buffer + insert

From: Jambunathan K <[email-masked]>
Date: Tue, 28 May 2013 08:16:41 +0530

A very subtle/obscure bug.  I have a hard time explaining the observed
behaviour.

1. emacs -Q
2. In the scratch buffer copy the following snippet and install it.

      (defvar count 1)
      (defun testing ()
        (interactive)
        (forward-line 1)
        (insert (with-temp-buffer
                  (insert (format "string-%d\n" (setq count (+ 1 count))))
                  (pop-to-buffer (current-buffer))
                  (buffer-string))))

3. M->

4. M-x testing
   C-x o

   M-x testing
   C-x o

   M-x testing
   C-x o

5. Expected behaviour: Point should be at the END of the scratch buffer

Observed behaviour: Not as expected.

Now comment out the `pop-to-buffer' in the snippet above, install the
changes and repeat.  You will see that the point is at END of the
scratch buffer.

In GNU Emacs 24.3.50.3 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2013-05-27 on debian-6.05
Bzr revision: 112737 [email-masked]
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
Important settings:
  value of $LANG: en_IN
  locale-coding-system: iso-latin-1-unix
  default enable-multibyte-characters: t