unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Al Haji-Ali <abdo.haji.ali@gmail.com>
To: 73446@debbugs.gnu.org
Subject: bug#73446: 29.1; Curious behaviour with with-current-buffer and read-string
Date: Tue, 24 Sep 2024 09:19:56 +0100	[thread overview]
Message-ID: <m04j65wjir.fsf@gmail.com> (raw)


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





             reply	other threads:[~2024-09-24  8:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24  8:19 Al Haji-Ali [this message]
2024-09-24 12:12 ` bug#73446: 29.1; Curious behaviour with with-current-buffer and read-string Eli Zaretskii
2024-09-24 13:12   ` Al Haji-Ali
2024-09-24 13:43     ` Eli Zaretskii
2024-09-24 15:07       ` Al Haji-Ali
2024-09-24 15:50         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m04j65wjir.fsf@gmail.com \
    --to=abdo.haji.ali@gmail.com \
    --cc=73446@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).