GNU bug report logs - #13973
thingatpt.el and end-of-sexp in python-mode

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Sat, 16 Mar 2013 07:53:02 UTC

Severity: minor

Full log


Message #22 received at 13973 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 13973 <at> debbugs.gnu.org
Subject: Re: bug#13973: Subject: 24.3; thingatpt.el, end-of-sexp
Date: Mon, 23 Aug 2021 19:11:45 +0200
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?
>




This bug report was last modified 3 years and 40 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.