Subject: Re: bug#20897: 25.0.50; [python] sexp-movement are confusing

From: Andreas Röhler <[email-masked]>
Date: Thu, 25 Jun 2015 18:16:43 +0200

Am 25.06.2015 um 17:53 schrieb Rasmus:
> Hi,
>
> Sexp movement in python.el are very confusing to me.  I know that logical
> sexp movements outside lisp are subjective,

Not more as anything else editor-related. Languages are composed by 
elements, which a syntax may describe. Even if an editor must not be the 
slave of a syntax, it should be aware of.

>   and I know that the behavior
> isn't wrong.

It behaves arbitrary WRT Python syntax, that's wrong.

>   I understand why it does what it does.  The behavior is just
> confusing when I use it an practice.
>
> Example, starting from emacs -q:
>
> Open test.py
>
> Insert something like this, ignoring point denoted by "{v,^} {1,...,5}".
>
> 4  5   6
> v  v   v
> def foo(x):
>     """return x as one"""
>
>      x = 1;
>
>      return(x)
>     ^      ^  ^
>     2      3  1
>
> Consider points 1,...,5.  At point 2 forward-sexp will go to point 1, at
> point 3 backward-sexp will go to point 2.  At point 1, sexp-backward will
> go to 4 rather than point 2 (as I would expect).  Likewise, at point 4,
> forward sexp goes to point 1 rather than 5.  At point five, everything is
> as I would expect, and {forward,backward}-sexp goes to 6 and 4.
>
> A switch to prefer a closer opening/closing of the "sexp" at point would
> be great.
>
> Thanks,
> Rasmus
>

[ ... ]

Python is composed by expressions.
If inside an expression C-M-f should to to its end.

 From end to next end same level if existing - or level up, or next 
top-level-form, or nil at EOB

Backward and forward needs to be consistent.