Function: char-after

char-after is a function defined in editfns.c.

Signature

(char-after &optional POS)

Documentation

Return character in current buffer at position POS.

POS is an integer or a marker and defaults to point. If POS is out of range, the value is nil.

Other relevant functions are documented in the buffer group.

View in manual

Shortdoc

;; buffer
(char-after 45)
    => 32

Source Code

// Defined in /usr/src/emacs/src/editfns.c
{
  register ptrdiff_t pos_byte;

  if (NILP (pos))
    {
      pos_byte = PT_BYTE;
      if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
        return Qnil;
    }
  else if (MARKERP (pos))
    {
      pos_byte = marker_byte_position (pos);
      if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
	return Qnil;
    }
  else
    {
      EMACS_INT p = fix_position (pos);
      if (! (BEGV <= p && p < ZV))
	return Qnil;

      pos_byte = CHAR_TO_BYTE (p);
    }

  return make_fixnum (FETCH_CHAR (pos_byte));
}