bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#4655: 23.1.50; buffer-swap-text oddity


From: Markus Rost
Subject: bug#4655: 23.1.50; buffer-swap-text oddity
Date: Wed, 7 Oct 2009 10:53:51 +0200 (CEST)

Juanma wrote:

> I would expect A/A both with and
> without it (and I'm quite surprised to find that it is not so).

Exactly.

> Why do you expect buffer-swap-text to switch the current buffer?

I don't.  See below for the concrete situation which led to my
example.

Stefan wrote:

> 1- markers are swapped along with the buffer texts (with a some
>    exceptions, mostly window-markers).
> 2- save-excursion saves the "position and current buffer" as a marker.

> Combine 1 and 2 together, and you'll see that save-excursion ends up
> changing the current buffer.

That explains what happened, thanks.  But 2- is not obvious from the
documentation of save-excursion.  And the conclusion "save-excursion
ends up changing the current buffer" is very, very surprising.

Since I am not the only one to be surprised, it seems to me that if
save-excursion/buffer-swap-text keeps having this behavior, it should
be documented, perhaps with a warning for lisp programmers.

==========

Here is the concrete scenario which induced my buffer-swap-text
example:  I have set

(defadvice rmail-cease-edit (after update-rmail-summary preactivate)
  "Recompute Summary-line immediately."
  (rmail-summary))

I expected this to behave like hitting 'h' after editing an rmail
buffer.  But I get an error:

rmail-new-summary: No RMAIL buffer found

The reason is that rmail-cease-edit contains the piece

    (save-excursion
      (rmail-show-message)
      (rmail-toggle-header (if pruned 1 0))))

and rmail-show-message has some buffer/text swapping in it.  Moreover,
the swap partner rmail-view-buffer (an odd name by the way) doesn't
know its rmail-buffer (maybe it should?), so calling rmail-summary
from it triggers the error.

==========

On a general note:  Thank you for all the great developments in Emacs
22/23.

Markus





reply via email to

[Prev in Thread] Current Thread [Next in Thread]