From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.devel Subject: Python interactive navigation around nested functions Date: Sat, 18 Jun 2016 21:52:47 -0700 Message-ID: <87lh21eq5c.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1466312008 30818 80.91.229.3 (19 Jun 2016 04:53:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Jun 2016 04:53:28 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 19 06:53:18 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 1bEUjV-0004oP-DO for ged-emacs-devel@m.gmane.org; Sun, 19 Jun 2016 06:53:17 +0200 Original-Received: from localhost ([::1]:37510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEUjQ-0006TM-Uj for ged-emacs-devel@m.gmane.org; Sun, 19 Jun 2016 00:53:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEUjL-0006SP-1Q for emacs-devel@gnu.org; Sun, 19 Jun 2016 00:53:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEUjH-0004y6-0I for emacs-devel@gnu.org; Sun, 19 Jun 2016 00:53:06 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:57966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEUjE-0004wz-I1 for emacs-devel@gnu.org; Sun, 19 Jun 2016 00:53:02 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 8569E20512 for ; Sun, 19 Jun 2016 00:52:49 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Sun, 19 Jun 2016 00:52:49 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=content-type:date:from:message-id:mime-version:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=5osSMiMmvy/41a2khaaVmySLJm0 =; b=mhrXIxAYPb524njr6eH3Ac0yqiDbpNjZLQ3QL0+anZt6B5DSYxqFnKe9tbi 6A9OIMiuLCfQxbisAR8xXlhvbIolEJnJ3tAGsCTmkD/qEg29IuiBpnhCwaLRXFWV JGnW4mB1kdkAHNbNADTimSuKuGKTBjNFsIP3eHhrjKXyIotk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=5o sSMiMmvy/41a2khaaVmySLJm0=; b=L+f8DZNOCPiPtARuAFpDjLPSEiwCk0P9MX +tI9ar5kMqnWau4Ki+gdJkgXFWUz1zBC7HrzhDYkAY1qjnllWFz1JUpkt5CSqcVl zsYQ/SWBqNnaKCTDPa7xVR7+xiwzHwR97g5NpujjmZusYHdlKRxepAJGDlTx0HTr ULsaB2Gr4= X-Sasl-enc: +pqOw1sck4WQSfD9eyt/wDqgiK2pveL4LpolhfY+kUwO 1466311969 Original-Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com [50.1.153.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 0DB58F29EE for ; Sun, 19 Jun 2016 00:52:49 -0400 (EDT) Original-Received: from dima by shorty.local with local (Exim 4.87) (envelope-from ) id 1bEUj1-0003S9-Pb for emacs-devel@gnu.org; Sat, 18 Jun 2016 21:52:47 -0700 User-agent: mu4e 0.9.17; emacs 25.0.94.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 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:204497 Archived-At: 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