From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Python interactive navigation around nested functions Date: Sun, 19 Jun 2016 22:43:00 -0400 Message-ID: References: <87lh21eq5c.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1466390641 14614 80.91.229.3 (20 Jun 2016 02:44:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 02:44:01 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 20 04:43:47 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bEpBh-00077d-Go for ged-emacs-devel@m.gmane.org; Mon, 20 Jun 2016 04:43:45 +0200 Original-Received: from localhost ([::1]:40893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEpBg-0006LC-ND for ged-emacs-devel@m.gmane.org; Sun, 19 Jun 2016 22:43:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEpBA-0006J9-L4 for emacs-devel@gnu.org; Sun, 19 Jun 2016 22:43:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEpB6-0000p9-Fp for emacs-devel@gnu.org; Sun, 19 Jun 2016 22:43:11 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:49810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEpB6-0000p5-8B for emacs-devel@gnu.org; Sun, 19 Jun 2016 22:43:08 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1bEpB4-0006dw-8x for emacs-devel@gnu.org; Mon, 20 Jun 2016 04:43:06 +0200 Original-Received: from 45.72.244.67 ([45.72.244.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 Jun 2016 04:43:06 +0200 Original-Received: from monnier by 45.72.244.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 Jun 2016 04:43:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 32 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 45.72.244.67 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:f4cWTc4GmWfK91kEbwnuhWR9TnI= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204559 Archived-At: > 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