bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11974: 24.1.50; python-nav-forward-sexp-function doesn't skip over s


From: Ivan Andrus
Subject: bug#11974: 24.1.50; python-nav-forward-sexp-function doesn't skip over strings
Date: Wed, 18 Jul 2012 14:29:39 +0200

Actually, the new function `python-nav-forward-sexp-function' doesn't do
what I expect at all.  I use forward-sexp, up-list and friends a lot,
so perhaps I'm not typical.  I do think sexp-like movement for python
would be AWESOME!  Let me show some use cases where the current
functionality is broken for me, and then attempt to articulate what I
would like/expect.  I shall always assume that forward-sexp has a
positive argument, and the obvious statements hold for negative
arguments.

In sage-mode we narrow to a docstring by doing the equivalent of

(let* ((bos (python-info-ppss-context 'string)))
  (goto-char bos)
  (forward-sexp 1)
  (narrow-to-region bos (point)))

This is broken now since forward-sexp goes to the end of the block, far
past the end of the string (or not moving at all).  If you have any
undindented code at the end of your buffer, then forward-sexp (and up-list)
will refuse to move past it e.g.

def main():
    2+3 # I get stuck here

print main()


What I would expect form a "perfect" python forward-sexp is to skip over
a block if and only if you are at the very beginning of the block.
Otherwise is should skip over a statement if and only if you are at the
beginning of a statement.  Otherwise is should act exactly as an
unmodified forward-sexp would, skipping over words, parenthesized
expressions, and strings.

I guess this is because I think of python as having a set of parens
around a block as well as parens around each statement in addition to
all parens and strings that are currently there.

I don't guarantee that this would be a good experience, but I think it
would.  Hopefully up-list would then move to the end of the block etc.
I'm not sure how to deal with down-list.  Perhaps going to the first
statement if it's at the beginning of a block and into a parenthesized
expression otherwise?

-Ivan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]