[Top][All Lists]

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

Re: Python interactive navigation around nested functions

From: Andreas Röhler
Subject: Re: Python interactive navigation around nested functions
Date: Mon, 20 Jun 2016 09:14:05 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Icedove/45.1.0

On 20.06.2016 04:43, Stefan Monnier wrote:
         def wwrap(f):
             print 'Inside wwrap()'
             def wrapped_f(*args):
                 print 'Inside wrapped_f()'
                 print 'Decorator arguments:', arg1, arg2, arg3
                 print 'After f(*args)'
             return wrapped_f
         return wwrap
The point is on "return wrapped_f".  The user then hits C-M-a to navigate
to the beginning of the current function.  The point is unambiguously
inside wwrap() and not inside wrapped_f(), so I claim it should end up
at the "def wwrap(f)" line.  However the current behavior (and that test
suite check) say it should end up on "def "wrapped_f()".
[ Note: the below is the view from the generic side of Emacs, because
   I don't know much about Python in general and python-mode
   in particular.  ]

Traditionally (IMO), C-M-a goes to the nearest beginning of defun at the
same AST level or higher.  So from "return wrapped_f", it seems reasonable
to jump to "def wrapped_f(*args):".

If you want to jump to the beginning of the enclosing defun, I think we
need another function, which currently doesn't exist in the "generic"
part of Emacs.  If C-M-a always jumped to the beginning of the enclosing
defun, then it would always jump to BOB when called from outside
a function, and that's clearly not how it behaves usually.


It's not about jumping to enclosing function --which would mean upwards--
but reaching the AST level entry node.

This is a bug, noted for python-mode.el too:

reply via email to

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