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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 24 Sep 2024 16:43:22 +0300

> From: Al Haji-Ali <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 24 Sep 2024 14:12:43 +0100
> 
> 
> 1. Open 'emacs -Q'.
> 2. Paste the following into the scratch buffer
> 
> (progn  
>   (defun test-bug-73446 nil    
>     (let ((buf1 "test1")
>           (buf2 "test2"))
>       (switch-to-buffer (get-buffer-create buf1))
>       (insert (make-string 20 ?H))
>       (goto-char 1)
>       (switch-to-buffer (get-buffer-create buf2))
>     
>       (let ((switch-to-buffer-preserve-window-point t)
>             start before after)
>         (display-buffer buf1 'display-buffer-use-some-window)
>         
>         (with-current-buffer (get-buffer buf1)
>           (setq start (point))
>           (goto-char 10)
>           (setq before (point))
>           (with-current-buffer (get-buffer buf2) ;; some random buffer
>             (read-string "Test: "))
>           (setq after (point)))
>         (list start before after))))
>   (message "%S" (test-bug-73446)))
> 
> 3. Press `C-x c-e` (or call `eval-last-sexp`) 
> 3. Press return when the prompt "Test: " appears.
> 4. I see the output (1 10 1), instead of (1 10 10) as I would expect.

If this is what you do, then it's the expected behavior: test1 is
displayed in another window, and so its window-point overrides what
you do.  See the node "Window Point" in the ELisp manual.

This is not a bug.