diff options
| author | Martin Rudalics | 2008-10-25 07:57:37 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2008-10-25 07:57:37 +0000 |
| commit | fec89261155d2e57ec33a27bd87d8f7d0ee5135b (patch) | |
| tree | 606d4f850f2fb652754d97529c3ab5e12ba3c07c /src | |
| parent | c6ec96f84a64513eaa05ea0247ef651152a71b7e (diff) | |
| download | emacs-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')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/window.c | 108 |
2 files changed, 71 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7176a2aa6ec..4ee8bcbe77f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-10-25 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.c (Fget_buffer_window, Fdelete_windows_on) | ||
| 4 | (Freplace_buffer_in_windows): Make buffer argument optional and | ||
| 5 | rename to buffer_or_name. | ||
| 6 | |||
| 1 | 2008-10-24 Chong Yidong <cyd@stupidchicken.com> | 7 | 2008-10-24 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 8 | ||
| 3 | * xdisp.c (handle_single_display_spec, handle_display_prop): Undo | 9 | * xdisp.c (handle_single_display_spec, handle_display_prop): Undo |
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 | ||
| 2417 | DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 1, 2, 0, | 2417 | DEFUN ("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. |
| 2419 | BUFFER can be a buffer or a buffer name. | 2419 | BUFFER-OR-NAME may be a buffer or a buffer name and defaults to the |
| 2420 | current buffer. | ||
| 2420 | If optional argument FRAME is `visible', search all visible frames. | 2421 | If optional argument FRAME is `visible', search all visible frames. |
| 2421 | If optional argument FRAME is 0, search all visible and iconified frames. | 2422 | If optional argument FRAME is 0, search all visible and iconified frames. |
| 2422 | If FRAME is t, search all frames. | 2423 | If FRAME is t, search all frames. |
| 2423 | If FRAME is nil, search only the selected frame. | 2424 | If FRAME is nil, search only the selected frame. |
| 2424 | If FRAME is a frame, search only that frame. */) | 2425 | If 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. |
| 2438 | Only the frame WINDOW is on is affected. | 2445 | Only the frame WINDOW is on is affected. |
| 2439 | This function tries to reduce display jumps | 2446 | This function tries to reduce display jumps by keeping the text |
| 2440 | by keeping the text previously visible in WINDOW | 2447 | previously visible in WINDOW in the same place on the frame. Doing this |
| 2441 | in the same place on the frame. Doing this depends on | 2448 | depends on the value of (window-start WINDOW), so if calling this |
| 2442 | the value of (window-start WINDOW), so if calling this function | 2449 | function in a program gives strange scrolling, make sure the |
| 2443 | in a program gives strange scrolling, make sure the window-start | 2450 | window-start value is reasonable when this function is called. */) |
| 2444 | value 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 | ||
| 2499 | DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on, | 2505 | DEFUN ("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. |
| 2502 | BUFFER must be a buffer or the name of an existing buffer. | 2508 | BUFFER-OR-NAME may be a buffer or the name of an existing buffer and |
| 2509 | defaults to the current buffer. | ||
| 2510 | |||
| 2503 | Optional second argument FRAME controls which frames are affected. | 2511 | Optional second argument FRAME controls which frames are affected. |
| 2504 | If optional argument FRAME is `visible', search all visible frames. | 2512 | If optional argument FRAME is `visible', search all visible frames. |
| 2505 | If FRAME is 0, search all visible and iconified frames. | 2513 | If FRAME is 0, search all visible and iconified frames. |
| 2506 | If FRAME is nil, search all frames. | 2514 | If FRAME is nil, search all frames. |
| 2507 | If FRAME is t, search only the selected frame. | 2515 | If FRAME is t, search only the selected frame. |
| 2508 | If FRAME is a frame, search only that frame. | 2516 | If FRAME is a frame, search only that frame. |
| 2509 | When a window showing BUFFER is dedicated and the only window of its | 2517 | When a window showing BUFFER-OR-NAME is dedicated and the only window of |
| 2510 | frame, that frame is deleted when there are other frames left. */) | 2518 | its 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 | ||
| 2531 | DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, | 2544 | DEFUN ("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. |
| 2535 | BUFFER may be a buffer or the name of an existing buffer. | 2548 | BUFFER-OR-NAME may be a buffer or the name of an existing buffer and |
| 2536 | When a window showing BUFFER is dedicated that window is deleted. When | 2549 | defaults to the current buffer. |
| 2537 | that window is the only window on its frame, that frame is deleted too | 2550 | |
| 2538 | when there are other frames left. */) | 2551 | When a window showing BUFFER-OR-NAME is dedicated that window is |
| 2539 | (buffer) | 2552 | deleted. If that window is the only window on its frame, that frame is |
| 2540 | Lisp_Object buffer; | 2553 | deleted too when there are other frames left. If there are no other |
| 2541 | { | 2554 | frames 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); | |||
| 3319 | void | 3341 | void |
| 3320 | run_window_configuration_change_hook (struct frame *f) | 3342 | run_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 | |||
| 3476 | or the name of an existing buffer. Optional third argument KEEP-MARGINS | 3498 | or the name of an existing buffer. Optional third argument KEEP-MARGINS |
| 3477 | non-nil means that WINDOW's current display margins, fringe widths, and | 3499 | non-nil means that WINDOW's current display margins, fringe widths, and |
| 3478 | scroll bar settings are preserved; the default is to reset these from | 3500 | scroll bar settings are preserved; the default is to reset these from |
| 3479 | the local settings for BUFFER-OR-NAME or the frame defaults. Return nil | 3501 | the local settings for BUFFER-OR-NAME or the frame defaults. Return nil. |
| 3480 | 3502 | ||
| 3481 | This function throws an error when WINDOW is dedicated to its buffer and | 3503 | This function throws an error when WINDOW is dedicated to its buffer and |
| 3482 | does not already display BUFFER-OR-NAME. | 3504 | does not already display BUFFER-OR-NAME. |