emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add pseudo vector types


From: Eli Zaretskii
Subject: Re: How to add pseudo vector types
Date: Sat, 24 Jul 2021 19:14:13 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Sat, 24 Jul 2021 11:04:35 -0400
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>  Clément Pit-Claudel <cpitclaudel@gmail.com>,
>  emacs-devel@gnu.org
> 
> +(define-derived-mode ts-c-mode prog-mode "TS C"
> +  "C mode with tree-sitter support."
> +  (setq-local font-lock-fontify-region-function
> +              #'tree-sitter-fontify-region-function)
> +  (setq-local tree-sitter-font-lock-settings
> +              `(("font-lock-c"
> +                 ,(tree-sitter-c)
> +                 "(null) @font-lock-constant-face
> +(true) @font-lock-constant-face
> +(false) @font-lock-constant-face
> +
> +(comment) @font-lock-comment-face
> +
> +(system_lib_string) @ts-c-fontify-system-lib
> +
> +(unary_expression
> +  operator: _ @font-lock-negation-char-face)
> +
> +(string_literal) @font-lock-string-face
> +(char_literal) @font-lock-string-face

Where does this repertoire of possible syntax categories come from?
Is this from some list that TS exposes or documents?  If so, what
happens when the repertoire is modified?

>        beg = (char *) BUF_BYTE_ADDRESS (buffer, byte_pos);
> -      len = next_char_len(byte_pos);
> +      len = BYTES_BY_CHAR_HEAD ((int) beg);

The last line is wrong: you need the byte itself.  So it should be:

      len = BYTES_BY_CHAR_HEAD (*beg);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]