static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of;
static Lisp_Object Qfloor, Qceiling;
+static Lisp_Object Qwindow_point_insertion_type;
static int displayed_window_lines (struct window *);
static int count_windows (struct window *);
/* Incremented for each window created. */
static int sequence_number;
-/* Nonzero after init_window_once has finished. */
-static int window_initialized;
-
/* Hook to run when window config changes. */
static Lisp_Object Qwindow_configuration_change_hook;
-/* Used by the function window_scroll_pixel_based */
+/* Used by the function window_scroll_pixel_based. */
static int window_scroll_pixel_based_preserve_x;
static int window_scroll_pixel_based_preserve_y;
DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
doc: /* Select WINDOW which must be a live window.
Also make WINDOW's frame the selected frame and WINDOW that frame's
-selected window. In addition, make WINDOW's buffer current and set that
+selected window. In addition, make WINDOW's buffer current and set its
buffer's value of `point' to the value of WINDOW's `window-point'.
Return WINDOW.
front of the buffer list and do not make this window the most recently
selected one.
-Note that the main editor command loop sets the current buffer to the
-buffer of the selected window before each command. */)
+Run `buffer-list-update-hook' unless NORECORD is non-nil. Note that
+applications and internal routines often select a window temporarily for
+various purposes; mostly, to simplify coding. As a rule, such
+selections should be not recorded and therefore will not pollute
+`buffer-list-update-hook'. Selections that "really count" are those
+causing a visible change in the next redisplay of WINDOW's frame and
+should be always recorded. So if you think of running a function each
+time a window gets selected put it on `buffer-list-update-hook'.
+
+Also note that the main editor command loop sets the current buffer to
+the buffer of the selected window before each command. */)
(register Lisp_Object window, Lisp_Object norecord)
{
return select_window (window, norecord, 0);
doc: /* Return the height of window WINDOW in pixels.
WINDOW must be a valid window and defaults to the selected one.
-The return value includes the mode line and header line, if any. If
-WINDOW is an internal window, its pixel height is the height of the
-screen areas spanned by its children. */)
+The return value includes the mode line and header line and the bottom
+divider, if any. If WINDOW is an internal window, its pixel height is
+the height of the screen areas spanned by its children. */)
(Lisp_Object window)
{
return make_number (decode_valid_window (window)->pixel_height);
wset_redisplay (w);
w->update_mode_line = true;
- /* We must select BUFFER for running the window-scroll-functions. */
- /* We can't check ! NILP (Vwindow_scroll_functions) here
- because that might itself be a local variable. */
- if (window_initialized)
- {
- record_unwind_current_buffer ();
- Fset_buffer (buffer);
- }
+ /* We must select BUFFER to run the window-scroll-functions and to look up
+ the buffer-local value of Vwindow_point_insertion_type. */
+ record_unwind_current_buffer ();
+ Fset_buffer (buffer);
XMARKER (w->pointm)->insertion_type = !NILP (Vwindow_point_insertion_type);
if (MINI_WINDOW_P (XWINDOW (selected_window))
&& !NILP (Vminibuf_scroll_window))
window = Vminibuf_scroll_window;
- /* If buffer is specified, scroll that buffer. */
- else if (!NILP (Vother_window_scroll_buffer))
+ /* If buffer is specified and live, scroll that buffer. */
+ else if (!NILP (Vother_window_scroll_buffer)
+ && BUFFERP (Vother_window_scroll_buffer)
+ && BUFFER_LIVE_P (XBUFFER (Vother_window_scroll_buffer)))
{
window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil);
if (NILP (window))
set_marker_restricted (w->start, p->start, w->contents);
set_marker_restricted (w->pointm, p->pointm,
w->contents);
+ if (MARKERP (p->mark) && !XMARKER (p->mark)->buffer
+ && !NILP (BVAR (XBUFFER (w->contents), mark_active)))
+ {
+ struct buffer *old = current_buffer;
+ extern Lisp_Object Qdeactivate_mark;
+ set_buffer_internal (XBUFFER (w->contents));
+ call0 (Qdeactivate_mark);
+ set_buffer_internal (old);
+ }
Fset_marker (BVAR (XBUFFER (w->contents), mark),
p->mark, w->contents);
else
p->pointm = Fcopy_marker (w->pointm, Qnil);
XMARKER (p->pointm)->insertion_type
- = !NILP (Vwindow_point_insertion_type);
+ = !NILP (buffer_local_value /* Don't signal error if void. */
+ (Qwindow_point_insertion_type, w->contents));
p->start = Fcopy_marker (w->start, Qnil);
p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
Vterminal_frame = selected_frame;
minibuf_window = f->minibuffer_window;
selected_window = f->selected_window;
-
- window_initialized = 1;
}
void
mode_line_in_non_selected_windows = 1;
DEFVAR_LISP ("other-window-scroll-buffer", Vother_window_scroll_buffer,
- doc: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */);
+ doc: /* If this is a live buffer, \\[scroll-other-window] should scroll its window. */);
Vother_window_scroll_buffer = Qnil;
DEFVAR_BOOL ("auto-window-vscroll", auto_window_vscroll_p,
DEFVAR_LISP ("window-point-insertion-type", Vwindow_point_insertion_type,
doc: /* Type of marker to use for `window-point'. */);
Vwindow_point_insertion_type = Qnil;
+ DEFSYM (Qwindow_point_insertion_type, "window_point_insertion_type");
DEFVAR_LISP ("window-configuration-change-hook",
Vwindow_configuration_change_hook,