Function: char-before
char-before is a function defined in editfns.c.
Signature
(char-before &optional POS)
Documentation
Return character in current buffer preceding 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.
Shortdoc
;; buffer
(char-before 13)
=> 101
Source Code
// Defined in /usr/src/emacs/src/editfns.c
{
register Lisp_Object val;
register ptrdiff_t pos_byte;
if (NILP (pos))
{
pos_byte = PT_BYTE;
XSETFASTINT (pos, PT);
}
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);
}
if (!NILP (BVAR (current_buffer, enable_multibyte_characters)))
{
pos_byte -= prev_char_len (pos_byte);
XSETFASTINT (val, FETCH_CHAR (pos_byte));
}
else
{
pos_byte--;
XSETFASTINT (val, FETCH_BYTE (pos_byte));
}
return val;
}