Fix latent side-effects of respecting field boundaries in text conversion
* src/textconv.c (textconv_query, get_extracted_text) (get_surrounding_text): Restore selected window in addition to excursion. (locate_and_save_position_in_field): Restore excursion lest the current buffer differ from the selected window's contents, to prevent redisplay from clobbering the current buffer when called while the current buffer is at variance with the selected window's contents, as seen with dired-other-window.
This commit is contained in:
parent
e4046f33ab
commit
1b4c562721
1 changed files with 16 additions and 9 deletions
|
@ -153,6 +153,15 @@ select_window (Lisp_Object window, Lisp_Object norecord)
|
||||||
Fselect_window (window, norecord);
|
Fselect_window (window, norecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Restore the selected window WINDOW. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
restore_selected_window (Lisp_Object window)
|
||||||
|
{
|
||||||
|
/* FIXME: not sure what to do if WINDOW has been deleted. */
|
||||||
|
select_window (window, Qt);
|
||||||
|
}
|
||||||
|
|
||||||
/* Perform the text conversion operation specified in QUERY and return
|
/* Perform the text conversion operation specified in QUERY and return
|
||||||
the results.
|
the results.
|
||||||
|
|
||||||
|
@ -188,6 +197,7 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query,
|
||||||
selected window. */
|
selected window. */
|
||||||
count = SPECPDL_INDEX ();
|
count = SPECPDL_INDEX ();
|
||||||
record_unwind_protect_excursion ();
|
record_unwind_protect_excursion ();
|
||||||
|
record_unwind_protect (restore_selected_window, selected_window);
|
||||||
|
|
||||||
/* Inhibit quitting. */
|
/* Inhibit quitting. */
|
||||||
specbind (Qinhibit_quit, Qt);
|
specbind (Qinhibit_quit, Qt);
|
||||||
|
@ -586,15 +596,6 @@ detect_conversion_events (void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore the selected window WINDOW. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
restore_selected_window (Lisp_Object window)
|
|
||||||
{
|
|
||||||
/* FIXME: not sure what to do if WINDOW has been deleted. */
|
|
||||||
select_window (window, Qt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Commit the given text in the composing region. If there is no
|
/* Commit the given text in the composing region. If there is no
|
||||||
composing region, then insert the text after frame F's selected
|
composing region, then insert the text after frame F's selected
|
||||||
window's last point instead, unless the mark is active. Finally,
|
window's last point instead, unless the mark is active. Finally,
|
||||||
|
@ -1138,6 +1139,10 @@ locate_and_save_position_in_field (struct frame *f, struct window *w,
|
||||||
|
|
||||||
/* Set the current buffer to W's. */
|
/* Set the current buffer to W's. */
|
||||||
count = SPECPDL_INDEX ();
|
count = SPECPDL_INDEX ();
|
||||||
|
|
||||||
|
/* The current buffer must be saved, not merely the selected
|
||||||
|
window. */
|
||||||
|
record_unwind_protect_excursion ();
|
||||||
record_unwind_protect (restore_selected_window, selected_window);
|
record_unwind_protect (restore_selected_window, selected_window);
|
||||||
XSETWINDOW (window, w);
|
XSETWINDOW (window, w);
|
||||||
select_window (window, Qt);
|
select_window (window, Qt);
|
||||||
|
@ -2097,6 +2102,7 @@ get_extracted_text (struct frame *f, ptrdiff_t n,
|
||||||
selected window. */
|
selected window. */
|
||||||
count = SPECPDL_INDEX ();
|
count = SPECPDL_INDEX ();
|
||||||
record_unwind_protect_excursion ();
|
record_unwind_protect_excursion ();
|
||||||
|
record_unwind_protect (restore_selected_window, selected_window);
|
||||||
|
|
||||||
/* Inhibit quitting. */
|
/* Inhibit quitting. */
|
||||||
specbind (Qinhibit_quit, Qt);
|
specbind (Qinhibit_quit, Qt);
|
||||||
|
@ -2219,6 +2225,7 @@ get_surrounding_text (struct frame *f, ptrdiff_t left,
|
||||||
selected window. */
|
selected window. */
|
||||||
count = SPECPDL_INDEX ();
|
count = SPECPDL_INDEX ();
|
||||||
record_unwind_protect_excursion ();
|
record_unwind_protect_excursion ();
|
||||||
|
record_unwind_protect (restore_selected_window, selected_window);
|
||||||
|
|
||||||
/* Inhibit quitting. */
|
/* Inhibit quitting. */
|
||||||
specbind (Qinhibit_quit, Qt);
|
specbind (Qinhibit_quit, Qt);
|
||||||
|
|
Loading…
Add table
Reference in a new issue