bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37396: 26.3; execute-kbd-macro changes current buffer inside with-te


From: Ryan C. Thompson
Subject: bug#37396: 26.3; execute-kbd-macro changes current buffer inside with-temp-buffer and similar forms
Date: Sun, 31 Jan 2021 01:09:01 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

On 1/30/21 2:35 AM, Lars Ingebrigtsen wrote:
martin rudalics <rudalics@gmx.at> writes:

'execute-kbd-macro' calls command_loop_1 which sets the current buffer
to the buffer shown in the selected window.

For example:

(with-temp-buffer
    (list
     ;; Returns the temp buffer
     (current-buffer)
     (execute-kbd-macro "hello")
     ;; Returns the buffer that was current when evaluation began
     (current-buffer)))
Try with

(with-temp-buffer
   (let ((restore (window-buffer))
        temp)
     (setq temp (current-buffer))
     (set-window-buffer (selected-window) temp)
     (execute-kbd-macro "hello")
     (set-window-buffer (selected-window) restore)
     (list temp (current-buffer))))
So this seems to work as designed, so I'm closing this bug report.  If
there's something to be done here, please respond to the debbugs address
and we'll reopen.

If nothing else, this behavior seems worth noting in the function's docstring, since otherwise there's no way to know about it short of reading the source.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]