Subject: Re: Description of `buffer-swap-text' is vague and inadequate.

From: Stefan Monnier <[email-masked]>
Date: Thu, 01 Oct 2009 09:56:00 -0400

> The Elisp manual page "Swapping Text", says that `buffer-swap-text'
> "swaps text between the current buffer and its argument BUFFER."

> This tells me nothing.  I'd have to read the source (or maybe try it
> out) to find out what this function does.

> What does "swap" mean here?  How much text is "swapped".  What does
> "between" mean?

> A naive guess would suggest this command takes a bit of text out of
> buffer A and dumps it into buffer B, simultaneously moving a bit of B
> into A.

No, it swaps the whole freakin' text, including text-properties,
markers, and overlays.  So at the end, buffer A has buffer B's text and
vice versa.

> There is also no entry in .../src/ChangeLog (or ChangeLog.10, ...)
> marking the introduction of this command.

grep disagrees:

   % grep buffer.swap.text src/ChangeLog*
   src/ChangeLog:  * buffer.c (Fbuffer_swap_text): Use POINTER_TYPE.
   src/ChangeLog:  * buffer.c (Fbuffer_swap_text) [REL_ALLOC]: Reset ralloc's internal
   src/ChangeLog:  * buffer.c (Fbuffer_swap_text): Signal error if swapping a dead buffer.
   src/ChangeLog:  * buffer.c (Fbuffer_swap_text): Remove redundant marker manipulation.
   src/ChangeLog:  * buffer.c (Fbuffer_swap_text): Reset window->point markers.
   src/ChangeLog:  * buffer.c (Fbuffer_swap_text): New function.
   % 

-- Stefan