unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: "Ryan C. Thompson" <rct@thompsonclan.org>, 37396@debbugs.gnu.org
Subject: bug#37396: 26.3; execute-kbd-macro changes current buffer inside with-temp-buffer and similar forms
Date: Fri, 13 Sep 2019 09:36:49 +0200	[thread overview]
Message-ID: <01061656-2610-ffdf-7915-2408127dcb02@gmx.at> (raw)
In-Reply-To: <83feea9a-66d6-0f02-d0cf-fa90f119c116@thompsonclan.org>

 > When inside a form that temporarily changes the current buffer, such
 > as "with-temp-buffer", running "execute-kbd-macro" appears to switch
 > the current buffer back to whatever buffer was current when the
 > current command started executing.

'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))))

martin





  reply	other threads:[~2019-09-13  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-13  1:18 bug#37396: 26.3; execute-kbd-macro changes current buffer inside with-temp-buffer and similar forms Ryan C. Thompson
2019-09-13  7:36 ` martin rudalics [this message]
2021-01-30  7:35   ` Lars Ingebrigtsen
2021-01-31  6:09     ` Ryan C. Thompson
2021-01-31  7:46       ` Lars Ingebrigtsen

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=01061656-2610-ffdf-7915-2408127dcb02@gmx.at \
    --to=rudalics@gmx.at \
    --cc=37396@debbugs.gnu.org \
    --cc=rct@thompsonclan.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).