all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: "Gerd Möllmann" <gerd.moellmann@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Qeustion about Ftreesit_pattern_expand
Date: Tue, 25 Jun 2024 22:13:04 -0700	[thread overview]
Message-ID: <061A0C36-1316-4F81-A7A4-AAE1EF78789C@gmail.com> (raw)
In-Reply-To: <m2tthgl2dy.fsf@pro2.fritz.box>



> On Jun 25, 2024, at 10:05 PM, Gerd Möllmann <gerd.moellmann@gmail.com> wrote:
> 
> Yuan Fu <casouri@gmail.com> writes:
> 
>>> On Jun 24, 2024, at 2:26 PM, Gerd Möllmann <gerd.moellmann@gmail.com> wrote:
>>> 
>>> Not important, just as context: I wanted to see if igc works with
>>> treesit Lisp objects, built with treesitter, and finally even got
>>> grammars for C and C++ installed :-/. Font-locking didn't work in my
>>> fork (CL packages), which I fixed.
>>> 
>>> My question:
>>> 
>>> Function Ftreesit_pattern_expand uses this to print Lisp objects:
>>> 
>>> return Fprin1_to_string (pattern, Qnil, Qt);
>>> 
>>> where prin1 prints readably, and second arg nil means add escapes as
>>> needed to that the result can be read back, by function read.
>>> 
>>> Why is it printing readably with escapes?
>>> 
>>> I know tree-sitter doesn't understand Lisp escaping because that was my
>>> problem with the font-locking. Or, in other words, should the second arg
>>> be Qt for don't escape?
>>> 
>> 
>> Thanks for checking this Gerd. IIUC, readably is controlled by the
>> second argument, so it’s not redundant: if the second arg is Qnil,
>> print readably (prin1), if it’s Qt, print without quotes and escapes
>> (princ). I guess the function should’ve been called print-to-string to
>> avoid confusion.
> 
> Erm, there's a misunderstanding it seems. I'm not talking about function
> names or anything, I'm basically saying that the function call to
> Fprin1_to_string is wrong, and its second argument should be Qt
> not Qnil :-)

Ah, then I can explain. Basically I want to convert the sexp query

((function_definition) @defun
 "return" @keyword)

to a string that’s like this

"((function_definition) @defun
 "return" @keyword)"

If the second arg is Qt, the result would be

"((function_definition) @defun
 return @keyword)"

which is not what I want. Basically, strings need to be still quoted.

Yuan


  reply	other threads:[~2024-06-26  5:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 21:26 Qeustion about Ftreesit_pattern_expand Gerd Möllmann
2024-06-26  4:54 ` Yuan Fu
2024-06-26  5:05   ` Gerd Möllmann
2024-06-26  5:13     ` Yuan Fu [this message]
2024-06-26  5:34       ` Gerd Möllmann
2024-06-26  6:04         ` Yuan Fu
2024-06-26  6:16           ` Gerd Möllmann

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

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

  git send-email \
    --in-reply-to=061A0C36-1316-4F81-A7A4-AAE1EF78789C@gmail.com \
    --to=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=gerd.moellmann@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.