unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11974: 24.1.50; python-nav-forward-sexp-function doesn't skip over strings
@ 2012-07-18 12:29 Ivan Andrus
  2012-07-19  7:52 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Ivan Andrus @ 2012-07-18 12:29 UTC (permalink / raw)
  To: 11974

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





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

end of thread, other threads:[~2012-09-28 21:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-18 12:29 bug#11974: 24.1.50; python-nav-forward-sexp-function doesn't skip over strings Ivan Andrus
2012-07-19  7:52 ` Stefan Monnier
2012-07-19 19:40   ` Ivan Andrus
     [not found]   ` <D3BE0B6C-F35A-4E54-A68C-FAB0F92E30D8@gmail.com>
2012-07-19 22:54     ` Stefan Monnier
2012-09-28 21:18       ` Ivan Andrus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).