* src/coding.c (setup_coding_system): Initialize it.
(produce_chars, encode_coding, decode_coding_gap):
Obey it in insert_from_gap calls.
(encode_string_utf_8, decode_string_utf_8): Update the other calls
to insert_from_gap to have one new argument (false).
* src/coding.h: New field insert_before_markers.
* src/decompress.c (Fzlib_decompress_region): Here too.
* src/insdel.c (insert_from_gap):
Accept new argument BEFORE_MARKERS (bug#71525) and pass it through
to adjust_markers_for_insert.
* src/lisp.h: Update prototype.
* src/process.c (read_and_insert_process_output):
Set process_coding->insert_before_markers instead of calling
adjust_markers_for_insert.
(cherry picked from commit
a8d5c5fd8789f28ddd040e497f03a988e5f0703c)
coding->default_char = XFIXNUM (CODING_ATTR_DEFAULT_CHAR (attrs));
coding->carryover_bytes = 0;
coding->raw_destination = 0;
+ coding->insert_before_markers = 0;
coding_type = CODING_ATTR_TYPE (attrs);
if (EQ (coding_type, Qundecided))
produced = dst - (coding->destination + coding->produced);
if (BUFFERP (coding->dst_object) && produced_chars > 0)
- insert_from_gap (produced_chars, produced, 0);
+ insert_from_gap (produced_chars, produced, 0,
+ coding->insert_before_markers);
coding->produced += produced;
coding->produced_char += produced_chars;
return carryover;
} while (coding->consumed_char < coding->src_chars);
if (BUFFERP (coding->dst_object) && coding->produced_char > 0)
- insert_from_gap (coding->produced_char, coding->produced, 0);
+ insert_from_gap (coding->produced_char, coding->produced, 0,
+ coding->insert_before_markers);
SAFE_FREE ();
}
}
coding->produced = bytes;
coding->produced_char = chars;
- insert_from_gap (chars, bytes, 1);
+ insert_from_gap (chars, bytes, 1, coding->insert_before_markers);
return;
}
}
struct buffer *oldb = current_buffer;
current_buffer = XBUFFER (buffer);
- insert_from_gap (outbytes, outbytes, false);
+ insert_from_gap (outbytes, outbytes, false, false);
current_buffer = oldb;
}
return val;
struct buffer *oldb = current_buffer;
current_buffer = XBUFFER (buffer);
- insert_from_gap (outchars, outbytes, false);
+ insert_from_gap (outchars, outbytes, false, false);
current_buffer = oldb;
}
return val;
/* Set to true if charbuf contains an annotation. */
bool_bf annotated : 1;
+ /* True to insert before markers in the output buffer,
+ if `dst_object' is a buffer. */
+ bool_bf insert_before_markers : 1;
+
/* Used internally in coding.c. See the comment of detect_ascii. */
unsigned eol_seen : 3;
inflate_status = inflate (&stream, Z_NO_FLUSH);
pos_byte += avail_in - stream.avail_in;
decompressed = avail_out - stream.avail_out;
- insert_from_gap (decompressed, decompressed, 0);
+ insert_from_gap (decompressed, decompressed, 0, false);
unwind_data.nbytes += decompressed;
maybe_quit ();
}
/* Insert a sequence of NCHARS chars which occupy NBYTES bytes
starting at GAP_END_ADDR - NBYTES (if text_at_gap_tail) and at
- GPT_ADDR (if not text_at_gap_tail). */
+ GPT_ADDR (if not text_at_gap_tail).
+
+ If BEFORE_MARKERS is true, insert before markers. At the moment the
+ only high-level callers of this functionality is
+ read_and_insert_process_output in process.c. */
void
-insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail)
+insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail,
+ bool before_markers)
{
ptrdiff_t ins_charpos = GPT, ins_bytepos = GPT_BYTE;
insert_from_gap_1 (nchars, nbytes, text_at_gap_tail);
adjust_markers_for_insert (ins_charpos, ins_bytepos,
- ins_charpos + nchars, ins_bytepos + nbytes, false);
+ ins_charpos + nchars, ins_bytepos + nbytes,
+ before_markers);
if (buffer_intervals (current_buffer))
{
extern void insert_and_inherit (const char *, ptrdiff_t);
extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t,
bool, bool, bool);
-extern void insert_from_gap_1 (ptrdiff_t, ptrdiff_t, bool text_at_gap_tail);
-extern void insert_from_gap (ptrdiff_t, ptrdiff_t, bool text_at_gap_tail);
+extern void insert_from_gap_1 (ptrdiff_t, ptrdiff_t, bool);
+extern void insert_from_gap (ptrdiff_t, ptrdiff_t, bool, bool);
extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, bool);
extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
if (NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters))
&& ! CODING_MAY_REQUIRE_DECODING (process_coding))
{
+ /* For compatibility with the long-standing behavior of
+ internal-default-process-filter we insert before markers,
+ both here and in the 'else' branch. */
insert_1_both (buf, nread, nread, 0, 0, 1);
signal_after_change (PT - nread, 0, nread);
}
specpdl_ref count1 = SPECPDL_INDEX ();
XSETBUFFER (curbuf, current_buffer);
+ process_coding->insert_before_markers = true;
/* We cannot allow after-change-functions be run
during decoding, because that might modify the
buffer, while we rely on process_coding.produced to
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);