Function: string-to-syntax
string-to-syntax is a function defined in syntax.c.
Signature
(string-to-syntax STRING)
Documentation
Convert a syntax descriptor STRING into a raw syntax descriptor.
STRING should be a string of the form allowed as argument of
modify-syntax-entry. The return value is a raw syntax descriptor: a
cons cell (CODE . MATCHING-CHAR) which can be used, for example, as
the value of a syntax-table text property.
Probably introduced at or before Emacs version 21.1.
Source Code
// Defined in /usr/src/emacs/src/syntax.c
{
const unsigned char *p;
int val;
Lisp_Object match;
CHECK_STRING (string);
p = SDATA (string);
val = syntax_spec_code[*p++];
if (val == 0377)
error ("Invalid syntax description letter: %c", p[-1]);
if (val == Sinherit)
return Qnil;
if (*p)
{
int len, character = string_char_and_length (p, &len);
XSETINT (match, character);
if (XFIXNAT (match) == ' ')
match = Qnil;
p += len;
}
else
match = Qnil;
while (*p)
switch (*p++)
{
case '1':
val |= 1 << 16;
break;
case '2':
val |= 1 << 17;
break;
case '3':
val |= 1 << 18;
break;
case '4':
val |= 1 << 19;
break;
case 'p':
val |= 1 << 20;
break;
case 'b':
val |= 1 << 21;
break;
case 'n':
val |= 1 << 22;
break;
case 'c':
val |= 1 << 23;
break;
}
if (val < ASIZE (Vsyntax_code_object) && NILP (match))
return AREF (Vsyntax_code_object, val);
else
/* Since we can't use a shared object, let's make a new one. */
return Fcons (make_fixnum (val), match);
}