From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#44418: 28.0.50; Spliced variable not matched as symbol in isearch Date: Fri, 23 Jun 2023 18:54:44 +0200 Message-ID: <6A3C260E-F112-446C-A2DF-C2351709475A@gmail.com> References: <16025AD0-9B58-4020-AEBF-C518D1CDE51A@gmail.com> <87fs6itmos.fsf@epfl.ch> <1C3E6B87-79B5-4360-BC39-DC9F6381E7B3@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_0042F261-D2A2-4267-8248-DED7BEEFA952" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12657"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44418@debbugs.gnu.org, Lars Ingebrigtsen , Yuan Fu , Stefan Monnier To: Basil Contovounesios Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 23 18:55:18 2023 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 1qCk46-00036k-NM for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Jun 2023 18:55:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCk3t-0008Fp-BH; Fri, 23 Jun 2023 12:55:05 -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 1qCk3r-0008FL-1J for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 12:55:03 -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 1qCk3q-0004bf-OI for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 12:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qCk3q-0004As-Hi for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 12:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Jun 2023 16:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44418 X-GNU-PR-Package: emacs Original-Received: via spool by 44418-submit@debbugs.gnu.org id=B44418.168753929616031 (code B ref 44418); Fri, 23 Jun 2023 16:55:02 +0000 Original-Received: (at 44418) by debbugs.gnu.org; 23 Jun 2023 16:54:56 +0000 Original-Received: from localhost ([127.0.0.1]:39443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCk3k-0004AU-76 for submit@debbugs.gnu.org; Fri, 23 Jun 2023 12:54:56 -0400 Original-Received: from mail-lj1-f170.google.com ([209.85.208.170]:59792) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCk3g-0004AF-80 for 44418@debbugs.gnu.org; Fri, 23 Jun 2023 12:54:54 -0400 Original-Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2b46773e427so14656761fa.3 for <44418@debbugs.gnu.org>; Fri, 23 Jun 2023 09:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687539286; x=1690131286; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=7oGEX8IKxHEkOxRg1YqdHq3J5MuEguL20PioX6WU6vg=; b=n541XY2ZppyVV4WCuf4qk0qgczGyHZB9w3wb2hHQUTo2eKpT1V4Zgh8zB0cBivxB0v eANbIE3c7Cg8FYcBFjcQzasBpbYFdxLzLJWyWPc+u+bk73gpjcK6AhFgm8ZH7IXiwexQ ihJF1DzR9jrDct1q05X4FcxU2nvF45rwqrE0rJ7jCiIOMHDA3JlH2lM6oO2UEqUbuUMl zGdzojy0WAnWuZaL+2vvNLZrJ2doAkcPrBbgySplxn/pK+ECf97PQFXpXQTnC9ORGk11 c5lzYbWAzdUDeaHO4GxabqOzPWPFZwpHAsKtj0VlUhuOuKBgq5WAUrZ7g1s2k+0/8mpi PfBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687539286; x=1690131286; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7oGEX8IKxHEkOxRg1YqdHq3J5MuEguL20PioX6WU6vg=; b=Z6P9T1I8LXACti0xgs2zxVVqOL8DNz4nZFSGpqkhYv9acRG76p5gPORy/7Lg/hHbxJ 1swKHXO5637aCLJkWMVk6BiSekwpU3QCGETo/l74Or1p07A1fzKAt6e35983jy797Qdn luPhf4p6iWe3UJbZ9g2eB+sIzRjWVNw2VtXW0ejKExYPXblvqeO30OBB/WSaLi/eS/fJ ZAZNxvZtc2xAQo5Al1vxar2XioDrPWy3pIOTEj/t5ufJuR3KUpPfkVc4XzQVhPm5RINd bJfZWq+IbmBCKqJLAkqqU45yzlbH3wUh6yBkUkkgntVb2wTmigSUGoOpmAFYRI5DhX1O Gdow== X-Gm-Message-State: AC+VfDzURUsyY/GF+9MJC2R/ZbutUXUcdWJUTVm4SpuBP21CZ0YOCcFB z83SH8RG3KrGjrBY6X5DIko= X-Google-Smtp-Source: ACHHUZ7+UXUF/7Tgp8omQly5D1cc20ih8UMz8a+royguyvWAHsUVv7PoNb99oZlpS1Q7FRekUNvq4A== X-Received: by 2002:a2e:9e44:0:b0:2a7:7055:97f5 with SMTP id g4-20020a2e9e44000000b002a7705597f5mr15124075ljk.0.1687539285827; Fri, 23 Jun 2023 09:54:45 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id h19-20020a2eb0f3000000b002b3318c8d6fsm1792748ljl.28.2023.06.23.09.54.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2023 09:54:45 -0700 (PDT) In-Reply-To: <1C3E6B87-79B5-4360-BC39-DC9F6381E7B3@gmail.com> X-Mailer: Apple Mail (2.3654.120.0.1.15) 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263964 Archived-At: --Apple-Mail=_0042F261-D2A2-4267-8248-DED7BEEFA952 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > Maybe we can introduce (@ NAME) as alternative syntax? Here is a proof-of-concept (missing tests and documentation), but it = works and I think it's a definite improvement. Maybe we can get a blessing from Yuan Fu. To recap, this permits the = syntax (@ symbol-name) as an alternative to @symbol-name in treesit = queries because that allows symbol searching to match the symbol-name, = and this can be really helpful. --Apple-Mail=_0042F261-D2A2-4267-8248-DED7BEEFA952 Content-Disposition: attachment; filename=treesit-alt-capture-construct.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="treesit-alt-capture-construct.diff" Content-Transfer-Encoding: 7bit diff --git a/src/treesit.c b/src/treesit.c index 87aa1eeb377..64570094347 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -2358,6 +2358,7 @@ DEFUN ("treesit-pattern-expand", (TYPE PATTERN...) [PATTERN...] FIELD-NAME: + (@ CAPTURE-NAME) @CAPTURE-NAME (_) _ @@ -2380,18 +2381,27 @@ DEFUN ("treesit-pattern-expand", return Vtreesit_str_pound_match; if (BASE_EQ (pattern, QCpred)) return Vtreesit_str_pound_pred; - Lisp_Object opening_delimeter - = VECTORP (pattern) - ? Vtreesit_str_open_bracket : Vtreesit_str_open_paren; - Lisp_Object closing_delimiter - = VECTORP (pattern) - ? Vtreesit_str_close_bracket : Vtreesit_str_close_paren; + + /* (@ X) -> @Y where X -> Y */ + if (CONSP (pattern) && BASE_EQ (XCAR (pattern), Qat) + && CONSP (XCDR (pattern)) && NILP (XCDR (XCDR (pattern)))) + return concat2 (build_string ("@"), + Ftreesit_pattern_expand (XCAR (XCDR (pattern)))); + if (VECTORP (pattern) || CONSP (pattern)) + { + Lisp_Object opening_delimeter + = VECTORP (pattern) + ? Vtreesit_str_open_bracket : Vtreesit_str_open_paren; + Lisp_Object closing_delimiter + = VECTORP (pattern) + ? Vtreesit_str_close_bracket : Vtreesit_str_close_paren; return concat3 (opening_delimeter, Fmapconcat (Qtreesit_pattern_expand, pattern, Vtreesit_str_space), closing_delimiter); + } if (STRINGP (pattern)) return treesit_query_string_string (pattern); @@ -2414,6 +2424,7 @@ DEFUN ("treesit-query-expand", (TYPE PATTERN...) [PATTERN...] FIELD-NAME: + (@ CAPTURE-NAME) @CAPTURE-NAME (_) _ @@ -4101,4 +4112,6 @@ syms_of_treesit (void) defsubr (&Streesit_subtree_stat); #endif /* HAVE_TREE_SITTER */ defsubr (&Streesit_available_p); + + DEFSYM (Qat, "@"); } --Apple-Mail=_0042F261-D2A2-4267-8248-DED7BEEFA952 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_0042F261-D2A2-4267-8248-DED7BEEFA952--