all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Python, syntax-ppss
@ 2023-02-06 10:54 Andreas Röhler
  2023-02-06 11:53 ` Arash Esbati
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Röhler @ 2023-02-06 10:54 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

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

Right?

Thanks,

Andreas

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, 
cairo version 1.16.0) of 2023-02-01




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python, syntax-ppss
  2023-02-06 10:54 Python, syntax-ppss Andreas Röhler
@ 2023-02-06 11:53 ` Arash Esbati
  2023-02-06 13:43   ` Andreas Röhler
  0 siblings, 1 reply; 3+ messages in thread
From: Arash Esbati @ 2023-02-06 11:53 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python, syntax-ppss
  2023-02-06 11:53 ` Arash Esbati
@ 2023-02-06 13:43   ` Andreas Röhler
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Röhler @ 2023-02-06 13:43 UTC (permalink / raw)
  To: Arash Esbati; +Cc: help-gnu-emacs


Am 06.02.23 um 12:53 schrieb Arash Esbati:
> 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


Thanks. So I have to provide some extra checks for this case.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-06 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-06 10:54 Python, syntax-ppss Andreas Röhler
2023-02-06 11:53 ` Arash Esbati
2023-02-06 13:43   ` Andreas Röhler

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.