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

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 24 Sep 2024 16:05:02 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
73446: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73446
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#73446: 29.1; Curious behaviour with with-current-buffer and read-string
From: Eli Zaretskii <[email-masked]>
To: Al Haji-Ali <[email-masked]>
Cc: [email-masked]
Date: Tue, 24 Sep 2024 18:50:19 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Al Haji-Ali <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 24 Sep 2024 16:07:42 +0100
> 
> 
> On 24/09/2024, Eli Zaretskii wrote:
> > 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.
> 
> Ah I see. It is interesting that even if the window displaying the
> buffer is shown but seemingly not selected (since the focus is on the
> minibuffer during `read-string`), the point gets reset to the
> window-point when Emacs waits for user input.
> 
> I vote to close this issue and apologies for the noise.

Thanks, I'm closing it.  But there's no need to apologize: Emacs is a
very complex beast, and no one knows all of its subtleties by heart.

Subject: 29.1; Curious behaviour with with-current-buffer and read-string
From: Al Haji-Ali <[email-masked]>
To: [email-masked]
Date: Tue, 24 Sep 2024 09:19:56 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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 easily solve this issue with `save-excursion`, but I thought this might be an unintended behaviour worth reporting.

Best regards,
-- Al