emacs-devel
[Top][All Lists]
Advanced

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

Re: Python interactive navigation around nested functions


From: Stefan Monnier
Subject: Re: Python interactive navigation around nested functions
Date: Sun, 19 Jun 2016 22:43:00 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

>         def wwrap(f):
>             print 'Inside wwrap()'
>             def wrapped_f(*args):
>                 print 'Inside wrapped_f()'
>                 print 'Decorator arguments:', arg1, arg2, arg3
>                 f(*args)
>                 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.


        Stefan




reply via email to

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