aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2018-12-29 10:51:35 +0100
committerMartin Rudalics2018-12-29 10:51:35 +0100
commitfb10834a602416f8422131d5ce9dabcc28e57be4 (patch)
tree40e63548d63cf95658eb33a5cc74f5b318fa9222 /src
parent8f9d93f3054a5a99a760101fa81a013c67d52f58 (diff)
downloademacs-fb10834a602416f8422131d5ce9dabcc28e57be4.tar.gz
emacs-fb10834a602416f8422131d5ce9dabcc28e57be4.zip
Avoid that unwind_format_mode_line messes up buffer points (Bug#32777)
* src/xdisp.c (format_mode_line_unwind_data): Before temporarily selecting a window on another frame, separately save the point of that window's buffer too. (unwind_format_mode_line): After undoing the temporary selection of a window on another frame, separately restore the buffer point of that window. This is needed since the operation that deselects that window will have stored back the point of that window into its buffer's point which is wrong since that window was never "officially" selected (Bug#32777).
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 4201bdc4a75..65a61a0120c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11850,7 +11850,7 @@ format_mode_line_unwind_data (struct frame *target_frame,
11850 Vmode_line_unwind_vector = Qnil; 11850 Vmode_line_unwind_vector = Qnil;
11851 11851
11852 if (NILP (vector)) 11852 if (NILP (vector))
11853 vector = make_nil_vector (10); 11853 vector = make_nil_vector (12);
11854 11854
11855 ASET (vector, 0, make_fixnum (mode_line_target)); 11855 ASET (vector, 0, make_fixnum (mode_line_target));
11856 ASET (vector, 1, make_fixnum (MODE_LINE_NOPROP_LEN (0))); 11856 ASET (vector, 1, make_fixnum (MODE_LINE_NOPROP_LEN (0)));
@@ -11867,12 +11867,24 @@ format_mode_line_unwind_data (struct frame *target_frame,
11867 ASET (vector, 7, owin); 11867 ASET (vector, 7, owin);
11868 if (target_frame) 11868 if (target_frame)
11869 { 11869 {
11870 Lisp_Object buffer = XWINDOW (target_frame->selected_window)->contents;
11871 struct buffer *b = XBUFFER (buffer);
11872 struct buffer *cb = current_buffer;
11873
11870 /* Similarly to `with-selected-window', if the operation selects 11874 /* Similarly to `with-selected-window', if the operation selects
11871 a window on another frame, we must restore that frame's 11875 a window on another frame, we must restore that frame's
11872 selected window, and (for a tty) the top-frame. */ 11876 selected window, and (for a tty) the top-frame. */
11873 ASET (vector, 8, target_frame->selected_window); 11877 ASET (vector, 8, target_frame->selected_window);
11874 if (FRAME_TERMCAP_P (target_frame)) 11878 if (FRAME_TERMCAP_P (target_frame))
11875 ASET (vector, 9, FRAME_TTY (target_frame)->top_frame); 11879 ASET (vector, 9, FRAME_TTY (target_frame)->top_frame);
11880
11881 /* If we select a window on another frame, make sure that that
11882 selection does not leave its buffer's point modified when
11883 unwinding (Bug#32777). */
11884 ASET (vector, 10, buffer);
11885 current_buffer = b;
11886 ASET (vector, 11, build_marker (current_buffer, PT, PT_BYTE));
11887 current_buffer = cb;
11876 } 11888 }
11877 11889
11878 return vector; 11890 return vector;
@@ -11912,6 +11924,24 @@ unwind_format_mode_line (Lisp_Object vector)
11912 } 11924 }
11913 11925
11914 Fselect_window (old_window, Qt); 11926 Fselect_window (old_window, Qt);
11927
11928 /* Restore point of target_frame_window's buffer (Bug#32777).
11929 But do this only after old_window has been reselected to
11930 avoid that the window point of target_frame_window moves. */
11931 if (!NILP (target_frame_window))
11932 {
11933 Lisp_Object buffer = AREF (vector, 10);
11934
11935 if (BUFFER_LIVE_P (XBUFFER (buffer)))
11936 {
11937 struct buffer *cb = current_buffer;
11938
11939 current_buffer = XBUFFER (buffer);
11940 set_point_from_marker (AREF (vector, 11));
11941 ASET (vector, 11, Qnil);
11942 current_buffer = cb;
11943 }
11944 }
11915 } 11945 }
11916 11946
11917 if (!NILP (AREF (vector, 6))) 11947 if (!NILP (AREF (vector, 6)))