From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wilhelm Kirschbaum Newsgroups: gmane.emacs.bugs Subject: bug#58711: Treesit hangs when calling treesit-search-forward Date: Sat, 22 Oct 2022 11:53:50 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000be52c705eb9c89de" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27221"; mail-complaints-to="usenet@ciao.gmane.io" To: 58711@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 22 12:10:41 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1omBSi-0006ti-A4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Oct 2022 12:10:40 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omBDi-00044o-Rw; Sat, 22 Oct 2022 05:55:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omBDa-00044c-Sv for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 05:55:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omBDa-0007dd-La for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 05:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1omBDa-0007Ua-5P for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 05:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wilhelm Kirschbaum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Oct 2022 09:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58711 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166643245328735 (code B ref -1); Sat, 22 Oct 2022 09:55:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Oct 2022 09:54:13 +0000 Original-Received: from localhost ([127.0.0.1]:39720 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omBCm-0007TO-CB for submit@debbugs.gnu.org; Sat, 22 Oct 2022 05:54:13 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:46450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omBCk-0007TH-J5 for submit@debbugs.gnu.org; Sat, 22 Oct 2022 05:54:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omBCi-00040C-Ac for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 05:54:10 -0400 Original-Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omBCd-0007XR-TL for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 05:54:06 -0400 Original-Received: by mail-io1-xd2a.google.com with SMTP id b79so4196514iof.5 for ; Sat, 22 Oct 2022 02:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=VfP69udyw1q3fnjYes0KvSRY7utqyYMfDmIhyBeU9ds=; b=j+o8tVeHFd0BuLFZcJgdziiFMVcKpivJYIJC+xMxcDDwYFCLvtg5kdsqUb371vJa/R u1ee1c7O0PDondphRsfU6DkTyCXu4NLLQSuilbvZjARG3x3rq574Bx8H7VOiskgeulRG dF7t1SAjV6ReP1es7sqxmwsN/A5aON1D8NVF/Ia271NkQXIFXNfUnIBDCecj/K1DNPAt TURrUFlH49GAXMYfJj3LHxa1zxi/OSGiM0lhthJ9wx+GFSm6aVpX06zKHzwBQI27RsCs ZgQxY9OGXbxj4YavILCSYiQtkCpthrzeQX2afGfQl9dXaRLC7WXkuQry16XjMAD+dVZu FQ/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VfP69udyw1q3fnjYes0KvSRY7utqyYMfDmIhyBeU9ds=; b=leBWjyF1T1VdeVVFdWSLD2h7FjB1gYF1xO9ymcvKv4ps0BiyNE/rk8Y1Tmpc4kOHpz QKLT5toNbJGCOLbn19dr5efoBhIeguUnFOY+XmUO7v/D8qOJK4hLSGMcJIeNdJr7iabl ImUCD8WiA4dBoISaskZzvG8dCuUN4n399C672vbc6VhuB60LMKvTYON32k0dM1Dwgjk1 wG4ZdwLFcmmlKOrgLs1Ri2Tgj5ft6bK7e9VmpoGCBXnYOup5g6BVls5nWrqBshPhPCSJ rr06/z+FOcg8VPC9Py+E7ijjVPl4Qr0cDpe08qV8CyGVwwrX6wsmtgCi+zPe9Jsis0Yv oYdg== X-Gm-Message-State: ACrzQf13NEnRzyQ8U57Z+xX7jMhip5Kpv/6vUNF3/UDxL8P1xK9MHjBm ZPJ2QVqj8/lRzhd7GcYT9KaKpJEFBayP3uF64kQcjZeFlds= X-Google-Smtp-Source: AMsMyM6gaIEuk4ykcL3bmAV5CmT7GkCPeoQ76Chv+jMrLJ4Or/o2JEPRlqMgu9dlGx6h1gkUAayFjqaMXq6m7PAnwWI= X-Received: by 2002:a05:6602:1551:b0:6bc:dfba:33f9 with SMTP id h17-20020a056602155100b006bcdfba33f9mr15086195iow.76.1666432441928; Sat, 22 Oct 2022 02:54:01 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::d2a; envelope-from=wkirschbaum@gmail.com; helo=mail-io1-xd2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246030 Archived-At: --000000000000be52c705eb9c89de Content-Type: text/plain; charset="UTF-8" I am attempting to implement treesit for the current elixir-mode using the branch feature/trees-sitter. For implementing beginning-of-defun-function using treesit I am running into an issue where the Emacs will hang indefinitely. Using (setq-local treesit-defun-type-regexp (rx (or "call"))) yields the same result. For the following node-at-point output (do_block (call target: (identifier))) with Elixir code # foo.ex defmodule Foo do <>def bar(), do: "bar" end When I call `(treesit-search-forward-goto (rx (or "call")) 'start nil t)` the function `treesit-search-forward` seems to get stuck. Elixir does not strictly have a begin function, but can be determined as one of the following: ; * modules and protocols (call target: (identifier) @ignore (arguments (alias) @name) (#match? @ignore "^(defmodule|defprotocol)$")) @definition.module ; * functions/macros (call target: (identifier) @ignore (arguments [ ; zero-arity functions with no parentheses (identifier) @name ; regular function clause (call target: (identifier) @name) ; function clause with a guard clause (binary_operator left: (call target: (identifier) @name) operator: "when") ]) (#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @definition.function The elixir tree sitter implementation is here: https://github.com/elixir-lang/tree-sitter-elixir I lack the knowledge to further debug this or find a clean workaround, but I'm almost sure that treesit-search-forward should never hang. In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-10-22 built on melissa.local Repository revision: 7c750343be6309a78d3fd289959bca241d9daf5d Repository branch: feature/tree-sitter Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Arch Linux Configured using: 'configure --with-tree-sitter --with-native-compilation' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON TREE-SITTER LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LANG: en_ZA.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t 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 emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa epg rfc6068 epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date comp comp-cstr warnings icons subr-x cl-extra help-mode bytecomp byte-compile cconv elixir-mode derived rx pcase cl-macs gv treesit cl-seq cl-loaddefs cl-lib rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-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 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 lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 81171 6071) (symbols 48 7449 0) (strings 32 20132 1351) (string-bytes 1 613689) (vectors 16 15685) (vector-slots 8 324392 11268) (floats 8 27 29) (intervals 56 211 0) (buffers 1008 11)) --000000000000be52c705eb9c89de Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I am attempting to implement treesit for the current = elixir-mode using the branch feature/trees-sitter. For implementing beginni= ng-of-defun-function using treesit I am running into an issue where the Ema= cs will hang indefinitely. Using (setq-local treesit-defun-type-regexp (rx = (or "call"))) yields the same result.

