changeset 10958:c0d821d95739

(Vsame_window_buffer_names, Vsame_window_regexps): New vars. (syms_of_window): Set up Lisp vars. (Fdisplay_buffer): Use those vars--if requested, use current window.
author Richard M. Stallman <rms@gnu.org>
date Sat, 11 Mar 1995 04:40:18 +0000
parents 6d3568e33019
children e43125b71452
files src/window.c
diffstat 1 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Sat Mar 11 04:37:47 1995 +0000
+++ b/src/window.c	Sat Mar 11 04:40:18 1995 +0000
@@ -88,6 +88,12 @@
 /* Function to pop up a special frame.  */
 Lisp_Object Vspecial_display_function;
 
+/* List of buffer *names* for buffers to appear in selected window.  */
+Lisp_Object Vsame_window_buffer_names;
+
+/* List of regexps for buffer names to appear in selected window.  */
+Lisp_Object Vsame_window_regexps;
+
 /* Hook run at end of temp_output_buffer_show.  */
 Lisp_Object Qtemp_buffer_show_hook;
 
@@ -1876,6 +1882,32 @@
       && XBUFFER (XWINDOW (selected_window)->buffer) == XBUFFER (buffer))
     return selected_window;
 
+  /* See if the user has specified this buffer should appear
+     in the selected window.  */
+  if (NILP (not_this_window))
+    {
+      tem = Fmember (XBUFFER (buffer)->name, Vsame_window_buffer_names);
+      if (!NILP (tem))
+	return Fswitch_to_buffer (buffer, Qnil);
+
+      tem = Fassoc (XBUFFER (buffer)->name, Vsame_window_buffer_names);
+      if (!NILP (tem))
+	return Fswitch_to_buffer (buffer, Qnil);
+
+      for (tem = Vsame_window_regexps; CONSP (tem); tem = XCONS (tem)->cdr)
+	{
+	  Lisp_Object car = XCONS (tem)->car;
+	  if (STRINGP (car)
+	      && fast_string_match (car, XBUFFER (buffer)->name) >= 0)
+	    return Fswitch_to_buffer (buffer, Qnil);
+	  else if (CONSP (car)
+		   && STRINGP (XCONS (car)->car)
+		   && fast_string_match (XCONS (car)->car,
+					 XBUFFER (buffer)->name) >= 0)
+	    return Fswitch_to_buffer (buffer, Qnil);
+	}
+    }
+
 #ifdef MULTI_FRAME
   /* If pop_up_frames,
      look for a window showing BUFFER on any visible or iconified frame.  */
@@ -3373,6 +3405,34 @@
 or matches a regexp in `special-display-regexps'.");
   Vspecial_display_function = Qnil;
 
+  DEFVAR_LISP ("same-window-buffer-names", &Vsame_window_buffer_names,
+    "*List of buffer names that should appear in the selected window.\n\
+Displaying one of these buffers using `display-buffer' or `pop-to-buffer'\n\
+switches to it in the selected window, rather than making it appear\n\
+in some other window.
+\n\
+An element of the list can be a cons cell instead of just a string.\n\
+Then the car must be a string, which specifies the buffer name.\n\
+This is for compatibility with `special-display-buffer-names';\n\
+the cdr of the cons cell is ignored.\n\
+\n\
+See also `same-window-regexps'.");
+  Vsame_window_buffer_names = Qnil;
+
+  DEFVAR_LISP ("same-window-regexps", &Vsame_window_regexps,
+    "*List of regexps saying which buffers should appear in the selected window.\n\
+If a buffer name matches one of these regexps, then displaying it\n\
+using `display-buffer' or `pop-to-buffer' switches to it\n\
+in the selected window, rather than making it appear in some other window.\n\
+\n\
+An element of the list can be a cons cell instead of just a string.\n\
+Then the car must be a string, which specifies the buffer name.\n\
+This is for compatibility with `special-display-buffer-names';\n\
+the cdr of the cons cell is ignored.\n\
+\n\
+See also `same-window-buffer-names'.");
+  Vsame_window_regexps = Qnil;
+
   DEFVAR_BOOL ("pop-up-windows", &pop_up_windows,
     "*Non-nil means display-buffer should make new windows.");
   pop_up_windows = 1;