Commit fec89261 authored by Martin Rudalics's avatar Martin Rudalics
Browse files

(Fget_buffer_window, Fdelete_windows_on, Freplace_buffer_in_windows):

Make buffer argument optional and rename to buffer_or_name.
parent c6ec96f8
2008-10-25 Martin Rudalics <rudalics@gmx.at>
* window.c (Fget_buffer_window, Fdelete_windows_on)
(Freplace_buffer_in_windows): Make buffer argument optional and
rename to buffer_or_name.
2008-10-24 Chong Yidong <cyd@stupidchicken.com> 2008-10-24 Chong Yidong <cyd@stupidchicken.com>
   
* xdisp.c (handle_single_display_spec, handle_display_prop): Undo * xdisp.c (handle_single_display_spec, handle_display_prop): Undo
......
...@@ -2414,18 +2414,25 @@ If FRAME is a frame, search only that frame. */) ...@@ -2414,18 +2414,25 @@ If FRAME is a frame, search only that frame. */)
frame); frame);
} }
DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 1, 2, 0, DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 0, 2, 0,
doc: /* Return a window currently displaying BUFFER, or nil if none. doc: /* Return a window currently displaying BUFFER-OR-NAME, or nil if none.
BUFFER can be a buffer or a buffer name. BUFFER-OR-NAME may be a buffer or a buffer name and defaults to the
current buffer.
If optional argument FRAME is `visible', search all visible frames. If optional argument FRAME is `visible', search all visible frames.
If optional argument FRAME is 0, search all visible and iconified frames. If optional argument FRAME is 0, search all visible and iconified frames.
If FRAME is t, search all frames. If FRAME is t, search all frames.
If FRAME is nil, search only the selected frame. If FRAME is nil, search only the selected frame.
If FRAME is a frame, search only that frame. */) If FRAME is a frame, search only that frame. */)
(buffer, frame) (buffer_or_name, frame)
Lisp_Object buffer, frame; Lisp_Object buffer_or_name, frame;
{ {
buffer = Fget_buffer (buffer); Lisp_Object buffer;
if (NILP (buffer_or_name))
buffer = Fcurrent_buffer ();
else
buffer = Fget_buffer (buffer_or_name);
if (BUFFERP (buffer)) if (BUFFERP (buffer))
return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame); return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame);
else else
...@@ -2436,12 +2443,11 @@ DEFUN ("delete-other-windows", Fdelete_other_windows, Sdelete_other_windows, ...@@ -2436,12 +2443,11 @@ DEFUN ("delete-other-windows", Fdelete_other_windows, Sdelete_other_windows,
0, 1, "", 0, 1, "",
doc: /* Make WINDOW (or the selected window) fill its frame. doc: /* Make WINDOW (or the selected window) fill its frame.
Only the frame WINDOW is on is affected. Only the frame WINDOW is on is affected.
This function tries to reduce display jumps This function tries to reduce display jumps by keeping the text
by keeping the text previously visible in WINDOW previously visible in WINDOW in the same place on the frame. Doing this
in the same place on the frame. Doing this depends on depends on the value of (window-start WINDOW), so if calling this
the value of (window-start WINDOW), so if calling this function function in a program gives strange scrolling, make sure the
in a program gives strange scrolling, make sure the window-start window-start value is reasonable when this function is called. */)
value is reasonable when this function is called. */)
(window) (window)
Lisp_Object window; Lisp_Object window;
{ {
...@@ -2497,20 +2503,24 @@ value is reasonable when this function is called. */) ...@@ -2497,20 +2503,24 @@ value is reasonable when this function is called. */)
} }
DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on, DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on,
1, 2, "bDelete windows on (buffer): ", 0, 2, "bDelete windows on (buffer): ",
doc: /* Delete all windows showing BUFFER. doc: /* Delete all windows showing BUFFER-OR-NAME.
BUFFER must be a buffer or the name of an existing buffer. BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
defaults to the current buffer.
Optional second argument FRAME controls which frames are affected. Optional second argument FRAME controls which frames are affected.
If optional argument FRAME is `visible', search all visible frames. If optional argument FRAME is `visible', search all visible frames.
If FRAME is 0, search all visible and iconified frames. If FRAME is 0, search all visible and iconified frames.
If FRAME is nil, search all frames. If FRAME is nil, search all frames.
If FRAME is t, search only the selected frame. If FRAME is t, search only the selected frame.
If FRAME is a frame, search only that frame. If FRAME is a frame, search only that frame.
When a window showing BUFFER is dedicated and the only window of its When a window showing BUFFER-OR-NAME is dedicated and the only window of
frame, that frame is deleted when there are other frames left. */) its frame, that frame is deleted when there are other frames left. */)
(buffer, frame) (buffer_or_name, frame)
Lisp_Object buffer, frame; Lisp_Object buffer_or_name, frame;
{ {
Lisp_Object buffer;
/* FRAME uses t and nil to mean the opposite of what window_loop /* FRAME uses t and nil to mean the opposite of what window_loop
expects. */ expects. */
if (NILP (frame)) if (NILP (frame))
...@@ -2518,33 +2528,45 @@ frame, that frame is deleted when there are other frames left. */) ...@@ -2518,33 +2528,45 @@ frame, that frame is deleted when there are other frames left. */)
else if (EQ (frame, Qt)) else if (EQ (frame, Qt))
frame = Qnil; frame = Qnil;
if (!NILP (buffer)) if (NILP (buffer_or_name))
buffer = Fcurrent_buffer ();
else
{ {
buffer = Fget_buffer (buffer); buffer = Fget_buffer (buffer_or_name);
CHECK_BUFFER (buffer); CHECK_BUFFER (buffer);
window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, frame);
} }
window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, frame);
return Qnil; return Qnil;
} }
DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows,
Sreplace_buffer_in_windows, Sreplace_buffer_in_windows,
1, 1, "bReplace buffer in windows: ", 0, 1, "bReplace buffer in windows: ",
doc: /* Replace BUFFER with some other buffer in all windows showing it. doc: /* Replace BUFFER-OR-NAME with some other buffer in all windows showing it.
BUFFER may be a buffer or the name of an existing buffer. BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
When a window showing BUFFER is dedicated that window is deleted. When defaults to the current buffer.
that window is the only window on its frame, that frame is deleted too
when there are other frames left. */) When a window showing BUFFER-OR-NAME is dedicated that window is
(buffer) deleted. If that window is the only window on its frame, that frame is
Lisp_Object buffer; deleted too when there are other frames left. If there are no other
{ frames left, some other buffer is displayed in that window. */)
if (!NILP (buffer)) (buffer_or_name)
Lisp_Object buffer_or_name;
{
Lisp_Object buffer;
if (NILP (buffer_or_name))
buffer = Fcurrent_buffer ();
else
{ {
buffer = Fget_buffer (buffer); buffer = Fget_buffer (buffer_or_name);
CHECK_BUFFER (buffer); CHECK_BUFFER (buffer);
window_loop (UNSHOW_BUFFER, buffer, 0, Qt);
} }
window_loop (UNSHOW_BUFFER, buffer, 0, Qt);
return Qnil; return Qnil;
} }
...@@ -3319,7 +3341,7 @@ static Lisp_Object select_window_norecord (Lisp_Object window); ...@@ -3319,7 +3341,7 @@ static Lisp_Object select_window_norecord (Lisp_Object window);
void void
run_window_configuration_change_hook (struct frame *f) run_window_configuration_change_hook (struct frame *f)
{ {
int count = SPECPDL_INDEX (); int count = SPECPDL_INDEX ();
Lisp_Object frame, global_wcch Lisp_Object frame, global_wcch
= Fdefault_value (Qwindow_configuration_change_hook); = Fdefault_value (Qwindow_configuration_change_hook);
XSETFRAME (frame, f); XSETFRAME (frame, f);
...@@ -3327,11 +3349,11 @@ run_window_configuration_change_hook (struct frame *f) ...@@ -3327,11 +3349,11 @@ run_window_configuration_change_hook (struct frame *f)
if (NILP (Vrun_hooks)) if (NILP (Vrun_hooks))
return; return;
if (SELECTED_FRAME () != f) if (SELECTED_FRAME () != f)
{ {
record_unwind_protect (Fselect_frame, Fselected_frame ()); record_unwind_protect (Fselect_frame, Fselected_frame ());
Fselect_frame (frame); Fselect_frame (frame);
} }
/* Use the right buffer. Matters when running the local hooks. */ /* Use the right buffer. Matters when running the local hooks. */
if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) if (current_buffer != XBUFFER (Fwindow_buffer (Qnil)))
...@@ -3355,8 +3377,8 @@ run_window_configuration_change_hook (struct frame *f) ...@@ -3355,8 +3377,8 @@ run_window_configuration_change_hook (struct frame *f)
select_window_norecord (window); select_window_norecord (window);
run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook,
buffer)); buffer));
unbind_to (count, Qnil); unbind_to (count, Qnil);
} }
} }
} }
...@@ -3476,7 +3498,7 @@ WINDOW defaults to the selected window. BUFFER-OR-NAME must be a buffer ...@@ -3476,7 +3498,7 @@ WINDOW defaults to the selected window. BUFFER-OR-NAME must be a buffer
or the name of an existing buffer. Optional third argument KEEP-MARGINS or the name of an existing buffer. Optional third argument KEEP-MARGINS
non-nil means that WINDOW's current display margins, fringe widths, and non-nil means that WINDOW's current display margins, fringe widths, and
scroll bar settings are preserved; the default is to reset these from scroll bar settings are preserved; the default is to reset these from
the local settings for BUFFER-OR-NAME or the frame defaults. Return nil the local settings for BUFFER-OR-NAME or the frame defaults. Return nil.
This function throws an error when WINDOW is dedicated to its buffer and This function throws an error when WINDOW is dedicated to its buffer and
does not already display BUFFER-OR-NAME. does not already display BUFFER-OR-NAME.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment