From 1e101a4be420878653f42a9f5e105adfb6690229 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 17 Dec 2012 14:17:06 -0500 Subject: [PATCH] * src/xdisp.c (select_frame_for_redisplay): Use select_window_1 to propagate redisplay's scrolling (if any) to the right window. (redisplay_internal): Use ensure_selected_frame. (display_mode_lines): Complete last fix. * src/window.c (select_window_1): New func, extracted from select_window. (select_window): Use it. * src/window.h (select_window_1): Declare. --- src/ChangeLog | 32 +++++++++++++++++++------------- src/window.c | 22 +++++++++++++++------- src/window.h | 9 +++++---- src/xdisp.c | 24 +++++++++++++----------- 4 files changed, 52 insertions(+), 35 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index acfd5c561b..2eb301bd93 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2012-12-17 Stefan Monnier + + * xdisp.c (select_frame_for_redisplay): Use select_window_1 to + propagate redisplay's scrolling (if any) to the right window. + (redisplay_internal): Use ensure_selected_frame. + (display_mode_lines): Complete last fix. + * window.c (select_window_1): New func, extracted from select_window. + (select_window): Use it. + * window.h (select_window_1): Declare. + 2012-12-17 Eli Zaretskii Emulate Posix ACL APIs on MS-Windows. @@ -42,8 +52,7 @@ * fileio.c (Ffile_acl, Fset_file_acl): New functions. (Fcopy_file): Change last arg to `preserve_extended_attributes' - and copy ACL entries of file in addition to SELinux context if - set. + and copy ACL entries of file in addition to SELinux context if set. (syms_of_fileio): Add `file-acl' and `set-file-acl'. * Makefile.in (LIBACL_LIBS): New macro. @@ -166,7 +175,7 @@ 2012-12-12 Daniel Colascione - * unexcw.c (fixup_executable): use posix_fallocate to ensure that + * unexcw.c (fixup_executable): Use posix_fallocate to ensure that the dumped Emacs is not a sparse file, greatly improving Cygwin "make bootstrap" performance. @@ -235,8 +244,7 @@ * w32fns.c (cache_system_info): Initialize the global hinst variable here so various initialization calls DTRT. - * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused - variables. + * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused variables. (hinst): Remove unneeded extern declaration. (_start): Remove initialization of above variables; remove initialization of hinst, as cache_system_info now does that. @@ -308,8 +316,7 @@ * w32fns.c (w32_wnd_proc): Handle the WM_EMACS_FILENOTIFY message by posting it to the w32_read_socket queue. - * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support - FILE_NOTIFY_EVENT. + * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support FILE_NOTIFY_EVENT. * makefile.w32-in (OBJ2): Add $(BLD)/w32notify.$(O). (GLOBAL_SOURCES): Add w32notify.c @@ -317,8 +324,8 @@ * lisp.h (syms_of_w32notify) [WINDOWSNT]: Add prototype. - * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]: Handle - FILE_NOTIFY_EVENT. + * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]: + Handle FILE_NOTIFY_EVENT. (syms_of_keyboard) [HAVE_NTGUI] : New symbol. (keys_of_keyboard) [WINDOWSNT]: Bind file-notify to w32notify-handle-event by default. @@ -329,8 +336,7 @@ 2012-12-10 Rüdiger Sonderfeld Support for filesystem notifications on GNU/Linux via inotify. - * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add - FILE_NOTIFY_EVENT. + * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add FILE_NOTIFY_EVENT. * lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype. @@ -647,9 +653,9 @@ 2012-12-03 Fabrice Popineau * w32fns.c: Remove prototype of atof. - (syspage_mask): Declared DWORD_PTR, for compatibility with 64-bit + (syspage_mask): Make it DWORD_PTR, for compatibility with 64-bit builds. - (file_dialog_callback): Declared UINT_PTR. + (file_dialog_callback): Make it UINT_PTR. * w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility with 64-bit builds. diff --git a/src/window.c b/src/window.c index 28c3bf9355..3f3d2fa563 100644 --- a/src/window.c +++ b/src/window.c @@ -487,7 +487,6 @@ static Lisp_Object select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) { register struct window *w; - register struct window *ow; struct frame *sf; CHECK_LIVE_WINDOW (window); @@ -523,12 +522,25 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) else fset_selected_window (sf, window); + select_window_1 (window, inhibit_point_swap); + + bset_last_selected_window (XBUFFER (w->buffer), window); + windows_or_buffers_changed++; + return window; +} + +/* Select window with a minimum of fuss, i.e. don't record the change anywhere + (not even for rediaplay's benefit), and assume that the window's frame is + already selected. */ +void +select_window_1 (Lisp_Object window, bool inhibit_point_swap) +{ /* Store the old selected window's buffer's point in pointm of the old selected window. It belongs to that window, and when the window is not selected, must be in the window. */ if (!inhibit_point_swap) { - ow = XWINDOW (selected_window); + struct window *ow = XWINDOW (selected_window); if (! NILP (ow->buffer)) set_marker_both (ow->pointm, ow->buffer, BUF_PT (XBUFFER (ow->buffer)), @@ -536,7 +548,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) } selected_window = window; - bset_last_selected_window (XBUFFER (w->buffer), window); /* Go to the point recorded in the window. This is important when the buffer is in more @@ -544,7 +555,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) redisplay_window has altered point after scrolling, because it makes the change only in the window. */ { - register ptrdiff_t new_point = marker_position (w->pointm); + register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm); if (new_point < BEGV) SET_PT (BEGV); else if (new_point > ZV) @@ -552,9 +563,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) else SET_PT (new_point); } - - windows_or_buffers_changed++; - return window; } DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, diff --git a/src/window.h b/src/window.h index f4f42a25af..716b977116 100644 --- a/src/window.h +++ b/src/window.h @@ -261,7 +261,7 @@ struct window EMACS_INT last_overlay_modified; /* Value of point at that time. Since this is a position in a buffer, - it should be positive. */ + it should be positive. */ ptrdiff_t last_point; /* Scaling factor for the glyph_matrix size calculation in this window. @@ -290,7 +290,7 @@ struct window /* Non-zero if this window is a minibuffer window. */ unsigned mini : 1; - /* Non-zero means must regenerate mode line of this window */ + /* Non-zero means must regenerate mode line of this window. */ unsigned update_mode_line : 1; /* Non-nil if the buffer was "modified" when the window @@ -343,7 +343,7 @@ struct window y-direction (smooth scrolling). */ int vscroll; - /* Z_BYTE - the buffer position of the last glyph in the current matrix of W. + /* Z_BYTE - Buffer position of the last glyph in the current matrix of W. Should be nonnegative, and only valid if window_end_valid is not nil. */ ptrdiff_t window_end_bytepos; }; @@ -934,7 +934,7 @@ extern EMACS_INT minibuf_level; extern int update_mode_lines; /* Nonzero if window sizes or contents have changed since last - redisplay that finished */ + redisplay that finished. */ extern int windows_or_buffers_changed; @@ -978,6 +978,7 @@ struct glyph *get_phys_cursor_glyph (struct window *w); extern Lisp_Object Qwindowp, Qwindow_live_p; extern Lisp_Object Vwindow_list; +extern void select_window_1 (Lisp_Object window, bool inhibit_point_swap); extern struct window *decode_live_window (Lisp_Object); extern struct window *decode_any_window (Lisp_Object); extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool); diff --git a/src/xdisp.c b/src/xdisp.c index f7fc75f8c2..c2789a78ef 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -869,7 +869,6 @@ static void push_it (struct it *, struct text_pos *); static void iterate_out_of_display_property (struct it *); static void pop_it (struct it *); static void sync_frame_with_window_matrix_rows (struct window *); -static void select_frame_for_redisplay (Lisp_Object); static void redisplay_internal (void); static int echo_area_display (int); static void redisplay_windows (Lisp_Object); @@ -1330,7 +1329,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, BVAR (current_buffer, header_line_format)); start_display (&it, w, top); - move_it_to (&it, charpos, -1, it.last_visible_y-1, -1, + move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1, (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); if (charpos >= 0 @@ -1338,7 +1337,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, && IT_CHARPOS (it) >= charpos) /* When scanning backwards under bidi iteration, move_it_to stops at or _before_ CHARPOS, because it stops at or to - the _right_ of the character at CHARPOS. */ + the _right_ of the character at CHARPOS. */ || (it.bidi_p && it.bidi_it.scan_dir == -1 && IT_CHARPOS (it) <= charpos))) { @@ -12966,7 +12965,9 @@ select_frame_for_redisplay (Lisp_Object frame) eassert (FRAMEP (frame) && FRAME_LIVE_P (XFRAME (frame))); selected_frame = frame; - selected_window = XFRAME (frame)->selected_window; + /* If redisplay causes scrolling, it sets point in the window, so we need to + be careful with the selected-window's point handling. */ + select_window_1 (XFRAME (frame)->selected_window, 0); do { for (tail = XFRAME (frame)->param_alist; @@ -13490,10 +13491,8 @@ redisplay_internal (void) if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) { - if (! EQ (frame, selected_frame)) - /* Select the frame, for the sake of frame-local - variables. */ - select_frame_for_redisplay (frame); + /* Select the frame, for the sake of frame-local variables. */ + ensure_selected_frame (frame); /* Mark all the scroll bars to be removed; we'll redeem the ones we want when we redisplay their windows. */ @@ -13790,8 +13789,8 @@ mark_window_display_accurate_1 (struct window *w, int accurate_p) { struct buffer *b = XBUFFER (w->buffer); - w->last_modified = accurate_p ? BUF_MODIFF(b) : 0; - w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF(b) : 0; + w->last_modified = accurate_p ? BUF_MODIFF (b) : 0; + w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0; w->last_had_star = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b); @@ -20360,8 +20359,11 @@ display_mode_lines (struct window *w) Lisp_Object old_frame_selected_window = XFRAME (new_frame)->selected_window; int n = 0; - selected_frame = w->frame; + selected_frame = new_frame; + /* FIXME: If we were to allow the mode-line's computation changing the buffer + or window's point, then we'd need select_window_1 here as well. */ XSETWINDOW (selected_window, w); + XFRAME (new_frame)->selected_window = selected_window; /* These will be set while the mode line specs are processed. */ line_number_displayed = 0; -- 2.20.1