Subject: bug#73446: 29.1; Curious behaviour with with-current-buffer and read-string

From: Eli Zaretskii <[email-masked]>
Date: Tue, 24 Sep 2024 15:12:40 +0300

> From: Al Haji-Ali <[email-masked]>
> Date: Tue, 24 Sep 2024 09:19:56 +0100
> 
> 
> Consider this code snippet:
> 
> ,----
> | (with-current-buffer (get-buffer "*scratch*")
> |   (message "START point %S %S" (current-buffer) (point))
> |   (goto-char 10)
> |   (message "BEFORE point %S %S" (current-buffer) (point))
> |   (with-current-buffer (get-buffer "*Messages*") ;; some random buffer
> |     (read-string "Test: "))
> |   (message "AFTER point %S %S" (current-buffer) (point)))
> `----
> 
> Assuming that *scratch* has a point at something other than 10 and *is visible in a window*, I get this output in Messages
> 
> ,----
> | START point #<buffer *scratch*> 2952
> | BEFORE point #<buffer *scratch*> 10
> | AFTER point #<buffer *scratch*> 2952
> `----
> 
> I was expecting (point) AFTER to be 100, as it was BEFORE.
> 
> This only happens when `read-string` is called and when `with-current-buffer` is nested, and only when *scratch* is visible in a window.

I can't reproduce this, but see switch-to-buffer-preserve-window-point.