From: "Stuart D. Herring" <herring@lanl.gov>
Cc: emacs-devel@gnu.org
Subject: Re: Recursive edits in `save-excursion'
Date: Fri, 29 Sep 2006 16:13:53 -0700 (PDT) [thread overview]
Message-ID: <15159.128.165.0.81.1159571633.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <E1GT7uI-0001YM-8S@fencepost.gnu.org>
> The explanation for this is that save-excursion saves the current
> buffer, but what you set when you switch buffers is the selected
> window's buffer. save-excursion does not restore that. The first
> save-excursion restores the original current buffer but doesn't
> switch to it. The second recursive edit notices that the current
> buffer isn't the same one you've switched to, so it arranges to
> save and restore the current buffer.
So -- just to make sure that I understand correctly -- `recursive-edit'
acts like it was implemented as follows?
(defun recursive-edit ()
"..."
(let ((obuf (unless (eq (current-buffer) (window-buffer))
(current-buffer)))
(set-buffer (window-buffer))
(unwind-protect
(if (eq (catch 'exit (command-loop) nil) t) (signal 'quit nil))
(if (obuf (set-buffer obuf))))))
In other words, it acts like it is a `save-excursion' embedded if and only
if the current buffer and current window's buffer differ? So you could
defeat this by doing something like what follows?
(save-excursion (set-buffer (window-buffer)) (recursive-edit) ...)
My concern is not which buffer is current around this form, or in which
buffer the `recursive-edit' starts, but just that the `...' be evaluated
with the buffer current that was current when the recursive edit was
exited.
I also wonder if it would be profitable to use the original form, but
calling `window-buffer' instead of `current-buffer'?
(save-excursion (recursive-edit) (window-buffer))
A quick test with the 21.3 I have in front of me seems to support my
theory (both of the modified examples work as I would expect). Assuming
I'm correct that they work reliably, is there a reason to prefer one or
the other?
Thanks,
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
next prev parent reply other threads:[~2006-09-29 23:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-25 3:57 Recursive edits in `save-excursion' Stuart D. Herring
2006-09-29 2:15 ` Richard Stallman
2006-09-29 23:13 ` Stuart D. Herring [this message]
2006-10-01 0:03 ` Richard Stallman
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=15159.128.165.0.81.1159571633.squirrel@webmail.lanl.gov \
--to=herring@lanl.gov \
--cc=emacs-devel@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 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.