aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2011-06-07 15:23:08 +0200
committerMartin Rudalics2011-06-07 15:23:08 +0200
commit190b47e683f61b30533bcc548f8be9d3b861029e (patch)
tree0cf48df3e7dba31caad6abe2a81e0f5936ff5c4e /src
parentfa8a67e67454a900e4cf7b93fed96f27ea41b1b8 (diff)
downloademacs-190b47e683f61b30533bcc548f8be9d3b861029e.tar.gz
emacs-190b47e683f61b30533bcc548f8be9d3b861029e.zip
Move get-lru-window and get-largest-window to window.el.
* window.c (window_loop): Remove handling of GET_LRU_WINDOW and GET_LARGEST_WINDOW. (Fget_lru_window, Fget_largest_window): Move to window.el. * window.el (get-lru-window, get-largest-window): Move here from window.c. Rename first argument to ALL-FRAMES. Rephrase doc-strings. (get-buffer-window-list): Rewrite using window-list-1. Rephrase doc-string.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog3
-rw-r--r--src/window.c81
2 files changed, 3 insertions, 81 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c7bcdec0512..435b5ea7468 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -10,6 +10,9 @@
10 delete_all_subwindows with window as argument. 10 delete_all_subwindows with window as argument.
11 (delete_all_subwindows): Take a window as argument and not a 11 (delete_all_subwindows): Take a window as argument and not a
12 structure. Rewrite. 12 structure. Rewrite.
13 (window_loop): Remove handling of GET_LRU_WINDOW and
14 GET_LARGEST_WINDOW.
15 (Fget_lru_window, Fget_largest_window): Move to window.el.
13 16
14 * window.h: Extern window_body_cols instead of 17 * window.h: Extern window_body_cols instead of
15 window_box_text_cols. delete_all_subwindows now takes a 18 window_box_text_cols. delete_all_subwindows now takes a
diff --git a/src/window.c b/src/window.c
index ee62f57ee07..5b95db634a0 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2487,10 +2487,8 @@ enum window_loop
2487{ 2487{
2488 WINDOW_LOOP_UNUSED, 2488 WINDOW_LOOP_UNUSED,
2489 GET_BUFFER_WINDOW, /* Arg is buffer */ 2489 GET_BUFFER_WINDOW, /* Arg is buffer */
2490 GET_LRU_WINDOW, /* Arg is t for full-width windows only */
2491 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */ 2490 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */
2492 DELETE_BUFFER_WINDOWS, /* Arg is buffer */ 2491 DELETE_BUFFER_WINDOWS, /* Arg is buffer */
2493 GET_LARGEST_WINDOW,
2494 UNSHOW_BUFFER, /* Arg is buffer */ 2492 UNSHOW_BUFFER, /* Arg is buffer */
2495 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */ 2493 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */
2496 CHECK_ALL_WINDOWS 2494 CHECK_ALL_WINDOWS
@@ -2573,21 +2571,6 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2573 } 2571 }
2574 break; 2572 break;
2575 2573
2576 case GET_LRU_WINDOW:
2577 /* `obj' is an integer encoding a bitvector.
2578 `obj & 1' means consider only full-width windows.
2579 `obj & 2' means consider also dedicated windows. */
2580 if (((XINT (obj) & 1) && !WINDOW_FULL_WIDTH_P (w))
2581 || (!(XINT (obj) & 2) && !NILP (w->dedicated))
2582 /* Minibuffer windows are always ignored. */
2583 || MINI_WINDOW_P (w))
2584 break;
2585 if (NILP (best_window)
2586 || (XFASTINT (XWINDOW (best_window)->use_time)
2587 > XFASTINT (w->use_time)))
2588 best_window = window;
2589 break;
2590
2591 case DELETE_OTHER_WINDOWS: 2574 case DELETE_OTHER_WINDOWS:
2592 if (!EQ (window, obj)) 2575 if (!EQ (window, obj))
2593 Fdelete_window (window); 2576 Fdelete_window (window);
@@ -2632,24 +2615,6 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2632 } 2615 }
2633 break; 2616 break;
2634 2617
2635 case GET_LARGEST_WINDOW:
2636 { /* nil `obj' means to ignore dedicated windows. */
2637 /* Ignore dedicated windows and minibuffers. */
2638 if (MINI_WINDOW_P (w) || (NILP (obj) && !NILP (w->dedicated)))
2639 break;
2640
2641 if (NILP (best_window))
2642 best_window = window;
2643 else
2644 {
2645 struct window *b = XWINDOW (best_window);
2646 if (XFASTINT (w->total_lines) * XFASTINT (w->total_cols)
2647 > XFASTINT (b->total_lines) * XFASTINT (b->total_cols))
2648 best_window = window;
2649 }
2650 }
2651 break;
2652
2653 case UNSHOW_BUFFER: 2618 case UNSHOW_BUFFER:
2654 if (EQ (w->buffer, obj)) 2619 if (EQ (w->buffer, obj))
2655 { 2620 {
@@ -2740,50 +2705,6 @@ time is the least recently selected one. */)
2740 return decode_window (window)->use_time; 2705 return decode_window (window)->use_time;
2741} 2706}
2742 2707
2743DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 2, 0,
2744 doc: /* Return the window least recently selected or used for display.
2745\(LRU means Least Recently Used.)
2746
2747Return a full-width window if possible.
2748A minibuffer window is never a candidate.
2749A dedicated window is never a candidate, unless DEDICATED is non-nil,
2750 so if all windows are dedicated, the value is nil.
2751If optional argument FRAME is `visible', search all visible frames.
2752If FRAME is 0, search all visible and iconified frames.
2753If FRAME is t, search all frames.
2754If FRAME is nil, search only the selected frame.
2755If FRAME is a frame, search only that frame. */)
2756 (Lisp_Object frame, Lisp_Object dedicated)
2757{
2758 register Lisp_Object w;
2759 /* First try for a window that is full-width */
2760 w = window_loop (GET_LRU_WINDOW,
2761 NILP (dedicated) ? make_number (1) : make_number (3),
2762 0, frame);
2763 if (!NILP (w) && !EQ (w, selected_window))
2764 return w;
2765 /* If none of them, try the rest */
2766 return window_loop (GET_LRU_WINDOW,
2767 NILP (dedicated) ? make_number (0) : make_number (2),
2768 0, frame);
2769}
2770
2771DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 2, 0,
2772 doc: /* Return the largest window in area.
2773A minibuffer window is never a candidate.
2774A dedicated window is never a candidate unless DEDICATED is non-nil,
2775 so if all windows are dedicated, the value is nil.
2776If optional argument FRAME is `visible', search all visible frames.
2777If FRAME is 0, search all visible and iconified frames.
2778If FRAME is t, search all frames.
2779If FRAME is nil, search only the selected frame.
2780If FRAME is a frame, search only that frame. */)
2781 (Lisp_Object frame, Lisp_Object dedicated)
2782{
2783 return window_loop (GET_LARGEST_WINDOW, dedicated, 0,
2784 frame);
2785}
2786
2787DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 0, 2, 0, 2708DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 0, 2, 0,
2788 doc: /* Return a window currently displaying BUFFER-OR-NAME, or nil if none. 2709 doc: /* Return a window currently displaying BUFFER-OR-NAME, or nil if none.
2789BUFFER-OR-NAME may be a buffer or a buffer name and defaults to the 2710BUFFER-OR-NAME may be a buffer or a buffer name and defaults to the
@@ -7431,8 +7352,6 @@ frame to be redrawn only if it is a tty frame. */);
7431 defsubr (&Snext_window); 7352 defsubr (&Snext_window);
7432 defsubr (&Sprevious_window); 7353 defsubr (&Sprevious_window);
7433 defsubr (&Sother_window); 7354 defsubr (&Sother_window);
7434 defsubr (&Sget_lru_window);
7435 defsubr (&Sget_largest_window);
7436 defsubr (&Sget_buffer_window); 7355 defsubr (&Sget_buffer_window);
7437 defsubr (&Sdelete_other_windows); 7356 defsubr (&Sdelete_other_windows);
7438 defsubr (&Sdelete_windows_on); 7357 defsubr (&Sdelete_windows_on);