Function: internal-default-process-filter
internal-default-process-filter is a function defined in process.c.
Signature
(internal-default-process-filter PROC TEXT)
Documentation
Function used as default process filter.
This inserts the process's output into its buffer, if there is one. Otherwise it discards the output.
Source Code
// Defined in /usr/src/emacs/src/process.c
{
struct Lisp_Process *p;
ptrdiff_t opoint;
CHECK_PROCESS (proc);
p = XPROCESS (proc);
CHECK_STRING (text);
if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
{
Lisp_Object old_read_only;
ptrdiff_t old_begv, old_zv;
ptrdiff_t before, before_byte;
ptrdiff_t opoint_byte;
struct buffer *b;
Fset_buffer (p->buffer);
opoint = PT;
opoint_byte = PT_BYTE;
old_read_only = BVAR (current_buffer, read_only);
old_begv = BEGV;
old_zv = ZV;
bset_read_only (current_buffer, Qnil);
/* Insert new output into buffer at the current end-of-output
marker, thus preserving logical ordering of input and output. */
if (XMARKER (p->mark)->buffer)
set_point_from_marker (p->mark);
else
SET_PT_BOTH (ZV, ZV_BYTE);
before = PT;
before_byte = PT_BYTE;
/* If the output marker is outside of the visible region, save
the restriction and widen. */
if (! (BEGV <= PT && PT <= ZV))
Fwiden ();
/* Adjust the multibyteness of TEXT to that of the buffer. */
if (NILP (BVAR (current_buffer, enable_multibyte_characters))
!= ! STRING_MULTIBYTE (text))
text = (STRING_MULTIBYTE (text)
? Fstring_as_unibyte (text)
: Fstring_to_multibyte (text));
/* Insert before markers in case we are inserting where
the buffer's mark is, and the user's next command is Meta-y. */
insert_from_string_before_markers (text, 0, 0,
SCHARS (text), SBYTES (text), 0);
/* Make sure the process marker's position is valid when the
process buffer is changed in the signal_after_change above.
W3 is known to do that. */
if (BUFFERP (p->buffer)
&& (b = XBUFFER (p->buffer), b != current_buffer))
set_marker_both (p->mark, p->buffer, BUF_PT (b), BUF_PT_BYTE (b));
else
set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
update_mode_lines = 23;
/* Make sure opoint and the old restrictions
float ahead of any new text just as point would. */
if (opoint >= before)
{
opoint += PT - before;
opoint_byte += PT_BYTE - before_byte;
}
if (old_begv > before)
old_begv += PT - before;
if (old_zv >= before)
old_zv += PT - before;
/* If the restriction isn't what it should be, set it. */
if (old_begv != BEGV || old_zv != ZV)
Fnarrow_to_region (make_fixnum (old_begv), make_fixnum (old_zv));
bset_read_only (current_buffer, old_read_only);
SET_PT_BOTH (opoint, opoint_byte);
}
return Qnil;
}