Function: internal-describe-syntax-value

internal-describe-syntax-value is a function defined in syntax.c.

Signature

(internal-describe-syntax-value SYNTAX)

Documentation

Insert a description of the internal syntax description SYNTAX at point.

Source Code

// Defined in /usr/src/emacs/src/syntax.c
{
  int code, syntax_code;
  bool start1, start2, end1, end2, prefix, comstyleb, comstylec, comnested;
  char str[2];
  Lisp_Object first, match_lisp, value = syntax;

  if (NILP (value))
    {
      insert_string ("default");
      return syntax;
    }

  if (CHAR_TABLE_P (value))
    {
      insert_string ("deeper char-table ...");
      return syntax;
    }

  if (!CONSP (value))
    {
      insert_string ("invalid");
      return syntax;
    }

  first = XCAR (value);
  match_lisp = XCDR (value);

  if (!FIXNUMP (first) || !(NILP (match_lisp) || CHARACTERP (match_lisp)))
    {
      insert_string ("invalid");
      return syntax;
    }

  syntax_code = XFIXNUM (first) & INT_MAX;
  code = syntax_code & 0377;
  start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code);
  start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);
  end1 = SYNTAX_FLAGS_COMEND_FIRST (syntax_code);
  end2 = SYNTAX_FLAGS_COMEND_SECOND (syntax_code);
  prefix = SYNTAX_FLAGS_PREFIX (syntax_code);
  comstyleb = SYNTAX_FLAGS_COMMENT_STYLEB (syntax_code);
  comstylec = SYNTAX_FLAGS_COMMENT_STYLEC (syntax_code);
  comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax_code);

  if (Smax <= code)
    {
      insert_string ("invalid");
      return syntax;
    }

  str[0] = syntax_code_spec[code], str[1] = 0;
  insert (str, 1);

  if (NILP (match_lisp))
    insert (" ", 1);
  else
    insert_char (XFIXNUM (match_lisp));

  if (start1)
    insert ("1", 1);
  if (start2)
    insert ("2", 1);

  if (end1)
    insert ("3", 1);
  if (end2)
    insert ("4", 1);

  if (prefix)
    insert ("p", 1);
  if (comstyleb)
    insert ("b", 1);
  if (comstylec)
    insert ("c", 1);
  if (comnested)
    insert ("n", 1);

  insert_string ("\twhich means: ");

  switch (code)
    {
    case Swhitespace:
      insert_string ("whitespace"); break;
    case Spunct:
      insert_string ("punctuation"); break;
    case Sword:
      insert_string ("word"); break;
    case Ssymbol:
      insert_string ("symbol"); break;
    case Sopen:
      insert_string ("open"); break;
    case Sclose:
      insert_string ("close"); break;
    case Squote:
      insert_string ("prefix"); break;
    case Sstring:
      insert_string ("string"); break;
    case Smath:
      insert_string ("math"); break;
    case Sescape:
      insert_string ("escape"); break;
    case Scharquote:
      insert_string ("charquote"); break;
    case Scomment:
      insert_string ("comment"); break;
    case Sendcomment:
      insert_string ("endcomment"); break;
    case Sinherit:
      insert_string ("inherit"); break;
    case Scomment_fence:
      insert_string ("comment fence"); break;
    case Sstring_fence:
      insert_string ("string fence"); break;
    default:
      insert_string ("invalid");
      return syntax;
    }

  if (!NILP (match_lisp))
    {
      insert_string (", matches ");
      insert_char (XFIXNUM (match_lisp));
    }

  if (start1)
    insert_string (",\n\t  is the first character of a comment-start sequence");
  if (start2)
    insert_string (",\n\t  is the second character of a comment-start sequence");

  if (end1)
    insert_string (",\n\t  is the first character of a comment-end sequence");
  if (end2)
    insert_string (",\n\t  is the second character of a comment-end sequence");
  if (comstyleb)
    insert_string (" (comment style b)");
  if (comstylec)
    insert_string (" (comment style c)");
  if (comnested)
    insert_string (" (nestable)");

  if (prefix)
    {
      AUTO_STRING (prefixdoc,
		   ",\n\t  is a prefix character for `backward-prefix-chars'");
      insert1 (calln (Qsubstitute_command_keys, prefixdoc));
    }

  return syntax;
}