unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: `save-excursion' defeated by `set-buffer'
Date: Sat, 12 Mar 2011 11:42:12 +0100	[thread overview]
Message-ID: <87d3lwr56j.fsf@fencepost.gnu.org> (raw)
In-Reply-To: mailman.10.1299924724.7270.help-gnu-emacs@gnu.org

Eli Zaretskii <eliz@gnu.org> writes:

>> From: David Kastrup <dak@gnu.org>
>> Date: Sat, 12 Mar 2011 10:34:45 +0100
>> 
>> >   Warning: `save-excursion' will not preserve point in the other buffer
>> >   set by `set-buffer'
>> 
>> Is there a particular reason that nobody is interested in letting the
>> warning be about the case that is supposed to be problematic
>
> Huh?  That's what I tried to express in the above text.  Isn't that
> _precisely_ the problematic case, when the other buffer is not the
> current and the body of save-excursion moves point and/or mark there?

No, it isn't.  The likelilood that somebody uses `set-buffer' when he
expects it not to change the current buffer is not exactly large.

> If that's not the problematic case, please cough up why not, rather
> than asking rhetorical questions.
>
>> The problem seems more like
>> 
>> Warning: `save-excursion' will preserve point and mark in the current
>>          buffer even if set-buffer does not actually change buffers.
>
> Your "warning" describes what `save-excursion' is supposed to do, at
> least according to the ELisp manual:
>
>        The `save-excursion' special form saves the identity of the current
>        buffer and the values of point and the mark in it, evaluates BODY,
>        and finally restores the buffer and its saved values of point and
>        the mark.
>
> So how could warning about the normal operation be TRT?

Very funny.  Of course the warning will be about a situation where every
function works according to its specifications.  Otherwise, it would be
reason for either a bug fix or an error message rather than a warning.

Anyway, I suggest you get yourself up to speed by reading a few messages
from Stefan Monnier about his rationale for introducing this warning.

-- 
David Kastrup


  parent reply	other threads:[~2011-03-12 10:42 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.0.1299085819.4487.help-gnu-emacs@gnu.org>
2011-03-02 20:54 ` `save-excursion' defeated by `set-buffer' Uday Reddy
2011-03-05  4:28 ` Stefan Monnier
2011-03-10 19:57   ` Andreas Röhler
2011-03-11  1:07     ` Leo
2011-03-11  1:28     ` Stefan Monnier
2011-03-11  8:52       ` Andreas Röhler
     [not found]       ` <mailman.25.1299833256.26376.help-gnu-emacs@gnu.org>
2011-03-11  9:54         ` David Kastrup
2011-03-11 11:09           ` Andreas Röhler
     [not found]           ` <mailman.10.1299841456.13496.help-gnu-emacs@gnu.org>
2011-03-11 11:38             ` David Kastrup
2011-03-11 15:52         ` Stefan Monnier
2011-03-12  8:59           ` Eli Zaretskii
2011-03-12 19:00             ` Andreas Röhler
2011-03-12 19:56               ` Drew Adams
2011-03-12 20:27                 ` Eli Zaretskii
2011-03-12 22:20                   ` Drew Adams
2011-03-14 18:59                 ` Juanma Barranquero
2011-03-14 21:17                   ` Drew Adams
     [not found]               ` <mailman.6.1299959800.9013.help-gnu-emacs@gnu.org>
2011-03-13  3:00                 ` Uday Reddy
2011-03-13 18:22                   ` Drew Adams
     [not found]                   ` <mailman.0.1300040583.10860.help-gnu-emacs@gnu.org>
2011-03-14  1:04                     ` Uday Reddy
2011-03-14  8:43                       ` Drew Adams
     [not found]             ` <mailman.4.1299956141.9013.help-gnu-emacs@gnu.org>
2011-03-12 22:29               ` Tim X
2011-03-13  7:15                 ` Andreas Röhler
2011-03-13 18:23                   ` Drew Adams
2011-03-13 12:46                 ` Uday S Reddy
2011-03-14  8:47                   ` Drew Adams
     [not found]                   ` <mailman.7.1300092490.2602.help-gnu-emacs@gnu.org>
2011-03-14 12:22                     ` Uday Reddy
2011-03-14 14:20                     ` Uday S Reddy
2011-03-14 17:36                       ` Drew Adams
2011-03-14 23:20                         ` Uday S Reddy
2011-03-15  3:55                           ` Drew Adams
     [not found]                       ` <mailman.14.1300124226.2531.help-gnu-emacs@gnu.org>
2011-03-15 14:39                         ` Stefan Monnier
2011-03-15 15:59                           ` Drew Adams
     [not found]                           ` <mailman.2.1300204800.1264.help-gnu-emacs@gnu.org>
