Subject: bug#66020: (bug#64735 spin-off): regarding the default for read-process-output-max

From: Dmitry Gutov <[email-masked]>
Date: Tue, 11 Jun 2024 06:12:21 +0300

On 09/06/2024 03:12, Dmitry Gutov wrote:
>>>
>> I guess we can install all 3 patches and see if anything breaks.
> 
> Thank you, now pushed to master.

On the heels of bug#71452, I've pushed three updates.

Here's a third one (hopefully last) which I'd like a second opinion on. 
Process output -- apparently -- needs to be inserted before markers.

Is it okay to make adjust_markers_for_insert non-static and call it 
here? See attached.

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 @@ verify (FLT_RADIX == 2 || FLT_RADIX == 16);
 				 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 b6ec114e2b3..0bd3d068441 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);