GNU bug report logs -
#13973
thingatpt.el and end-of-sexp in python-mode
Previous Next
To reply to this bug, email your comments to 13973 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Sat, 16 Mar 2013 07:53:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Andreas Röhler <andreas.roehler <at> easy-emacs.de>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 16 Mar 2013 07:53:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
(defun end-of-sexp ()
"Move point to the end of the current sexp.
\[This is an internal function.]"
(let ((char-syntax (char-syntax (char-after))))
(if (or (eq char-syntax ?\))
(and (eq char-syntax ?\") (in-string-p)))
(forward-char 1)
(forward-sexp 1))))
"or" asks if inside a string and calls (forward-char 1).
This must fail with some probability with
triple-quoted-strings as used in Python.
Solution:
When inside a string, jump to (nth 8 (syntax-ppss)) and
call (forward-sexp 1) from there.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Sat, 16 Mar 2013 10:36:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On 2013-03-16 15:51 +0800, Andreas Röhler wrote:
> When inside a string, jump to (nth 8 (syntax-ppss)) and
> call (forward-sexp 1) from there.
In my experience (a while ago, I use little python these days) this
cannot reliably goes to the end of the triple-quoted string.
Leo
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Sat, 16 Mar 2013 12:11:01 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
Am 16.03.2013 11:33, schrieb Leo Liu:
> On 2013-03-16 15:51 +0800, Andreas Röhler wrote:
>> When inside a string, jump to (nth 8 (syntax-ppss)) and
>> call (forward-sexp 1) from there.
>
> In my experience (a while ago, I use little python these days) this
> cannot reliably goes to the end of the triple-quoted string.
>
> Leo
>
>
>
>
>
Indeed seems a bug in python-mode.el at this place just now.
Anyway - forward-sexp must go to the end of string from it's beginning,
a string is a balanced expression.
Best,
Andreas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Sat, 16 Mar 2013 13:52:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 13973 <at> debbugs.gnu.org (full text, mbox):
>> When inside a string, jump to (nth 8 (syntax-ppss)) and
>> call (forward-sexp 1) from there.
Sounds right, yes.
> In my experience (a while ago, I use little python these days) this
> cannot reliably goes to the end of the triple-quoted string.
That would be a bug in python-mode, then.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Mon, 23 Aug 2021 01:10:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 13973 <at> debbugs.gnu.org (full text, mbox):
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
> (defun end-of-sexp ()
> "Move point to the end of the current sexp.
> \[This is an internal function.]"
> (let ((char-syntax (char-syntax (char-after))))
> (if (or (eq char-syntax ?\))
> (and (eq char-syntax ?\") (in-string-p)))
> (forward-char 1)
> (forward-sexp 1))))
>
> "or" asks if inside a string and calls (forward-char 1).
>
> This must fail with some probability with
> triple-quoted-strings as used in Python.
>
> Solution:
>
> When inside a string, jump to (nth 8 (syntax-ppss)) and
> call (forward-sexp 1) from there.
(I'm going through old bug reports that unfortunately weren't resolved
at the time.)
It's not quite clear to me what the actual problem here is. Do you have
a test case where thingatpt does the wrong thing in Python mode?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 23 Aug 2021 01:10:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Mon, 23 Aug 2021 17:12:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 13973 <at> debbugs.gnu.org (full text, mbox):
On 23.08.21 03:09, Lars Ingebrigtsen wrote:
> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>
>> (defun end-of-sexp ()
>> "Move point to the end of the current sexp.
>> \[This is an internal function.]"
>> (let ((char-syntax (char-syntax (char-after))))
>> (if (or (eq char-syntax ?\))
>> (and (eq char-syntax ?\") (in-string-p)))
>> (forward-char 1)
>> (forward-sexp 1))))
>>
>> "or" asks if inside a string and calls (forward-char 1).
>>
>> This must fail with some probability with
>> triple-quoted-strings as used in Python.
>>
>> Solution:
>>
>> When inside a string, jump to (nth 8 (syntax-ppss)) and
>> call (forward-sexp 1) from there.
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> It's not quite clear to me what the actual problem here is.
It's only abstract reasoning when looking at the code.
Maybe put the Python code below at the top of some buffer and run the
test delivered below:
# Python
def main():
"""Some hint"""
if len(sys.argv) == 1:
usage()
;; Elisp
(defun forward-sexp-text ()
(interactive)
(goto-char 30 )
(forward-sexp))
> Do you have
> a test case where thingatpt does the wrong thing in Python mode?
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Wed, 25 Aug 2021 10:40:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 13973 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
> Maybe put the Python code below at the top of some buffer and run the
> test delivered below:
>
> # Python
>
> def main():
> """Some hint"""
> if len(sys.argv) == 1:
> usage()
>
> ;; Elisp
> (defun forward-sexp-text ()
> (interactive)
> (goto-char 30 )
> (forward-sexp))
By that goto-char, do you mean the "S" character? (It's where point
lands in the buffer included below.) If so, `forward-sex'
(in Emacs 28) does the correct thing -- it moves to the end of "Some".
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
[sexp.py (text/x-python, inline)]
# Python
def main():
"""Some hint"""
if len(sys.argv) == 1:
usage()
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Thu, 26 Aug 2021 06:22:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 13973 <at> debbugs.gnu.org (full text, mbox):
On 25.08.21 12:38, Lars Ingebrigtsen wrote:
> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>
>> Maybe put the Python code below at the top of some buffer and run the
>> test delivered below:
>>
>> # Python
>>
>> def main():
>> """Some hint"""
>> if len(sys.argv) == 1:
>> usage()
>>
>> ;; Elisp
>> (defun forward-sexp-text ()
>> (interactive)
>> (goto-char 30 )
>> (forward-sexp))
> By that goto-char, do you mean the "S" character?
No, sorry, the 5th double-quote of the triple-quoted-string.
> (It's where point
> lands in the buffer included below.) If so, `forward-sex'
> (in Emacs 28) does the correct thing -- it moves to the end of "Some".
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Thu, 26 Aug 2021 14:06:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 13973 <at> debbugs.gnu.org (full text, mbox):
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>>> Maybe put the Python code below at the top of some buffer and run the
>>> test delivered below:
>>>
>>> # Python
>>>
>>> def main():
>>> """Some hint"""
>>> if len(sys.argv) == 1:
>>> usage()
>>>
>>> ;; Elisp
>>> (defun forward-sexp-text ()
>>> (interactive)
>>> (goto-char 30 )
>>> (forward-sexp))
>> By that goto-char, do you mean the "S" character?
>
> No, sorry, the 5th double-quote of the triple-quoted-string.
That gives me
forward-sexp: Scan error: "Unbalanced parentheses", 40, 86
which I think is the right thing?
This bug report started with thingatpt. What is the real thingatpt use
case that doesn't work in triple-quoted strings?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Fri, 27 Aug 2021 18:45:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 13973 <at> debbugs.gnu.org (full text, mbox):
On 26.08.21 16:05, Lars Ingebrigtsen wrote:
> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>
>>>> Maybe put the Python code below at the top of some buffer and run the
>>>> test delivered below:
>>>>
>>>> # Python
>>>>
>>>> def main():
>>>> """Some hint"""
>>>> if len(sys.argv) == 1:
>>>> usage()
>>>>
>>>> ;; Elisp
>>>> (defun forward-sexp-text ()
>>>> (interactive)
>>>> (goto-char 30 )
>>>> (forward-sexp))
>>> By that goto-char, do you mean the "S" character?
>> No, sorry, the 5th double-quote of the triple-quoted-string.
> That gives me
>
> forward-sexp: Scan error: "Unbalanced parentheses", 40, 86
>
> which I think is the right thing?
If inside a string, forward-sexp --or end-of-- should reach the end of
this string.
BTW end-of-sexp is declared obsolete meanwhile. Below an adapted test.
(defun my-thing-at-point--end-of-sexp-test ()
(interactive)
(goto-char (point-max))
(search-backward "\"" nil t 6)
;; the only one ending correctly behind the string
(thing-at-point--end-of-sexp)
(goto-char (point-max))
(search-backward "\"" nil t 6)
(forward-char 4)
(thing-at-point--end-of-sexp)
(goto-char (point-max))
(search-backward "\"" nil t 3)
(thing-at-point--end-of-sexp)
(goto-char (point-max))
(search-backward "\"" nil t 2)
(thing-at-point--end-of-sexp))
and here the Python code to test again:
def main():
"""Some hint"""
if len(sys.argv) == 1:
usage()
>
> This bug report started with thingatpt. What is the real thingatpt use
> case that doesn't work in triple-quoted strings?
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13973
; Package
emacs
.
(Sat, 28 Aug 2021 15:06:01 GMT)
Full text and
rfc822 format available.
Message #37 received at 13973 <at> debbugs.gnu.org (full text, mbox):
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
> BTW end-of-sexp is declared obsolete meanwhile. Below an adapted test.
Thanks. The odd movements happen in these cases:
"|""Some hint"""
"""Some hint|"""
where | is point.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Removed tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 27 Sep 2021 10:51:03 GMT)
Full text and
rfc822 format available.
Changed bug title to 'thingatpt.el and end-of-sexp in python-mode' from 'Subject: 24.3; thingatpt.el, end-of-sexp'
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 05 May 2022 12:18:02 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 39 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.