Function: internal-default-process-sentinel

internal-default-process-sentinel is a function defined in process.c.

Signature

(internal-default-process-sentinel PROC MSG)

Documentation

Function used as default sentinel for processes.

This inserts a status message into the process's buffer, if there is one.

Source Code

// Defined in /usr/src/emacs/src/process.c
{
  Lisp_Object buffer, symbol;
  struct Lisp_Process *p;
  CHECK_PROCESS (proc);
  p = XPROCESS (proc);
  buffer = p->buffer;
  symbol = p->status;
  if (CONSP (symbol))
    symbol = XCAR (symbol);

  if (!EQ (symbol, Qrun) && !NILP (buffer))
    {
      Lisp_Object tem;
      struct buffer *old = current_buffer;
      ptrdiff_t opoint, opoint_byte;
      ptrdiff_t before, before_byte;

      /* Avoid error if buffer is deleted
	 (probably that's why the process is dead, too).  */
      if (!BUFFER_LIVE_P (XBUFFER (buffer)))
	return Qnil;
      Fset_buffer (buffer);

      if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
	msg = (code_convert_string_norecord
	       (msg, Vlocale_coding_system, 1));

      opoint = PT;
      opoint_byte = PT_BYTE;
      /* 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)
	Fgoto_char (p->mark);
      else
	SET_PT_BOTH (ZV, ZV_BYTE);

      before = PT;
      before_byte = PT_BYTE;

      tem = BVAR (current_buffer, read_only);
      bset_read_only (current_buffer, Qnil);
      insert_string ("\nProcess ");
      { /* FIXME: temporary kludge.  */
	Lisp_Object tem2 = p->name; Finsert (1, &tem2); }
      insert_string (" ");
      Finsert (1, &msg);
      bset_read_only (current_buffer, tem);
      set_marker_both (p->mark, p->buffer, PT, PT_BYTE);

      if (opoint >= before)
	SET_PT_BOTH (opoint + (PT - before),
		     opoint_byte + (PT_BYTE - before_byte));
      else
	SET_PT_BOTH (opoint, opoint_byte);

      set_buffer_internal (old);
    }
  return Qnil;
}