/* Buffer manipulation primitives for GNU Emacs.
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994,
1995, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008
+ 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GNU Emacs.
DEFUN ("switch-to-buffer", Fswitch_to_buffer, Sswitch_to_buffer, 1, 2,
"(list (read-buffer-to-switch \"Switch to buffer: \"))",
- doc: /* Make BUFFER-OR-NAME current and display it in the selected window.
-BUFFER-OR-NAME may be a buffer, a string, or nil. If BUFFER-OR-NAME is
-nil, then this function chooses a buffer using `other-buffer'. If
-BUFFER-OR-NAME is a string and does not identify an existing buffer,
-then this function creates a buffer with that name.
+ doc: /* Make BUFFER-OR-NAME current and display it in selected window.
+BUFFER-OR-NAME may be a buffer, a string \(a buffer name), or
+nil. Return the buffer switched to.
-Optional second arg NORECORD non-nil means do not put this buffer at the
-front of the list of recently selected ones. This function returns the
-buffer it switched to as a Lisp object.
+If BUFFER-OR-NAME is a string and does not identify an existing
+buffer, create a new buffer with that name. Interactively, if
+`confirm-nonexistent-file-or-buffer' is non-nil, request
+confirmation before creating a new buffer. If BUFFER-OR-NAME is
+nil, switch to buffer returned by `other-buffer'.
-If the selected window is the minibuffer window or dedicated to its
-buffer, use `pop-to-buffer' for displaying the buffer.
+Optional second arg NORECORD non-nil means do not put this buffer
+at the front of the list of recently selected ones. This
+function returns the buffer it switched to as a Lisp object.
+
+If the selected window is the minibuffer window or dedicated to
+its buffer, use `pop-to-buffer' for displaying the buffer.
WARNING: This is NOT the way to work on another buffer temporarily
-within a Lisp program! Use `set-buffer' instead. That avoids messing
-with the window-buffer correspondences. */)
+within a Lisp program! Use `set-buffer' instead. That avoids
+messing with the window-buffer correspondences. */)
(buffer_or_name, norecord)
Lisp_Object buffer_or_name, norecord;
{
return byte_pos;
}
+#ifdef REL_ALLOC
+extern void r_alloc_reset_variable P_ ((POINTER_TYPE *, POINTER_TYPE *));
+#endif /* REL_ALLOC */
+
DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
1, 1, 0,
doc: /* Swap the text between current buffer and BUFFER. */)
CHECK_BUFFER (buffer);
other_buffer = XBUFFER (buffer);
+ if (NILP (other_buffer->name))
+ error ("Cannot swap a dead buffer's text");
+
/* Actually, it probably works just fine.
* if (other_buffer == current_buffer)
* error ("Cannot swap a buffer's text with itself"); */
swapfield (own_text, struct buffer_text);
eassert (current_buffer->text == ¤t_buffer->own_text);
eassert (other_buffer->text == &other_buffer->own_text);
+#ifdef REL_ALLOC
+ r_alloc_reset_variable ((POINTER_TYPE **) ¤t_buffer->own_text.beg,
+ (POINTER_TYPE **) &other_buffer->own_text.beg);
+ r_alloc_reset_variable ((POINTER_TYPE **) &other_buffer->own_text.beg,
+ (POINTER_TYPE **) ¤t_buffer->own_text.beg);
+#endif /* REL_ALLOC */
+
swapfield (pt, EMACS_INT);
swapfield (pt_byte, EMACS_INT);
swapfield (begv, EMACS_INT);
if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
{
/* Grow buffer to add directory separator and '\0'. */
- pwd = (char *) xrealloc (pwd, len + 2);
+ pwd = (char *) realloc (pwd, len + 2);
+ if (!pwd)
+ fatal ("`get_current_dir_name' failed: %s\n", strerror (errno));
pwd[len] = DIRECTORY_SEP;
pwd[len + 1] = '\0';
}