aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorMartin Rudalics2008-10-25 07:57:37 +0000
committerMartin Rudalics2008-10-25 07:57:37 +0000
commitfec89261155d2e57ec33a27bd87d8f7d0ee5135b (patch)
tree606d4f850f2fb652754d97529c3ab5e12ba3c07c /src/window.c
parentc6ec96f84a64513eaa05ea0247ef651152a71b7e (diff)
downloademacs-fec89261155d2e57ec33a27bd87d8f7d0ee5135b.tar.gz
emacs-fec89261155d2e57ec33a27bd87d8f7d0ee5135b.zip
(Fget_buffer_window, Fdelete_windows_on, Freplace_buffer_in_windows):
Make buffer argument optional and rename to buffer_or_name.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c108
1 files changed, 65 insertions, 43 deletions
diff --git a/src/window.c b/src/window.c
index 36b88cb8678..5931955fd66 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2414,18 +2414,25 @@ If FRAME is a frame, search only that frame. */)
2414 frame); 2414 frame);
2415} 2415}
2416 2416
2417DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 1, 2, 0, 2417DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 0, 2, 0,
2418 doc: /* Return a window currently displaying BUFFER, or nil if none. 2418 doc: /* Return a window currently displaying BUFFER-OR-NAME, or nil if none.
2419BUFFER can be a buffer or a buffer name. 2419BUFFER-OR-NAME may be a buffer or a buffer name and defaults to the
2420current buffer.
2420If optional argument FRAME is `visible', search all visible frames. 2421If optional argument FRAME is `visible', search all visible frames.
2421If optional argument FRAME is 0, search all visible and iconified frames. 2422If optional argument FRAME is 0, search all visible and iconified frames.
2422If FRAME is t, search all frames. 2423If FRAME is t, search all frames.
2423If FRAME is nil, search only the selected frame. 2424If FRAME is nil, search only the selected frame.
2424If FRAME is a frame, search only that frame. */) 2425If FRAME is a frame, search only that frame. */)
2425 (buffer, frame) 2426 (buffer_or_name, frame)
2426 Lisp_Object buffer, frame; 2427 Lisp_Object buffer_or_name, frame;
2427{ 2428{
2428 buffer = Fget_buffer (buffer); 2429 Lisp_Object buffer;
2430
2431 if (NILP (buffer_or_name))
2432 buffer = Fcurrent_buffer ();
2433 else
2434 buffer = Fget_buffer (buffer_or_name);
2435
2429 if (BUFFERP (buffer)) 2436 if (BUFFERP (buffer))
2430 return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame); 2437 return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame);
2431 else 2438 else
@@ -2436,12 +2443,11 @@ DEFUN ("delete-other-windows", Fdelete_other_windows, Sdelete_other_windows,
2436 0, 1, "", 2443 0, 1, "",
2437 doc: /* Make WINDOW (or the selected window) fill its frame. 2444 doc: /* Make WINDOW (or the selected window) fill its frame.
2438Only the frame WINDOW is on is affected. 2445Only the frame WINDOW is on is affected.
2439This function tries to reduce display jumps 2446This function tries to reduce display jumps by keeping the text
2440by keeping the text previously visible in WINDOW 2447previously visible in WINDOW in the same place on the frame. Doing this
2441in the same place on the frame. Doing this depends on 2448depends on the value of (window-start WINDOW), so if calling this
2442the value of (window-start WINDOW), so if calling this function 2449function in a program gives strange scrolling, make sure the
2443in a program gives strange scrolling, make sure the window-start 2450window-start value is reasonable when this function is called. */)
2444value is reasonable when this function is called. */)
2445 (window) 2451 (window)
2446 Lisp_Object window; 2452 Lisp_Object window;
2447{ 2453{
@@ -2497,20 +2503,24 @@ value is reasonable when this function is called. */)
2497} 2503}
2498 2504
2499DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on, 2505DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on,
2500 1, 2, "bDelete windows on (buffer): ", 2506 0, 2, "bDelete windows on (buffer): ",
2501 doc: /* Delete all windows showing BUFFER. 2507 doc: /* Delete all windows showing BUFFER-OR-NAME.
2502BUFFER must be a buffer or the name of an existing buffer. 2508BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
2509defaults to the current buffer.
2510
2503Optional second argument FRAME controls which frames are affected. 2511Optional second argument FRAME controls which frames are affected.
2504If optional argument FRAME is `visible', search all visible frames. 2512If optional argument FRAME is `visible', search all visible frames.
2505If FRAME is 0, search all visible and iconified frames. 2513If FRAME is 0, search all visible and iconified frames.
2506If FRAME is nil, search all frames. 2514If FRAME is nil, search all frames.
2507If FRAME is t, search only the selected frame. 2515If FRAME is t, search only the selected frame.
2508If FRAME is a frame, search only that frame. 2516If FRAME is a frame, search only that frame.
2509When a window showing BUFFER is dedicated and the only window of its 2517When a window showing BUFFER-OR-NAME is dedicated and the only window of
2510frame, that frame is deleted when there are other frames left. */) 2518its frame, that frame is deleted when there are other frames left. */)
2511 (buffer, frame) 2519 (buffer_or_name, frame)
2512 Lisp_Object buffer, frame; 2520 Lisp_Object buffer_or_name, frame;
2513{ 2521{
2522 Lisp_Object buffer;
2523
2514 /* FRAME uses t and nil to mean the opposite of what window_loop 2524 /* FRAME uses t and nil to mean the opposite of what window_loop
2515 expects. */ 2525 expects. */
2516 if (NILP (frame)) 2526 if (NILP (frame))
@@ -2518,33 +2528,45 @@ frame, that frame is deleted when there are other frames left. */)
2518 else if (EQ (frame, Qt)) 2528 else if (EQ (frame, Qt))
2519 frame = Qnil; 2529 frame = Qnil;
2520 2530
2521 if (!NILP (buffer)) 2531 if (NILP (buffer_or_name))
2532 buffer = Fcurrent_buffer ();
2533 else
2522 { 2534 {
2523 buffer = Fget_buffer (buffer); 2535 buffer = Fget_buffer (buffer_or_name);
2524 CHECK_BUFFER (buffer); 2536 CHECK_BUFFER (buffer);
2525 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, frame);
2526 } 2537 }
2527 2538
2539 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, frame);
2540
2528 return Qnil; 2541 return Qnil;
2529} 2542}
2530 2543
2531DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, 2544DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows,
2532 Sreplace_buffer_in_windows, 2545 Sreplace_buffer_in_windows,
2533 1, 1, "bReplace buffer in windows: ", 2546 0, 1, "bReplace buffer in windows: ",
2534 doc: /* Replace BUFFER with some other buffer in all windows showing it. 2547 doc: /* Replace BUFFER-OR-NAME with some other buffer in all windows showing it.
2535BUFFER may be a buffer or the name of an existing buffer. 2548BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
2536When a window showing BUFFER is dedicated that window is deleted. When 2549defaults to the current buffer.
2537that window is the only window on its frame, that frame is deleted too 2550
2538when there are other frames left. */) 2551When a window showing BUFFER-OR-NAME is dedicated that window is
2539 (buffer) 2552deleted. If that window is the only window on its frame, that frame is
2540 Lisp_Object buffer; 2553deleted too when there are other frames left. If there are no other
2541{ 2554frames left, some other buffer is displayed in that window. */)
2542 if (!NILP (buffer)) 2555 (buffer_or_name)
2556 Lisp_Object buffer_or_name;
2557{
2558 Lisp_Object buffer;
2559
2560 if (NILP (buffer_or_name))
2561 buffer = Fcurrent_buffer ();
2562 else
2543 { 2563 {
2544 buffer = Fget_buffer (buffer); 2564 buffer = Fget_buffer (buffer_or_name);
2545 CHECK_BUFFER (buffer); 2565 CHECK_BUFFER (buffer);
2546 window_loop (UNSHOW_BUFFER, buffer, 0, Qt);
2547 } 2566 }
2567
2568 window_loop (UNSHOW_BUFFER, buffer, 0, Qt);
2569
2548 return Qnil; 2570 return Qnil;
2549} 2571}
2550 2572
@@ -3319,7 +3341,7 @@ static Lisp_Object select_window_norecord (Lisp_Object window);
3319void 3341void
3320run_window_configuration_change_hook (struct frame *f) 3342run_window_configuration_change_hook (struct frame *f)
3321{ 3343{
3322 int count = SPECPDL_INDEX (); 3344 int count = SPECPDL_INDEX ();
3323 Lisp_Object frame, global_wcch 3345 Lisp_Object frame, global_wcch
3324 = Fdefault_value (Qwindow_configuration_change_hook); 3346 = Fdefault_value (Qwindow_configuration_change_hook);
3325 XSETFRAME (frame, f); 3347 XSETFRAME (frame, f);
@@ -3327,11 +3349,11 @@ run_window_configuration_change_hook (struct frame *f)
3327 if (NILP (Vrun_hooks)) 3349 if (NILP (Vrun_hooks))
3328 return; 3350 return;
3329 3351
3330 if (SELECTED_FRAME () != f) 3352 if (SELECTED_FRAME () != f)
3331 { 3353 {
3332 record_unwind_protect (Fselect_frame, Fselected_frame ()); 3354 record_unwind_protect (Fselect_frame, Fselected_frame ());
3333 Fselect_frame (frame); 3355 Fselect_frame (frame);
3334 } 3356 }
3335 3357
3336 /* Use the right buffer. Matters when running the local hooks. */ 3358 /* Use the right buffer. Matters when running the local hooks. */
3337 if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) 3359 if (current_buffer != XBUFFER (Fwindow_buffer (Qnil)))
@@ -3355,8 +3377,8 @@ run_window_configuration_change_hook (struct frame *f)
3355 select_window_norecord (window); 3377 select_window_norecord (window);
3356 run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, 3378 run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook,
3357 buffer)); 3379 buffer));
3358 unbind_to (count, Qnil); 3380 unbind_to (count, Qnil);
3359 } 3381 }
3360 } 3382 }
3361 } 3383 }
3362 3384
@@ -3476,7 +3498,7 @@ WINDOW defaults to the selected window. BUFFER-OR-NAME must be a buffer
3476or the name of an existing buffer. Optional third argument KEEP-MARGINS 3498or the name of an existing buffer. Optional third argument KEEP-MARGINS
3477non-nil means that WINDOW's current display margins, fringe widths, and 3499non-nil means that WINDOW's current display margins, fringe widths, and
3478scroll bar settings are preserved; the default is to reset these from 3500scroll bar settings are preserved; the default is to reset these from
3479the local settings for BUFFER-OR-NAME or the frame defaults. Return nil 3501the local settings for BUFFER-OR-NAME or the frame defaults. Return nil.
3480 3502
3481This function throws an error when WINDOW is dedicated to its buffer and 3503This function throws an error when WINDOW is dedicated to its buffer and
3482does not already display BUFFER-OR-NAME. 3504does not already display BUFFER-OR-NAME.