all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'David Kastrup'" <dak@gnu.org>, <help-gnu-emacs@gnu.org>
Subject: RE: `save-exursion' makes a comeback!
Date: Tue, 15 Mar 2011 09:02:02 -0700	[thread overview]
Message-ID: <12BFB1D857B848BC862DBEAAC016E686@us.oracle.com> (raw)
In-Reply-To: <87d3lso1a6.fsf@fencepost.gnu.org>

> > Forget about `save-excursion' "saving" or "restoring" or
> > "hiding" or "protecting" anything.  Forget about it "defeating"
> > or being "defeated".  Forget all of that right now.
> >
> > The real name of `save-excursion' is `come-back-here'.
> > Just remember that and Bob's your uncle.
> 
> M-: (with-temp-buffer (let ((b (current-buffer))) (save-excursion
>     (set-buffer "*scratch*") (kill-buffer b))) (current-buffer)) RET

Yes, David.  I explicitly mentioned that case before (though that was no doubt
lost in the bit torrent).  This makes it even clearer, I think:

(defun foo ()
  (interactive)
  (save-excursion
    (message "BEFORE KILL, buf: %S, pt: %S, mark: %S"
	       (current-buffer) (point) (mark))
    (sit-for 2)
    (kill-buffer (current-buffer))
    (message "BEFORE END, buf: %S, pt: %S, mark: %S"
	       (current-buffer) (point) (mark))
    (sit-for 2))
  (message "AFTER, buf: %S, pt: %S, mark: %S"
	     (current-buffer) (point) (mark))
  (sit-for 2))

M-x foo RET

This is no different from your father saying "Come back here!" as you run out
the door, and your then burning down the house so there is no place to come back
to.

Really, this kind of thing just adds confusion to the discussion for most users.
There is nothing special here to do with `save-excursion'.  `save-excursion'
just does an `unwind-protect' to return where you came from.  If in the meantime
you have nuked the place you came from then there is nothing that
`save-excursion', `unwind-protect', or the Emacs god herself can do to bring
your home back.




  reply	other threads:[~2011-03-15 16:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3.1300201687.14512.help-gnu-emacs@gnu.org>
2011-03-15 15:23 ` `save-exursion' makes a comeback! David Kastrup
2011-03-15 16:02   ` Drew Adams [this message]
     [not found]   ` <mailman.4.1300204937.1264.help-gnu-emacs@gnu.org>
2011-03-15 16:11     ` David Kastrup
2011-03-16 12:48 ` Uday S Reddy
2011-03-15 15:07 Drew Adams

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=12BFB1D857B848BC862DBEAAC016E686@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=dak@gnu.org \
    --cc=help-gnu-emacs@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.