unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Python interactive navigation around nested functions
@ 2016-06-19  4:52 Dima Kogan
  2016-06-20  2:43 ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Dima Kogan @ 2016-06-19  4:52 UTC (permalink / raw)
  To: emacs-devel

Hi. The current way python-mode handles nested functions seems wrong to
me. I had thought that it was a bug, but the test suite explicitly
checks for the current behavior, so I want to ask about it here before
proposing a patch.

This is the first check in the (python-nav-beginning-of-defun-1) test in
test/automated/python-tests.el. Let's say you have a python buffer:

    def decoratorFunctionWithArguments(arg1, arg2, arg3):
        '''print decorated function call data to stdout.

        Usage:

        @decoratorFunctionWithArguments('arg1', 'arg2')
        def func(a, b, c=True):
            pass
        '''

        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()".

This seems wrong. In fact, there are two different "go-to-previous-def"
functions: one that supposedly handles nested defuns
(python-nav-beginning-of-defun) and one that doesn't
(python-nav-backward-defun), and it doesn't make sense that they both do
the same thing here. 

I propose to make C-M-a to go to "def wwrap" here. I already have the
patches ready, but the test case is giving me pause.

dima



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

end of thread, other threads:[~2016-06-27  6:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-19  4:52 Python interactive navigation around nested functions Dima Kogan
2016-06-20  2:43 ` Stefan Monnier
2016-06-20  7:14   ` Andreas Röhler
2016-06-20  7:34     ` Stefan Monnier
2016-06-20  8:28       ` Andreas Röhler
2016-06-20 13:57         ` Clément Pit--Claudel
2016-06-20 16:23           ` Andreas Röhler
2016-06-21  5:45   ` Dima Kogan
2016-06-21  6:05     ` Dima Kogan
2016-06-21  6:21       ` Stefan Monnier
2016-06-24 22:10         ` Dima Kogan
2016-06-24 23:23           ` Clément Pit--Claudel
2016-06-26 19:29             ` Andreas Röhler
2016-06-27  0:39               ` Clément Pit--Claudel
2016-06-27  6:02                 ` Andreas Röhler
2016-06-25  0:18           ` Stefan Monnier
2016-06-26 19:37             ` Andreas Röhler
2016-06-21  6:32       ` Andreas Röhler
2016-06-21  6:26     ` Andreas Röhler

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).