From dc9c9d3143aff3399ede1ce4acf166d18a31e1ec Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 11 Jun 2024 21:02:57 +0300 Subject: [PATCH] read_and_insert_process_output: Insert before markers * src/insdel.c (adjust_markers_for_insert): Make non-static. * src/lisp.h: Add declaration for it. * src/process.c (read_and_insert_process_output): Use it here. And also call insert_1_both with BEFORE_MARKERS=t, for compatibility with internal-default-process-filter (bug#66020). (cherry picked from commit 3199b8584e4583a4b74263f5704a21c3431658c2) --- src/insdel.c | 2 +- src/lisp.h | 2 ++ src/process.c | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/insdel.c b/src/insdel.c index 3809f8bc060..fbf71e1e595 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -284,7 +284,7 @@ adjust_markers_for_delete (ptrdiff_t from, ptrdiff_t from_byte, we advance it if either its insertion-type is t or BEFORE_MARKERS is true. */ -static void +void adjust_markers_for_insert (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t to, ptrdiff_t to_byte, bool before_markers) { diff --git a/src/lisp.h b/src/lisp.h index e1911cbb660..21dada59132 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4399,6 +4399,8 @@ extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t); extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t); +extern void adjust_markers_for_insert (ptrdiff_t, ptrdiff_t, + ptrdiff_t, ptrdiff_t, bool); extern void adjust_markers_bytepos (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, int); extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, bool, bool, diff --git a/src/process.c b/src/process.c index 43a02affa90..eb526311c53 100644 --- a/src/process.c +++ b/src/process.c @@ -6406,7 +6406,7 @@ read_and_insert_process_output (struct Lisp_Process *p, char *buf, if (NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters)) && ! CODING_MAY_REQUIRE_DECODING (process_coding)) { - insert_1_both (buf, nread, nread, 0, 0, 0); + insert_1_both (buf, nread, nread, 0, 0, 1); signal_after_change (PT - nread, 0, nread); } else @@ -6423,6 +6423,9 @@ read_and_insert_process_output (struct Lisp_Process *p, char *buf, specbind (Qinhibit_modification_hooks, Qt); decode_coding_c_string (process_coding, (unsigned char *) buf, nread, curbuf); + adjust_markers_for_insert (PT, PT_BYTE, + PT + process_coding->produced_char, + PT_BYTE + process_coding->produced, true); unbind_to (count1, Qnil); read_process_output_set_last_coding_system (p, process_coding); -- 2.39.2