unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Basil Contovounesios <contovob@tcd.ie>
Cc: 44418@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>,
	Yuan Fu <casouri@gmail.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#44418: 28.0.50; Spliced variable not matched as symbol in isearch
Date: Fri, 23 Jun 2023 18:54:44 +0200	[thread overview]
Message-ID: <6A3C260E-F112-446C-A2DF-C2351709475A@gmail.com> (raw)
In-Reply-To: <1C3E6B87-79B5-4360-BC39-DC9F6381E7B3@gmail.com>

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

> 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.


[-- Attachment #2: treesit-alt-capture-construct.diff --]
[-- Type: application/octet-stream, Size: 1824 bytes --]

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, "@");
 }

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




  reply	other threads:[~2023-06-23 16:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 15:38 bug#44418: 28.0.50; Spliced variable not matched as symbol in isearch Basil L. Contovounesios
2022-06-07 10:29 ` Lars Ingebrigtsen
2022-06-07 12:05   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-07 17:45     ` Lars Ingebrigtsen
2022-06-07 18:20       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-07 18:28         ` Lars Ingebrigtsen
2022-06-08 12:29         ` Lars Ingebrigtsen
2023-06-21 15:59 ` Mattias Engdegård
2023-06-21 17:15   ` Eli Zaretskii
2023-06-22  8:50     ` Mattias Engdegård
2023-06-22 10:11       ` Eli Zaretskii
2023-06-22 11:24         ` Mattias Engdegård
2023-06-23 11:58   ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-23 12:06     ` Mattias Engdegård
2023-06-23 16:54       ` Mattias Engdegård [this message]
2023-06-23 22:39 ` Yuan Fu
2023-06-24  6:39   ` Eli Zaretskii
2023-06-24 10:12   ` Mattias Engdegård
2023-06-25 11:38     ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-08 23:48     ` Yuan Fu
2023-07-09  6:07       ` Eli Zaretskii
2023-07-09 12:36         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-12 15:09           ` Dmitry Gutov
2023-07-12 14:46       ` Mattias Engdegård
2023-07-12 15:26         ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-18  1:54           ` Dmitry Gutov
2023-07-18  8:35             ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6A3C260E-F112-446C-A2DF-C2351709475A@gmail.com \
    --to=mattias.engdegard@gmail.com \
    --cc=44418@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=contovob@tcd.ie \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).