unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Arash Esbati <arash@gnu.org>
To: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Python, syntax-ppss
Date: Mon, 06 Feb 2023 12:53:36 +0100	[thread overview]
Message-ID: <86v8kfqabj.fsf@gnu.org> (raw)
In-Reply-To: <3cd4eda0-a795-073a-81fd-b128d4871aee@easy-emacs.de> ("Andreas Röhler"'s message of "Mon, 6 Feb 2023 11:54:34 +0100")

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> when calling (syntax-ppss) at the end of the Python snippet below, it yields
>
> (1 6 7 34 nil nil 0 nil 8 (6) nil)
>
> whereas nth 1 --depth in parens--, should tell "2", as the opening
> curly bracket should count too:
>
> ---
> print(f"Addition: {m1 + m2
> ---

The 34 says that the point is inside a string, more precisely, this is
the character that will terminate the string[1] -- in this case " which
has the codepoint 34.  The parser doesn't count the depth in parens
inside strings.  Emacs sees only one open parentheses, and that in
buffer position 6.

Best, Arash

Footnotes:
[1]  https://www.gnu.org/software/emacs/manual/html_node/elisp/Parser-State.html



  reply	other threads:[~2023-02-06 11:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 10:54 Python, syntax-ppss Andreas Röhler
2023-02-06 11:53 ` Arash Esbati [this message]
2023-02-06 13:43   ` Andreas Röhler

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=86v8kfqabj.fsf@gnu.org \
    --to=arash@gnu.org \
    --cc=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).