GNU bug report logs - #73446
29.1; Curious behaviour with with-current-buffer and read-string

Previous Next

Package: emacs;

Reported by: Al Haji-Ali <abdo.haji.ali <at> gmail.com>

Date: Tue, 24 Sep 2024 08:31:02 UTC

Severity: normal

Found in version 29.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 73446 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
Cc: 73446 <at> debbugs.gnu.org
Subject: Re: bug#73446: 29.1; Curious behaviour with with-current-buffer and
 read-string
Date: Tue, 24 Sep 2024 16:43:22 +0300
> From: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
> Cc: 73446 <at> debbugs.gnu.org
> 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.




This bug report was last modified 318 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.