aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2008-06-05 18:00:36 +0000
committerStefan Monnier2008-06-05 18:00:36 +0000
commit87478b52f95d5519a94ed5d0ba95520dd443e752 (patch)
tree81861a7e1e13e25e7d49a77d26dc5f50a5d2a15a /src
parent9e0e0d77da7a2726e7d718d4f303b1f5a6444b28 (diff)
downloademacs-87478b52f95d5519a94ed5d0ba95520dd443e752.tar.gz
emacs-87478b52f95d5519a94ed5d0ba95520dd443e752.zip
* window.el (display-buffer-function, special-display-p)
(special-display-buffer-names, special-display-regexps) (special-display-function, same-window-p, same-window-buffer-names) (same-window-regexps, pop-up-frames, display-buffer-reuse-frames) (pop-up-frame-function, pop-up-windows) (split-window-preferred-function, split-height-threshold) (split-width-threshold, window--splittable-p) (window--try-to-split-window, window--frame-usable-p) (even-window-heights, window--even-window-heights) (window--display-buffer-1, window--display-buffer-2, display-buffer) (pop-to-buffer): Move from window.c and buffer.c. (split-window-preferred-horizontally): Remove. * cus-start.el: Remove corresponding declarations. * window.c (pop_up_windows, pop_up_frames) (display_buffer_reuse_frames, Vpop_up_frame_function) (Vdisplay_buffer_function, Veven_window_heights) (Vspecial_display_buffer_names, Vspecial_display_regexps) (Vspecial_display_function, Vsame_window_buffer_names) (Vsame_window_regexps, split_height_threshold) (Vsplit_window_preferred_function): Move those vars to window.el. (display_buffer_1, Fspecial_display_p, Fsame_window_p) (Fdisplay_buffer): Move those functions to window.el. (syms_of_window): Remove corresponding declarations. (display_buffer): New function. (temp_output_buffer_show, Fother_window_for_scrolling): Use it. * dispnew.c (Flast_nonminibuf_frame): New function. * buffer.c (Fpop_to_buffer): Move to window.el.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/buffer.c37
-rw-r--r--src/dispnew.c12
-rw-r--r--src/lisp.h1
-rw-r--r--src/window.c548
-rw-r--r--src/window.h1
6 files changed, 40 insertions, 576 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9c026552cd3..d04d1b81c33 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,20 @@
12008-06-05 Martin Rudalics <rudalics@gmx.at>
2
3 * window.c (pop_up_windows, pop_up_frames)
4 (display_buffer_reuse_frames, Vpop_up_frame_function)
5 (Vdisplay_buffer_function, Veven_window_heights)
6 (Vspecial_display_buffer_names, Vspecial_display_regexps)
7 (Vspecial_display_function, Vsame_window_buffer_names)
8 (Vsame_window_regexps, split_height_threshold)
9 (Vsplit_window_preferred_function): Move those vars to window.el.
10 (display_buffer_1, Fspecial_display_p, Fsame_window_p)
11 (Fdisplay_buffer): Move those functions to window.el.
12 (syms_of_window): Remove corresponding declarations.
13 (display_buffer): New function.
14 (temp_output_buffer_show, Fother_window_for_scrolling): Use it.
15 * dispnew.c (Flast_nonminibuf_frame): New function.
16 * buffer.c (Fpop_to_buffer): Move to window.el.
17
12008-06-05 Stefan Monnier <monnier@iro.umontreal.ca> 182008-06-05 Stefan Monnier <monnier@iro.umontreal.ca>
2 19
3 * data.c (set_internal): Fix up call to let_shadows_buffer_binding_p. 20 * data.c (set_internal): Fix up call to let_shadows_buffer_binding_p.
diff --git a/src/buffer.c b/src/buffer.c
index 86ba8263ab1..bafcb020e8d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1811,42 +1811,6 @@ the window-buffer correspondences. */)
1811 return switch_to_buffer_1 (buffer, norecord); 1811 return switch_to_buffer_1 (buffer, norecord);
1812} 1812}
1813 1813
1814DEFUN ("pop-to-buffer", Fpop_to_buffer, Spop_to_buffer, 1, 3, 0,
1815 doc: /* Select buffer BUFFER in some window, preferably a different one.
1816BUFFER may be a buffer, a string \(a buffer name), or nil.
1817If BUFFER is a string which is not the name of an existing buffer,
1818then this function creates a buffer with that name.
1819If BUFFER is nil, then it chooses some other buffer.
1820If `pop-up-windows' is non-nil, windows can be split to do this.
1821If optional second arg OTHER-WINDOW is non-nil, insist on finding another
1822window even if BUFFER is already visible in the selected window,
1823and ignore `same-window-regexps' and `same-window-buffer-names'.
1824This function returns the buffer it switched to.
1825This uses the function `display-buffer' as a subroutine; see the documentation
1826of `display-buffer' for additional customization information.
1827
1828Optional third arg NORECORD non-nil means
1829do not put this buffer at the front of the list of recently selected ones. */)
1830 (buffer, other_window, norecord)
1831 Lisp_Object buffer, other_window, norecord;
1832{
1833 register Lisp_Object buf;
1834 if (NILP (buffer))
1835 buf = Fother_buffer (Fcurrent_buffer (), Qnil, Qnil);
1836 else
1837 {
1838 buf = Fget_buffer (buffer);
1839 if (NILP (buf))
1840 {
1841 buf = Fget_buffer_create (buffer);
1842 Fset_buffer_major_mode (buf);
1843 }
1844 }
1845 Fset_buffer (buf);
1846 Fselect_window (Fdisplay_buffer (buf, other_window, Qnil), norecord);
1847 return buf;
1848}
1849
1850DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0, 1814DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0,
1851 doc: /* Return the current buffer as a Lisp object. */) 1815 doc: /* Return the current buffer as a Lisp object. */)
1852 () 1816 ()
@@ -6269,7 +6233,6 @@ The function `kill-all-local-variables' runs this before doing anything else. *
6269 defsubr (&Skill_buffer); 6233 defsubr (&Skill_buffer);
6270 defsubr (&Sset_buffer_major_mode); 6234 defsubr (&Sset_buffer_major_mode);
6271 defsubr (&Sswitch_to_buffer); 6235 defsubr (&Sswitch_to_buffer);
6272 defsubr (&Spop_to_buffer);
6273 defsubr (&Scurrent_buffer); 6236 defsubr (&Scurrent_buffer);
6274 defsubr (&Sset_buffer); 6237 defsubr (&Sset_buffer);
6275 defsubr (&Sbarf_if_buffer_read_only); 6238 defsubr (&Sbarf_if_buffer_read_only);
diff --git a/src/dispnew.c b/src/dispnew.c
index 82541987908..0867c2eccbe 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -7061,6 +7061,17 @@ WINDOW nil or omitted means report on the selected window. */)
7061 return w->cursor_off_p ? Qnil : Qt; 7061 return w->cursor_off_p ? Qnil : Qt;
7062} 7062}
7063 7063
7064DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame,
7065 Slast_nonminibuf_frame, 0, 0, 0,
7066 doc: /* Value is last nonminibuffer frame. */)
7067 ()
7068{
7069 Lisp_Object frame;
7070
7071 XSETFRAME (frame, last_nonminibuf_frame);
7072
7073 return frame;
7074}
7064 7075
7065/*********************************************************************** 7076/***********************************************************************
7066 Initialization 7077 Initialization
@@ -7079,6 +7090,7 @@ syms_of_display ()
7079 defsubr (&Ssend_string_to_terminal); 7090 defsubr (&Ssend_string_to_terminal);
7080 defsubr (&Sinternal_show_cursor); 7091 defsubr (&Sinternal_show_cursor);
7081 defsubr (&Sinternal_show_cursor_p); 7092 defsubr (&Sinternal_show_cursor_p);
7093 defsubr (&Slast_nonminibuf_frame);
7082 7094
7083#if GLYPH_DEBUG 7095#if GLYPH_DEBUG
7084 defsubr (&Sdump_redisplay_history); 7096 defsubr (&Sdump_redisplay_history);
diff --git a/src/lisp.h b/src/lisp.h
index b512fb3c657..bdbfe43ba19 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2865,7 +2865,6 @@ EXFUN (set_buffer_if_live, 1);
2865EXFUN (Fbarf_if_buffer_read_only, 0); 2865EXFUN (Fbarf_if_buffer_read_only, 0);
2866EXFUN (Fcurrent_buffer, 0); 2866EXFUN (Fcurrent_buffer, 0);
2867EXFUN (Fswitch_to_buffer, 2); 2867EXFUN (Fswitch_to_buffer, 2);
2868EXFUN (Fpop_to_buffer, 3);
2869EXFUN (Fother_buffer, 3); 2868EXFUN (Fother_buffer, 3);
2870EXFUN (Foverlay_get, 2); 2869EXFUN (Foverlay_get, 2);
2871EXFUN (Fbuffer_modified_p, 1); 2870EXFUN (Fbuffer_modified_p, 1);
diff --git a/src/window.c b/src/window.c
index 9385b307b9e..7af0c6db711 100644
--- a/src/window.c
+++ b/src/window.c
@@ -52,8 +52,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
52 52
53 53
54Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; 54Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
55Lisp_Object Qdisplay_buffer;
55Lisp_Object Qscroll_up, Qscroll_down; 56Lisp_Object Qscroll_up, Qscroll_down;
56Lisp_Object Qwindow_size_fixed; 57Lisp_Object Qwindow_size_fixed;
58
57extern Lisp_Object Qleft_margin, Qright_margin; 59extern Lisp_Object Qleft_margin, Qright_margin;
58 60
59static int displayed_window_lines P_ ((struct window *)); 61static int displayed_window_lines P_ ((struct window *));
@@ -139,63 +141,10 @@ int mode_line_in_non_selected_windows;
139EMACS_INT window_min_height; 141EMACS_INT window_min_height;
140EMACS_INT window_min_width; 142EMACS_INT window_min_width;
141 143
142/* Nonzero implies Fdisplay_buffer should create windows. */
143
144int pop_up_windows;
145
146/* Nonzero implies make new frames for Fdisplay_buffer. */
147
148int pop_up_frames;
149
150/* Nonzero means reuse existing frames for displaying buffers. */
151
152int display_buffer_reuse_frames;
153
154/* Non-nil means use this function instead of default */
155
156Lisp_Object Vpop_up_frame_function;
157
158/* Function to call to handle Fdisplay_buffer. */
159
160Lisp_Object Vdisplay_buffer_function;
161
162/* Non-nil means that Fdisplay_buffer should even the heights of windows. */
163
164Lisp_Object Veven_window_heights;
165
166/* List of buffer *names* for buffers that should have their own frames. */
167
168Lisp_Object Vspecial_display_buffer_names;
169
170/* List of regexps for buffer names that should have their own frames. */
171
172Lisp_Object Vspecial_display_regexps;
173
174/* Function to pop up a special frame. */
175
176Lisp_Object Vspecial_display_function;
177
178/* List of buffer *names* for buffers to appear in selected window. */
179
180Lisp_Object Vsame_window_buffer_names;
181
182/* List of regexps for buffer names to appear in selected window. */
183
184Lisp_Object Vsame_window_regexps;
185
186/* Hook run at end of temp_output_buffer_show. */ 144/* Hook run at end of temp_output_buffer_show. */
187 145
188Lisp_Object Qtemp_buffer_show_hook; 146Lisp_Object Qtemp_buffer_show_hook;
189 147
190/* Fdisplay_buffer always splits the largest window
191 if that window is more than this high. */
192
193EMACS_INT split_height_threshold;
194
195/* How to split windows (horizontally/vertically/hybrid). */
196
197Lisp_Object Vsplit_window_preferred_function;
198
199/* Number of lines of continuity in scrolling by screenfuls. */ 148/* Number of lines of continuity in scrolling by screenfuls. */
200 149
201EMACS_INT next_screen_context_lines; 150EMACS_INT next_screen_context_lines;
@@ -3639,339 +3588,13 @@ select_window_norecord (window)
3639 return Fselect_window (window, Qt); 3588 return Fselect_window (window, Qt);
3640} 3589}
3641 3590
3642/* Deiconify the frame containing the window WINDOW, 3591Lisp_Object
3643 unless it is the selected frame; 3592display_buffer (buffer, not_this_window_p, override_frame)
3644 then return WINDOW. 3593 Lisp_Object buffer, not_this_window_p, override_frame;
3645
3646 The reason for the exception for the selected frame
3647 is that it seems better not to change the selected frames visibility
3648 merely because of displaying a different buffer in it.
3649 The deiconification is useful when a buffer gets shown in
3650 another frame that you were not using lately. */
3651
3652static Lisp_Object
3653display_buffer_1 (window)
3654 Lisp_Object window;
3655{ 3594{
3656 Lisp_Object frame = XWINDOW (window)->frame; 3595 return call3 (Qdisplay_buffer, buffer, not_this_window_p, override_frame);
3657 FRAME_PTR f = XFRAME (frame);
3658
3659 FRAME_SAMPLE_VISIBILITY (f);
3660
3661 if (EQ (frame, selected_frame))
3662 ; /* Assume the selected frame is already visible enough. */
3663 else if (minibuf_level > 0
3664 && MINI_WINDOW_P (XWINDOW (selected_window))
3665 && WINDOW_LIVE_P (minibuf_selected_window)
3666 && EQ (frame, WINDOW_FRAME (XWINDOW (minibuf_selected_window))))
3667 ; /* Assume the frame from which we invoked the minibuffer is visible. */
3668 else
3669 {
3670 if (FRAME_ICONIFIED_P (f))
3671 Fmake_frame_visible (frame);
3672 else if (FRAME_VISIBLE_P (f))
3673 Fraise_frame (frame);
3674 }
3675
3676 return window;
3677} 3596}
3678 3597
3679DEFUN ("special-display-p", Fspecial_display_p, Sspecial_display_p, 1, 1, 0,
3680 doc: /* Returns non-nil if a buffer named BUFFER-NAME gets a special frame.
3681If the value is t, `display-buffer' or `pop-to-buffer' would create a
3682special frame for that buffer using the default frame parameters.
3683
3684If the value is a list, it is a list of frame parameters that would be used
3685to make a frame for that buffer.
3686The variables `special-display-buffer-names'
3687and `special-display-regexps' control this. */)
3688 (buffer_name)
3689 Lisp_Object buffer_name;
3690{
3691 Lisp_Object tem;
3692
3693 CHECK_STRING (buffer_name);
3694
3695 tem = Fmember (buffer_name, Vspecial_display_buffer_names);
3696 if (!NILP (tem))
3697 return Qt;
3698
3699 tem = Fassoc (buffer_name, Vspecial_display_buffer_names);
3700 if (!NILP (tem))
3701 return XCDR (tem);
3702
3703 for (tem = Vspecial_display_regexps; CONSP (tem); tem = XCDR (tem))
3704 {
3705 Lisp_Object car = XCAR (tem);
3706 if (STRINGP (car)
3707 && fast_string_match (car, buffer_name) >= 0)
3708 return Qt;
3709 else if (CONSP (car)
3710 && STRINGP (XCAR (car))
3711 && fast_string_match (XCAR (car), buffer_name) >= 0)
3712 return XCDR (car);
3713 }
3714 return Qnil;
3715}
3716
3717DEFUN ("same-window-p", Fsame_window_p, Ssame_window_p, 1, 1, 0,
3718 doc: /* Returns non-nil if a buffer named BUFFER-NAME would use the same window.
3719More precisely, if `display-buffer' or `pop-to-buffer' would display
3720that buffer in the selected window rather than (as usual) in some other window.
3721See `same-window-buffer-names' and `same-window-regexps'. */)
3722 (buffer_name)
3723 Lisp_Object buffer_name;
3724{
3725 Lisp_Object tem;
3726
3727 CHECK_STRING (buffer_name);
3728
3729 tem = Fmember (buffer_name, Vsame_window_buffer_names);
3730 if (!NILP (tem))
3731 return Qt;
3732
3733 tem = Fassoc (buffer_name, Vsame_window_buffer_names);
3734 if (!NILP (tem))
3735 return Qt;
3736
3737 for (tem = Vsame_window_regexps; CONSP (tem); tem = XCDR (tem))
3738 {
3739 Lisp_Object car = XCAR (tem);
3740 if (STRINGP (car)
3741 && fast_string_match (car, buffer_name) >= 0)
3742 return Qt;
3743 else if (CONSP (car)
3744 && STRINGP (XCAR (car))
3745 && fast_string_match (XCAR (car), buffer_name) >= 0)
3746 return Qt;
3747 }
3748 return Qnil;
3749}
3750
3751/* Use B so the default is (other-buffer). */
3752DEFUN ("display-buffer", Fdisplay_buffer, Sdisplay_buffer, 1, 3,
3753 "BDisplay buffer: \nP",
3754 doc: /* Make BUFFER appear in some window but don't select it.
3755BUFFER must be the name of an existing buffer, or, when called from Lisp,
3756a buffer.
3757If BUFFER is shown already in some window, just use that one,
3758unless the window is the selected window and the optional second
3759argument NOT-THIS-WINDOW is non-nil (interactively, with prefix arg).
3760If `pop-up-frames' is non-nil, make a new frame if no window shows BUFFER.
3761Returns the window displaying BUFFER.
3762If `display-buffer-reuse-frames' is non-nil, and another frame is currently
3763displaying BUFFER, then simply raise that frame.
3764
3765The variables `special-display-buffer-names',
3766`special-display-regexps', `same-window-buffer-names', and
3767`same-window-regexps' customize how certain buffer names are handled.
3768The latter two take effect only if NOT-THIS-WINDOW is nil.
3769
3770If optional argument FRAME is `visible', check all visible frames
3771for a window to use.
3772If FRAME is 0, check all visible and iconified frames.
3773If FRAME is t, check all frames.
3774If FRAME is a frame, check only that frame.
3775If FRAME is nil, check only the selected frame
3776 (actually the last nonminibuffer frame),
3777 unless `pop-up-frames' or `display-buffer-reuse-frames' is non-nil,
3778 which means search visible and iconified frames.
3779
3780If a full-width window on a splittable frame is available to display
3781the buffer, it may be split, subject to the value of the variable
3782`split-height-threshold'.
3783
3784If `even-window-heights' is non-nil, window heights will be evened out
3785if displaying the buffer causes two vertically adjacent windows to be
3786displayed. */)
3787 (buffer, not_this_window, frame)
3788 Lisp_Object buffer, not_this_window, frame;
3789{
3790 register Lisp_Object window, tem, swp;
3791 struct frame *f;
3792
3793 swp = Qnil;
3794 buffer = Fget_buffer (buffer);
3795 CHECK_BUFFER (buffer);
3796
3797 if (!NILP (Vdisplay_buffer_function))
3798 return call2 (Vdisplay_buffer_function, buffer, not_this_window);
3799
3800 if (NILP (not_this_window)
3801 && XBUFFER (XWINDOW (selected_window)->buffer) == XBUFFER (buffer))
3802 return display_buffer_1 (selected_window);
3803
3804 /* See if the user has specified this buffer should appear
3805 in the selected window. */
3806 if (NILP (not_this_window))
3807 {
3808 swp = Fsame_window_p (XBUFFER (buffer)->name);
3809 if (!NILP (swp) && !no_switch_window (selected_window))
3810 {
3811 Fswitch_to_buffer (buffer, Qnil);
3812 return display_buffer_1 (selected_window);
3813 }
3814 }
3815
3816 /* If the user wants pop-up-frames or display-buffer-reuse-frames,
3817 look for a window showing BUFFER on any visible or iconified frame.
3818 Otherwise search only the current frame. */
3819 if (! NILP (frame))
3820 tem = frame;
3821 else if (pop_up_frames
3822 || display_buffer_reuse_frames
3823 || last_nonminibuf_frame == 0)
3824 XSETFASTINT (tem, 0);
3825 else
3826 XSETFRAME (tem, last_nonminibuf_frame);
3827
3828 window = Fget_buffer_window (buffer, tem);
3829 if (!NILP (window)
3830 && (NILP (not_this_window) || !EQ (window, selected_window)))
3831 return display_buffer_1 (window);
3832
3833 /* Certain buffer names get special handling. */
3834 if (!NILP (Vspecial_display_function) && NILP (swp))
3835 {
3836 tem = Fspecial_display_p (XBUFFER (buffer)->name);
3837 if (EQ (tem, Qt))
3838 return call1 (Vspecial_display_function, buffer);
3839 if (CONSP (tem))
3840 return call2 (Vspecial_display_function, buffer, tem);
3841 }
3842
3843 /* If there are no frames open that have more than a minibuffer,
3844 we need to create a new frame. */
3845 if (pop_up_frames || last_nonminibuf_frame == 0)
3846 {
3847 window = Fframe_selected_window (call0 (Vpop_up_frame_function));
3848 Fset_window_buffer (window, buffer, Qnil);
3849 return display_buffer_1 (window);
3850 }
3851
3852 f = SELECTED_FRAME ();
3853 if (pop_up_windows
3854 || FRAME_MINIBUF_ONLY_P (f)
3855 /* If the current frame is a special display frame,
3856 don't try to reuse its windows. */
3857 || !NILP (XWINDOW (FRAME_ROOT_WINDOW (f))->dedicated))
3858 {
3859 Lisp_Object frames;
3860 struct gcpro gcpro1;
3861 GCPRO1 (buffer);
3862
3863 frames = Qnil;
3864 if (FRAME_MINIBUF_ONLY_P (f))
3865 XSETFRAME (frames, last_nonminibuf_frame);
3866
3867 /* Note that both Fget_largest_window and Fget_lru_window
3868 ignore minibuffers and dedicated windows.
3869 This means they can return nil. */
3870
3871 /* If the frame we would try to split cannot be split,
3872 try other frames. */
3873 if (FRAME_NO_SPLIT_P (NILP (frames) ? f : last_nonminibuf_frame))
3874 {
3875 /* Try visible frames first. */
3876 window = Fget_largest_window (Qvisible, Qt);
3877 /* If that didn't work, try iconified frames. */
3878 if (NILP (window))
3879 window = Fget_largest_window (make_number (0), Qt);
3880#if 0 /* Don't try windows on other displays. */
3881 if (NILP (window))
3882 window = Fget_largest_window (Qt, Qt);
3883#endif
3884 }
3885 else
3886 window = Fget_largest_window (frames, Qt);
3887
3888 tem = Qnil;
3889 if (!NILP (Vsplit_window_preferred_function))
3890 tem = call1 (Vsplit_window_preferred_function, window);
3891
3892 if (!NILP (tem))
3893 window = tem;
3894 else
3895 /* If the largest window is tall enough, full-width, and either eligible
3896 for splitting or the only window, split it. */
3897 if (!NILP (window)
3898 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3899 && WINDOW_FULL_WIDTH_P (XWINDOW (window))
3900 && (window_height (window) >= split_height_threshold
3901 || (NILP (XWINDOW (window)->parent)))
3902 && (window_height (window)
3903 >= (2 * window_min_size_2 (XWINDOW (window), 0, 0))))
3904 window = Fsplit_window (window, Qnil, Qnil);
3905 else
3906 {
3907 Lisp_Object upper, other;
3908
3909 window = Fget_lru_window (frames, Qt);
3910 /* If the LRU window is tall enough, and either eligible for
3911 splitting and selected or the only window, split it. */
3912 if (!NILP (window)
3913 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3914 && ((EQ (window, selected_window)
3915 && window_height (window) >= split_height_threshold)
3916 || (NILP (XWINDOW (window)->parent)))
3917 && (window_height (window)
3918 >= (2 * window_min_size_2 (XWINDOW (window), 0, 0))))
3919 window = Fsplit_window (window, Qnil, Qnil);
3920 else
3921 window = Fget_lru_window (frames, Qnil);
3922 /* If Fget_lru_window returned nil, try other approaches. */
3923
3924 /* Try visible frames first. */
3925 if (NILP (window))
3926 window = Fget_buffer_window (buffer, Qvisible);
3927 if (NILP (window))
3928 window = Fget_largest_window (Qvisible, Qnil);
3929 /* If that didn't work, try iconified frames. */
3930 if (NILP (window))
3931 window = Fget_buffer_window (buffer, make_number (0));
3932 if (NILP (window))
3933 window = Fget_largest_window (make_number (0), Qnil);
3934
3935#if 0 /* Don't try frames on other displays. */
3936 if (NILP (window))
3937 window = Fget_buffer_window (buffer, Qt);
3938 if (NILP (window))
3939 window = Fget_largest_window (Qt, Qnil);
3940#endif
3941 /* As a last resort, make a new frame. */
3942 if (NILP (window))
3943 window = Fframe_selected_window (call0 (Vpop_up_frame_function));
3944 /* If window appears above or below another,
3945 even out their heights. */
3946 other = upper = Qnil;
3947 if (!NILP (XWINDOW (window)->prev))
3948 other = upper = XWINDOW (window)->prev;
3949 if (!NILP (XWINDOW (window)->next))
3950 other = XWINDOW (window)->next, upper = window;
3951 if (!NILP (other)
3952 && !NILP (Veven_window_heights)
3953 /* Check that OTHER and WINDOW are vertically arrayed. */
3954 && !EQ (XWINDOW (other)->top_line, XWINDOW (window)->top_line)
3955 && (XFASTINT (XWINDOW (other)->total_lines)
3956 > XFASTINT (XWINDOW (window)->total_lines)))
3957 {
3958 int total = (XFASTINT (XWINDOW (other)->total_lines)
3959 + XFASTINT (XWINDOW (window)->total_lines));
3960 enlarge_window (upper,
3961 total / 2 - XFASTINT (XWINDOW (upper)->total_lines),
3962 0);
3963 }
3964 }
3965 UNGCPRO;
3966 }
3967 else
3968 window = Fget_lru_window (Qnil, Qnil);
3969
3970 Fset_window_buffer (window, buffer, Qnil);
3971 return display_buffer_1 (window);
3972}
3973
3974
3975DEFUN ("force-window-update", Fforce_window_update, Sforce_window_update, 3598DEFUN ("force-window-update", Fforce_window_update, Sforce_window_update,
3976 0, 1, 0, 3599 0, 1, 0,
3977 doc: /* Force all windows to be updated on next redisplay. 3600 doc: /* Force all windows to be updated on next redisplay.
@@ -4041,7 +3664,7 @@ temp_output_buffer_show (buf)
4041 call1 (Vtemp_buffer_show_function, buf); 3664 call1 (Vtemp_buffer_show_function, buf);
4042 else 3665 else
4043 { 3666 {
4044 window = Fdisplay_buffer (buf, Qnil, Qnil); 3667 window = display_buffer (buf, Qnil, Qnil);
4045 3668
4046 if (!EQ (XWINDOW (window)->frame, selected_frame)) 3669 if (!EQ (XWINDOW (window)->frame, selected_frame))
4047 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); 3670 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window)));
@@ -5692,7 +5315,7 @@ specifies the window. This takes precedence over
5692 { 5315 {
5693 window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil); 5316 window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil);
5694 if (NILP (window)) 5317 if (NILP (window))
5695 window = Fdisplay_buffer (Vother_window_scroll_buffer, Qt, Qnil); 5318 window = display_buffer (Vother_window_scroll_buffer, Qt, Qnil);
5696 } 5319 }
5697 else 5320 else
5698 { 5321 {
@@ -7453,6 +7076,9 @@ syms_of_window ()
7453 Qwindow_live_p = intern ("window-live-p"); 7076 Qwindow_live_p = intern ("window-live-p");
7454 staticpro (&Qwindow_live_p); 7077 staticpro (&Qwindow_live_p);
7455 7078
7079 Qdisplay_buffer = intern ("display-buffer");
7080 staticpro (&Qdisplay_buffer);
7081
7456 Qtemp_buffer_show_hook = intern ("temp-buffer-show-hook"); 7082 Qtemp_buffer_show_hook = intern ("temp-buffer-show-hook");
7457 staticpro (&Qtemp_buffer_show_hook); 7083 staticpro (&Qtemp_buffer_show_hook);
7458 7084
@@ -7474,21 +7100,6 @@ If this function is used, then it must do the entire job of showing
7474the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */); 7100the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */);
7475 Vtemp_buffer_show_function = Qnil; 7101 Vtemp_buffer_show_function = Qnil;
7476 7102
7477 DEFVAR_LISP ("display-buffer-function", &Vdisplay_buffer_function,
7478 doc: /* If non-nil, function to call to handle `display-buffer'.
7479It will receive two args, the buffer and a flag which if non-nil means
7480that the currently selected window is not acceptable.
7481It should choose or create a window, display the specified buffer in it,
7482and return the window.
7483Commands such as `switch-to-buffer-other-window' and `find-file-other-window'
7484work using this function. */);
7485 Vdisplay_buffer_function = Qnil;
7486
7487 DEFVAR_LISP ("even-window-heights", &Veven_window_heights,
7488 doc: /* *If non-nil, `display-buffer' should even the window heights.
7489If nil, `display-buffer' will leave the window configuration alone. */);
7490 Veven_window_heights = Qt;
7491
7492 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window, 7103 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window,
7493 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */); 7104 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */);
7494 Vminibuf_scroll_window = Qnil; 7105 Vminibuf_scroll_window = Qnil;
@@ -7503,148 +7114,14 @@ is displayed in the `mode-line' face. */);
7503 doc: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */); 7114 doc: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */);
7504 Vother_window_scroll_buffer = Qnil; 7115 Vother_window_scroll_buffer = Qnil;
7505 7116
7506 DEFVAR_BOOL ("pop-up-frames", &pop_up_frames,
7507 doc: /* *Non-nil means `display-buffer' should make a separate frame. */);
7508 pop_up_frames = 0;
7509
7510 DEFVAR_BOOL ("auto-window-vscroll", &auto_window_vscroll_p, 7117 DEFVAR_BOOL ("auto-window-vscroll", &auto_window_vscroll_p,
7511 doc: /* *Non-nil means to automatically adjust `window-vscroll' to view tall lines. */); 7118 doc: /* *Non-nil means to automatically adjust `window-vscroll' to view tall lines. */);
7512 auto_window_vscroll_p = 1; 7119 auto_window_vscroll_p = 1;
7513 7120
7514 DEFVAR_BOOL ("display-buffer-reuse-frames", &display_buffer_reuse_frames,
7515 doc: /* *Non-nil means `display-buffer' should reuse frames.
7516If the buffer in question is already displayed in a frame, raise that frame. */);
7517 display_buffer_reuse_frames = 0;
7518
7519 DEFVAR_LISP ("pop-up-frame-function", &Vpop_up_frame_function,
7520 doc: /* Function to call to handle automatic new frame creation.
7521It is called with no arguments and should return a newly created frame.
7522
7523A typical value might be `(lambda () (new-frame pop-up-frame-alist))'
7524where `pop-up-frame-alist' would hold the default frame parameters. */);
7525 Vpop_up_frame_function = Qnil;
7526
7527 DEFVAR_LISP ("special-display-buffer-names", &Vspecial_display_buffer_names,
7528 doc: /* *List of buffer names that should have their own special frames.
7529Displaying a buffer with `display-buffer' or `pop-to-buffer',
7530if its name is in this list, makes a special frame for it
7531using `special-display-function'. See also `special-display-regexps'.
7532
7533An element of the list can be a list instead of just a string.
7534There are two ways to use a list as an element:
7535 (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...)
7536In the first case, the FRAME-PARAMETERS are pairs of the form
7537\(PARAMETER . VALUE); these parameter values are used to create the frame.
7538In the second case, FUNCTION is called with BUFFER as the first argument,
7539followed by the OTHER-ARGS--it can display BUFFER in any way it likes.
7540All this is done by the function found in `special-display-function'.
7541
7542If the specified frame parameters include (same-buffer . t), the
7543buffer is displayed in the currently selected window. Otherwise, if
7544they include (same-frame . t), the buffer is displayed in a new window
7545in the currently selected frame.
7546
7547If this variable appears \"not to work\", because you add a name to it
7548but that buffer still appears in the selected window, look at the
7549values of `same-window-buffer-names' and `same-window-regexps'.
7550Those variables take precedence over this one. */);
7551 Vspecial_display_buffer_names = Qnil;
7552
7553 DEFVAR_LISP ("special-display-regexps", &Vspecial_display_regexps,
7554 doc: /* *List of regexps saying which buffers should have their own special frames.
7555When displaying a buffer with `display-buffer' or `pop-to-buffer',
7556if any regexp in this list matches the buffer name, it makes a
7557special frame for the buffer by calling `special-display-function'.
7558
7559An element of the list can be a list instead of just a string.
7560There are two ways to use a list as an element:
7561 (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...)
7562In the first case, the FRAME-PARAMETERS are pairs of the form
7563\(PARAMETER . VALUE); these parameter values are used to create the frame.
7564In the second case, FUNCTION is called with BUFFER as the first argument,
7565followed by the OTHER-ARGS--it can display the buffer in any way it likes.
7566All this is done by the function found in `special-display-function'.
7567
7568If the specified frame parameters include (same-buffer . t), the
7569buffer is displayed in the currently selected window. Otherwise, if
7570they include (same-frame . t), the buffer is displayed in a new window
7571in the currently selected frame.
7572
7573If this variable appears \"not to work\", because you add a regexp to it
7574but the matching buffers still appear in the selected window, look at the
7575values of `same-window-buffer-names' and `same-window-regexps'.
7576Those variables take precedence over this one. */);
7577 Vspecial_display_regexps = Qnil;
7578
7579 DEFVAR_LISP ("special-display-function", &Vspecial_display_function,
7580 doc: /* Function to call to make a new frame for a special buffer.
7581It is called with two arguments, the buffer and optional buffer specific
7582data, and should return a window displaying that buffer.
7583The default value normally makes a separate frame for the buffer,
7584 using `special-display-frame-alist' to specify the frame parameters.
7585But if the buffer specific data includes (same-buffer . t) then the
7586 buffer is displayed in the current selected window.
7587Otherwise if it includes (same-frame . t) then the buffer is displayed in
7588 a new window in the currently selected frame.
7589
7590A buffer is special if it is listed in `special-display-buffer-names'
7591or matches a regexp in `special-display-regexps'. */);
7592 Vspecial_display_function = Qnil;
7593
7594 DEFVAR_LISP ("same-window-buffer-names", &Vsame_window_buffer_names,
7595 doc: /* *List of buffer names that should appear in the selected window.
7596Displaying one of these buffers using `display-buffer' or `pop-to-buffer'
7597switches to it in the selected window, rather than making it appear
7598in some other window.
7599
7600An element of the list can be a cons cell instead of just a string.
7601Then the car must be a string, which specifies the buffer name.
7602This is for compatibility with `special-display-buffer-names';
7603the cdr of the cons cell is ignored.
7604
7605See also `same-window-regexps'. */);
7606 Vsame_window_buffer_names = Qnil;
7607
7608 DEFVAR_LISP ("same-window-regexps", &Vsame_window_regexps,
7609 doc: /* *List of regexps saying which buffers should appear in the selected window.
7610If a buffer name matches one of these regexps, then displaying it
7611using `display-buffer' or `pop-to-buffer' switches to it
7612in the selected window, rather than making it appear in some other window.
7613
7614An element of the list can be a cons cell instead of just a string.
7615Then the car must be a string, which specifies the buffer name.
7616This is for compatibility with `special-display-buffer-names';
7617the cdr of the cons cell is ignored.
7618
7619See also `same-window-buffer-names'. */);
7620 Vsame_window_regexps = Qnil;
7621
7622 DEFVAR_BOOL ("pop-up-windows", &pop_up_windows,
7623 doc: /* *Non-nil means display-buffer should make new windows. */);
7624 pop_up_windows = 1;
7625
7626 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines, 7121 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines,
7627 doc: /* *Number of lines of continuity when scrolling by screenfuls. */); 7122 doc: /* *Number of lines of continuity when scrolling by screenfuls. */);
7628 next_screen_context_lines = 2; 7123 next_screen_context_lines = 2;
7629 7124
7630 DEFVAR_INT ("split-height-threshold", &split_height_threshold,
7631 doc: /* *A window must be at least this tall to be eligible for splitting
7632by `display-buffer'. The value is in line units.
7633If there is only one window, it is split regardless of this value. */);
7634 split_height_threshold = 500;
7635
7636 DEFVAR_LISP ("split-window-preferred-function",
7637 &Vsplit_window_preferred_function,
7638 doc: /* Function to use to split a window.
7639This is used by `display-buffer' to allow the user to choose whether
7640to split windows horizontally or vertically or some mix of the two.
7641When this variable is nil, `display-buffer' splits windows vertically.
7642Otherwise, `display-buffer' calls this function to split a window.
7643It is called with a window as single argument and should split it in two
7644and return the new window, or return an appropriate existing window
7645if splitting is not eligible. */);
7646 Vsplit_window_preferred_function = Qnil;
7647
7648 DEFVAR_INT ("window-min-height", &window_min_height, 7125 DEFVAR_INT ("window-min-height", &window_min_height,
7649 doc: /* Allow deleting windows less than this tall. 7126 doc: /* Allow deleting windows less than this tall.
7650The value is measured in line units. If a window wants a modeline it 7127The value is measured in line units. If a window wants a modeline it
@@ -7724,9 +7201,6 @@ with the relevant frame selected. */);
7724 defsubr (&Sdelete_window); 7201 defsubr (&Sdelete_window);
7725 defsubr (&Sset_window_buffer); 7202 defsubr (&Sset_window_buffer);
7726 defsubr (&Sselect_window); 7203 defsubr (&Sselect_window);
7727 defsubr (&Sspecial_display_p);
7728 defsubr (&Ssame_window_p);
7729 defsubr (&Sdisplay_buffer);
7730 defsubr (&Sforce_window_update); 7204 defsubr (&Sforce_window_update);
7731 defsubr (&Ssplit_window); 7205 defsubr (&Ssplit_window);
7732 defsubr (&Senlarge_window); 7206 defsubr (&Senlarge_window);
diff --git a/src/window.h b/src/window.h
index 0b38c5c8696..6c148d99cea 100644
--- a/src/window.h
+++ b/src/window.h
@@ -760,7 +760,6 @@ extern Lisp_Object Vmouse_event;
760 760
761EXFUN (Fnext_window, 3); 761EXFUN (Fnext_window, 3);
762EXFUN (Fselect_window, 2); 762EXFUN (Fselect_window, 2);
763EXFUN (Fdisplay_buffer, 3);
764EXFUN (Fset_window_buffer, 3); 763EXFUN (Fset_window_buffer, 3);
765EXFUN (Fset_window_hscroll, 2); 764EXFUN (Fset_window_hscroll, 2);
766EXFUN (Fwindow_hscroll, 1); 765EXFUN (Fwindow_hscroll, 1);