2011-03-15 17:46                             ` Stefan Monnier
2011-03-15 18:55                               ` Drew Adams
2011-03-14 14:18                   ` Andreas Röhler
     [not found]                   ` <mailman.5.1300111985.27831.help-gnu-emacs@gnu.org>
2011-03-14 14:54                     ` Uday Reddy
     [not found]                 ` <mailman.5.1300000253.31664.help-gnu-emacs@gnu.org>
2011-03-13 14:16                   ` Uday Reddy
2011-03-13 18:25                     ` Drew Adams
     [not found]                     ` <mailman.2.1300040743.10860.help-gnu-emacs@gnu.org>
2011-03-13 20:48                       ` Uday Reddy
2011-03-14  0:31                         ` Drew Adams
     [not found]                 ` <mailman.4.1300066631.25374.help-gnu-emacs@gnu.org>
2011-03-14 14:34                   ` Stefan Monnier
2011-03-13  2:11               ` Uday Reddy
2011-03-13 18:26                 ` Drew Adams
     [not found]           ` <mailman.5.1299920357.7270.help-gnu-emacs@gnu.org>
2011-03-12  9:34             ` David Kastrup
2011-03-12 10:12               ` Eli Zaretskii
     [not found]               ` <mailman.10.1299924724.7270.help-gnu-emacs@gnu.org>
2011-03-12 10:42                 ` David Kastrup [this message]
2011-03-12 12:28                   ` Eli Zaretskii
2011-03-12 15:17                   ` Uday Reddy
2011-03-12 15:25                     ` David Kastrup
2011-03-13  2:40                       ` Uday Reddy
2011-03-14 14:25                         ` Stefan Monnier
2011-03-14 17:26                           ` Andreas Röhler
     [not found]                           ` <mailman.11.1300123292.2531.help-gnu-emacs@gnu.org>
2011-03-15 14:35                             ` Stefan Monnier
2011-03-15 14:47                               ` David Kastrup
2011-03-15 15:19                               ` PJ Weisberg
2011-03-15 16:00                               ` Drew Adams
     [not found]                               ` <mailman.6.1300202904.14512.help-gnu-emacs@gnu.org>
2011-03-15 17:42                                 ` Stefan Monnier
     [not found]                               ` <mailman.3.1300204850.1264.help-gnu-emacs@gnu.org>
2011-03-15 17:49                                 ` Stefan Monnier
2011-03-15 18:56                                   ` Drew Adams
2011-03-15 21:30                                     ` Stefan Monnier
2011-03-15 19:02                                   ` Jason Earl
2011-03-15 20:55                                     ` Drew Adams
2011-03-16  4:31                                     ` rusi
2011-03-16  8:11                                       ` David Kastrup
2011-03-17  3:46                                         ` rusi
2011-03-17  7:10                                           ` rusi
2011-03-17  8:29                                             ` Antoine Levitt
     [not found]                                   ` <mailman.1.1300215374.6982.help-gnu-emacs@gnu.org>
2011-03-16 12:05                                     ` Uday S Reddy
2011-03-12 22:18             ` Tim X
2011-03-11 23:06         ` Uday Reddy
2011-03-10 22:40   ` David Kastrup
2011-03-11  2:46     ` Stefan Monnier
2011-04-01  3:20 ` rusi
2011-04-01 12:39   ` Uday Reddy
2011-03-02 17:12 Andreas Röhler
2011-03-03  4:58 ` Le Wang
     [not found] ` <mailman.7.1299128292.20537.help-gnu-emacs@gnu.org>
2011-03-13 15:05   ` Uday Reddy

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=87d3lwr56j.fsf@fencepost.gnu.org \
    --to=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.
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).