From: Uday S Reddy <u.s.reddy@cs.bham.ac.uk>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: `save-exursion' makes a comeback!
Date: Wed, 16 Mar 2011 12:48:08 +0000 [thread overview]
Message-ID: <19840.45448.609000.620645@gargle.gargle.HOWL> (raw)
In-Reply-To: <mailman.3.1300201687.14512.help-gnu-emacs@gnu.org>
[Despite David's admonition, I would like to extend this thread
because it is a slightly different slant on the original debate. It
seems to me that this also the first time that Drew has said something
positive about how he would like to use `save-excursion' (rather than
just complaining about the compiler).]
> Pun-summary: `save-excursion' makes a comeback!
>
> That's all that can or need ever be said about it.
"comeback" is a very different application of `save-excursion' from
that described in the ELisp manual.
Going back to the manual first, the Section 30.2 sets out the "motion
commands" to be used for moving the point and Section 30.3 sets out
the additional stuff you use to handle "excursions". Excursions are,
in the words of the manual, temporary point movements within a
*localized* portion of the program (or to switch buffers
temporarily). Such excursions are to be placed in a `save-excursion'
form. So, the manual distinguishes between permanent point movements,
which you handle normally, and temporary pont movements, which you
place inside a `save-excursion' form.
The idea of "comeback" seems to be quite different. It suggests that
no distinctions will be made in the code between permanent movements
of the point and temporary movements. They will all be handled as if
they were permanent. However, a top-level save-excursion (which was
my term for "comeback") will ensure that you will return to the
original point in the current buffer.
As long as your code is dealing with a single buffer, this seems like
a reasonable way to develop your program (though it is not something I
would recommend). Moreover, if you are dealing with a single buffer,
you won't have any `set-buffer' in your code. So, the compiler will
leave you in peace. The warning won't arise.
But, if your code is dealing with multiple buffers, then the top-level
save-excursion, i.e., "comback", will only restore the point in the
current buffer, not the other buffers you might have switched to
temporarily. The point in all the other buffers might move. If the
user cares about the other buffers or if your own code does
modifications to the contents in the other buffers, then the "comback"
idea can lead to quite chaotic results.
If you have an application where
- the point is moved in the current buffer, but not other buffers, or
- the point movement in all buffers other than the current buffers is
unimportant,
then the "comback" idea might be suitable. But these seem to be very
specialized applications. For most Emacs developers, all the buffers
are equally important and random point movements in them would need to
be avoided.
Cheers,
Uday
next prev parent reply other threads:[~2011-03-16 12:48 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
[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 [this message]
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=19840.45448.609000.620645@gargle.gargle.HOWL \
--to=u.s.reddy@cs.bham.ac.uk \
--cc=drew.adams@oracle.com \
--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.