0

What is the Raw Syntax Descriptor for a char at POS? Can I have some examples so I can understand what this thing is all about?

Drew
  • 77,472
  • 10
  • 114
  • 243
Dilna
  • 1
  • 3
  • 11
  • 1
    Do `C-h i g (elisp) i raw syn' and read the section. Why do you need to know? What are you trying to do? IME, an approximate understanding of syntax tables is almost always enough (and those sections fill the gap when and only when I really need to dig into very low level details). – NickD Jul 20 '22 at 11:55
  • I want to know whether a ( or ) occurs within a string, comment or is escaped. – Dilna Jul 20 '22 at 12:40
  • Please explain the context: I cannot guess what you mean. Are you trying to parse a piece of code? What kind of code? Give an example. – NickD Jul 20 '22 at 13:11

1 Answers1

2

In order to understand syntax, you need to understand what the syntax of a char is. You can find this with how to use the command C-u C-x =. The syntax of the same char could be different based on the mode in use.

See Syntax of some char

See Syntax of some other char


C-x = runs the command what-cursor-position (found in global-map), which is an interactive compiled Lisp function in simple.el.

It is bound to C-x =.

(what-cursor-position &optional DETAIL)

Print info on cursor position (on screen and within buffer). Also describe the character after point, and give its character code in octal, decimal and hex. If what-cursor-show-names is non-nil, additionally show the name of the character.

For a non-ASCII multibyte character, also give its encoding in the buffer`s selected coding system if the coding system encodes the character safely. If the character is encoded into one byte, that code is shown in hex. If the character is encoded into more than one byte, just "..." is shown.

In addition, with prefix argument, show details about that character in Help buffer. See also the command describe-char.

Probably introduced at or before Emacs version 27.1.

[back]

  • does syntax-ppss give () in your example? – Dilna Jul 20 '22 at 15:14
  • What is C-u C-x = bound to? – Dilna Jul 20 '22 at 15:20
  • It is there in my response. What Emacs version are you using and on which OS? –  Jul 20 '22 at 15:30
  • I have circled things ... What do you see there? –  Jul 20 '22 at 15:33
  • desribe-char then. Have been wondering what (nth 3 (syntax-ppss)) does. – Dilna Jul 20 '22 at 15:35
  • M-x find-library RET syntax RET and M-x occur RET 3 ppss. Go to that position and report what do you see. Take time to think about information I am giving you. –  Jul 20 '22 at 15:40
  • Yes, I am interested in Parse-Partial-Sexp State at POS. I get 418: ((nth 3 ppss) 'string) 473: (nth 3 last) 624: (syntax-ppss--update-stats 3 pt-min pos). – Dilna Jul 20 '22 at 15:50
  • Read that function. It tells you a lot. –  Jul 21 '22 at 01:32
  • I am having trouble understanding the list returned by parse-partial-sexp such as (9 157 158 34 nil nil 8 nil 166 (146 147 148 149 150 151 152 153 157) nil). – Dilna Jul 21 '22 at 02:42
  • How many elements are in that list? Read C-h f parse-partial-sexp once again. There is a numbered list which you cannot miss in the description. –  Jul 21 '22 at 03:39