For the following node-at-point output

(do_b= lock (call target: (identifier)))

with Elixir code=

# foo.ex
defmodule Foo do
=C2=A0= <<point/cursor here>>def bar(), do: "bar"
end

When I call `(treesit-search-forward-goto (rx (or &qu= ot;call")) 'start nil t)` the function `treesit-search-forward` se= ems to get stuck.

Elixir does not strictly ha= ve a begin function, but can be determined as one of the following:
; * modules and protocols
(call
=C2=A0 target: (identifier) @ignor= e
=C2=A0 (arguments (alias) @name)
=C2=A0 (#match? @ignore "^(de= fmodule|defprotocol)$")) @definition.module

; * functions/macro= s
(call
=C2=A0 target: (identifier) @ignore
=C2=A0 (arguments
= =C2=A0 =C2=A0 [
=C2=A0 =C2=A0 =C2=A0 ; zero-arity functions with no pare= ntheses
=C2=A0 =C2=A0 =C2=A0 (identifier) @name
=C2=A0 =C2=A0 =C2=A0 = ; regular function clause
=C2=A0 =C2=A0 =C2=A0 (call target: (identifier= ) @name)
=C2=A0 =C2=A0 =C2=A0 ; function clause with a guard clause
= =C2=A0 =C2=A0 =C2=A0 (binary_operator
=C2=A0 =C2=A0 =C2=A0 =C2=A0 left: = (call target: (identifier) @name)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 operator: = "when")
=C2=A0 =C2=A0 ])
=C2=A0 (#match? @ignore "^(de= f|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$"= )) @definition.function

The elixir tree sitter= implementation is here: https://github.com/elixir-lang/tree-sitter-elixir

I lack the knowledge to further debug this or find a clean = workaround, but I'm almost sure that treesit-search-forward should neve= r hang.

In GNU Emacs 29.0.50 (build 3, x86_64= -pc-linux-gnu, GTK+ Version
=C2=A03.24.34, cairo version 1.17.6) of 2022= -10-22 built on melissa.local
Repository revision: 7c750343be6309a78d3fd= 289959bca241d9daf5d
Repository branch: feature/tree-sitter
Windowing = system distributor 'The X.Org Foundation', version 11.0.12101004System Description: Arch Linux

Configured using:
=C2=A0'conf= igure --with-tree-sitter --with-native-compilation'

Configured f= eatures:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFB= UZZ JPEG
JSON TREE-SITTER LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP N= OTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOO= LKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important s= ettings:
=C2=A0 value of $LANG: en_ZA.UTF-8
=C2=A0 locale-coding-syst= em: utf-8-unix

Major mode: Lisp Interaction

Minor modes in ef= fect:
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mode: t
=C2=A0 el= doc-mode: t
=C2=A0 show-paren-mode: t
=C2=A0 electric-indent-mode: t<= br>=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-mode: t
=C2=A0 menu-bar= -mode: t
=C2=A0 file-name-shadow-mode: t
=C2=A0 global-font-lock-mode= : t
=C2=A0 font-lock-mode: t
=C2=A0 blink-cursor-mode: t
=C2=A0 li= ne-number-mode: t
=C2=A0 indent-tabs-mode: t
=C2=A0 transient-mark-mo= de: t
=C2=A0 auto-composition-mode: t
=C2=A0 auto-encryption-mode: t<= br>=C2=A0 auto-compression-mode: t

Load-path shadows:
None found.=

Features:
(shadow sort mail-extr emacsbug message mailcap yank-m= edia puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa epg= rfc6068
epg-config gnus-util text-property-search mm-decode mm-bodies m= m-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc= 2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date comp
= comp-cstr warnings icons subr-x cl-extra help-mode bytecomp byte-compilecconv elixir-mode derived rx pcase cl-macs gv treesit cl-seq cl-loaddefscl-lib rmc iso-transl tooltip eldoc paren electric uniquify ediff-hookvc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common= -win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list r= eplace newcomment text-mode lisp-mode prog-mode register
page tab-bar me= nu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lo= ck font-lock syntax font-core term/tty-colors
frame minibuffer nadvice s= eq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc= -lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51= 932 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 fac= es cus-face macroexp files window
text-properties overlay sha1 md5 base6= 4 format env code-pages mule
custom widget keymap hashtable-print-readab= le backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-= setting font-render-setting
cairo move-toolbar gtk x-toolkit xinput2 x m= ulti-tty
make-network-process native-compile emacs)

Memory inform= ation:
((conses 16 81171 6071)
=C2=A0(symbols 48 7449 0)
=C2=A0(st= rings 32 20132 1351)
=C2=A0(string-bytes 1 613689)
=C2=A0(vectors 16 = 15685)
=C2=A0(vector-slots 8 324392 11268)
=C2=A0(floats 8 27 29)
= =C2=A0(intervals 56 211 0)
=C2=A0(buffers 1008 11))
--000000000000be52c705eb9c89de--