unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting
@ 2024-03-06 17:25 Divvy Cr.
  2024-03-06 17:48 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Divvy Cr. @ 2024-03-06 17:25 UTC (permalink / raw)
  To: 69589

[-- Attachment #1: Type: text/plain, Size: 5427 bytes --]

Open a JavaScript file containing 'const x = 10;' for instance. Then,
enable js-ts-mode (M-x js-ts-mode). Expected the literal '10' to be
highlighted with font-lock-number-face, but it is not.

The apparent reason is that the 'function' node name used in
treesit-font-lock-rules to define js--treesit-font-lock-settings (in the
file js.el) is a valid elisp function (C-h f function). This invalidates
the query, as verified by running the following:

(treesit-query-validate 'javascript ((function
      name: (identifier) @font-lock-function-name-face)

     (class_declaration
      name: (identifier) @font-lock-type-face)

     (function_declaration
      name: (identifier) @font-lock-function-name-face)

     (method_definition
      name: (property_identifier) @font-lock-function-name-face)

     (formal_parameters
      [(identifier) @font-lock-variable-name-face
       (array_pattern (identifier) @font-lock-variable-name-face)
       (object_pattern (shorthand_property_identifier_pattern)
@font-lock-variable-name-face)])

     (variable_declarator
      name: (identifier) @font-lock-variable-name-face)

     (variable_declarator
      name: (identifier) @font-lock-function-name-face
      value: [(function) (arrow_function)])

     (variable_declarator
      name: [(array_pattern (identifier) @font-lock-variable-name-face)
             (object_pattern
              (shorthand_property_identifier_pattern)
@font-lock-variable-name-face)])

     ;; full module imports
     (import_clause (identifier) @font-lock-variable-name-face)
     ;; named imports with aliasing
     (import_clause (named_imports (import_specifier
                                    alias: (identifier)
@font-lock-variable-name-face)))
     ;; named imports without aliasing
     (import_clause (named_imports (import_specifier
                                    !alias
                                    name: (identifier)
@font-lock-variable-name-face)))

     ;; full namespace import (* as alias)
     (import_clause (namespace_import (identifier)
     @font-lock-variable-name-face))))

Note that this query is taken directly from the definition of
js--tresit-font-lock-settings.

Removing the invalid snippet above from the definition of
js--treesit-font-lock-settings fixes this bug.


In GNU Emacs 29.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33,
 cairo version 1.16.0) of 2024-03-05 built on DV-Portable
System Description: Ubuntu 22.04.4 LTS

Configured using:
 'configure --with-pgtk --with-native-compilation
 --without-compress-install --with-tree-sitter'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER XIM GTK3 ZLIB

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix

Major mode: JavaScript

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr cl-print thingatpt help-fns radix-tree emacsbug
message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec
password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils pp wid-edit descr-text js
c-ts-common treesit json map byte-opt imenu cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
cl-loaddefs comp comp-cstr warnings icons subr-x rx cl-seq cl-macs gv
cl-extra help-mode bytecomp byte-compile cl-lib rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
gtk pgtk lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 146459 33528)
 (symbols 48 22745 0)
 (strings 32 97373 2695)
 (string-bytes 1 2500148)
 (vectors 16 25550)
 (vector-slots 8 853209 33493)
 (floats 8 53 28)
 (intervals 56 282 0)
 (buffers 984 14))

[-- Attachment #2: Type: text/html, Size: 6147 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting
  2024-03-06 17:25 bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting Divvy Cr.
@ 2024-03-06 17:48 ` Eli Zaretskii
       [not found]   ` <CADmOxiLB9J1UhE3UXiMDCDVnUDT-=_i0RjJbbJpn=9uZckf=XA@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-03-06 17:48 UTC (permalink / raw)
  To: Divvy Cr.; +Cc: 69589

> From: "Divvy Cr." <divvycr@gmail.com>
> Date: Wed, 6 Mar 2024 17:25:40 +0000
> 
> Open a JavaScript file containing 'const x = 10;' for instance. Then,
> enable js-ts-mode (M-x js-ts-mode). Expected the literal '10' to be
> highlighted with font-lock-number-face, but it is not.
> 
> The apparent reason is that the 'function' node name used in
> treesit-font-lock-rules to define js--treesit-font-lock-settings (in the
> file js.el) is a valid elisp function (C-h f function). This invalidates
> the query, as verified by running the following:
> 
> (treesit-query-validate 'javascript ((function
>       name: (identifier) @font-lock-function-name-face)
> 
>      (class_declaration
>       name: (identifier) @font-lock-type-face)
> 
>      (function_declaration
>       name: (identifier) @font-lock-function-name-face)
> 
>      (method_definition
>       name: (property_identifier) @font-lock-function-name-face)
> 
>      (formal_parameters
>       [(identifier) @font-lock-variable-name-face
>        (array_pattern (identifier) @font-lock-variable-name-face)
>        (object_pattern (shorthand_property_identifier_pattern) @font-lock-variable-name-face)])
> 
>      (variable_declarator
>       name: (identifier) @font-lock-variable-name-face)
> 
>      (variable_declarator
>       name: (identifier) @font-lock-function-name-face
>       value: [(function) (arrow_function)])
> 
>      (variable_declarator
>       name: [(array_pattern (identifier) @font-lock-variable-name-face)
>              (object_pattern
>               (shorthand_property_identifier_pattern) @font-lock-variable-name-face)])
> 
>      ;; full module imports
>      (import_clause (identifier) @font-lock-variable-name-face)
>      ;; named imports with aliasing
>      (import_clause (named_imports (import_specifier
>                                     alias: (identifier) @font-lock-variable-name-face)))
>      ;; named imports without aliasing
>      (import_clause (named_imports (import_specifier
>                                     !alias
>                                     name: (identifier) @font-lock-variable-name-face)))
> 
>      ;; full namespace import (* as alias)
>      (import_clause (namespace_import (identifier)
>      @font-lock-variable-name-face))))
> 
> Note that this query is taken directly from the definition of
> js--tresit-font-lock-settings.
> 
> Removing the invalid snippet above from the definition of
> js--treesit-font-lock-settings fixes this bug.

Thanks, I believe this is bug#68879, which was already solved in the
development code about a month ago.  See commit 2f69353e4a75 on the
emacs-29 branch of the Emacs Git repository.  Can you try patching
js.el with that change?





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting
       [not found]   ` <CADmOxiLB9J1UhE3UXiMDCDVnUDT-=_i0RjJbbJpn=9uZckf=XA@mail.gmail.com>
@ 2024-03-06 19:21     ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2024-03-06 19:21 UTC (permalink / raw)
  To: Divvy Cr.; +Cc: 69589-done

> From: "Divvy Cr." <divvycr@gmail.com>
> Date: Wed, 6 Mar 2024 18:00:50 +0000
> 
> Ah, yep, that solves it. Cheers!

Thanks for testing, I'm therefore closing this bug.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-06 19:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06 17:25 bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting Divvy Cr.
2024-03-06 17:48 ` Eli Zaretskii
     [not found]   ` <CADmOxiLB9J1UhE3UXiMDCDVnUDT-=_i0RjJbbJpn=9uZckf=XA@mail.gmail.com>
2024-03-06 19:21     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).