all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Al Haji-Ali <abdo.haji.ali@gmail.com>
Cc: 73446@debbugs.gnu.org
Subject: bug#73446: 29.1; Curious behaviour with with-current-buffer and read-string
Date: Tue, 24 Sep 2024 15:12:40 +0300	[thread overview]
Message-ID: <86msjxdzd3.fsf@gnu.org> (raw)
In-Reply-To: <m04j65wjir.fsf@gmail.com> (message from Al Haji-Ali on Tue, 24 Sep 2024 09:19:56 +0100)

> From: Al Haji-Ali <abdo.haji.ali@gmail.com>
> 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.





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

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

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

  git send-email \
    --in-reply-to=86msjxdzd3.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=73446@debbugs.gnu.org \
    --cc=abdo.haji.ali@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.