From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Lazurkin Newsgroups: gmane.emacs.bugs Subject: bug#24820: Rebase against master Date: Wed, 4 Jan 2017 23:24:54 +0300 Message-ID: <9982d241-51f3-c77b-cc00-36d85c6d8365@gmail.com> References: <2a59e0dc-45f4-b482-475a-d8db7e5c2ef6@gmail.com> <442b97a3-f05a-e142-0d56-4e2b9adeec89@gmail.com> <83r34iepej.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1483561644 26849 195.159.176.226 (4 Jan 2017 20:27:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Jan 2017 20:27:24 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 Cc: 24820@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 04 21:27:20 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOs9W-0006D7-NA for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Jan 2017 21:27:18 +0100 Original-Received: from localhost ([::1]:41735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOs9a-0006bV-LI for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Jan 2017 15:27:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOs8M-0005VB-8m for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 15:26:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOs8I-0003Bv-W8 for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 15:26:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54302) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cOs8I-0003Bp-T5 for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 15:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cOs8I-0007hm-2w for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 15:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Lazurkin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Jan 2017 20:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24820 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24820-submit@debbugs.gnu.org id=B24820.148356150529544 (code B ref 24820); Wed, 04 Jan 2017 20:26:02 +0000 Original-Received: (at 24820) by debbugs.gnu.org; 4 Jan 2017 20:25:05 +0000 Original-Received: from localhost ([127.0.0.1]:41467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOs7M-0007gQ-HK for submit@debbugs.gnu.org; Wed, 04 Jan 2017 15:25:04 -0500 Original-Received: from mail-lf0-f44.google.com ([209.85.215.44]:33472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOs7J-0007ff-TB for 24820@debbugs.gnu.org; Wed, 04 Jan 2017 15:25:02 -0500 Original-Received: by mail-lf0-f44.google.com with SMTP id k86so22462538lfi.0 for <24820@debbugs.gnu.org>; Wed, 04 Jan 2017 12:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=GCEO4MBDQjppgNSOIvL4Jqsk1nYh02C3ER1N94T5oLQ=; b=kCQDntJ/1fapS03glBbFRoa8awnw4oiZN9g4Nagx+1lhozqMowGEV2OOI5KtoNyh5t b3DpnccGSjlC6yGsue7El3R/hX4toS+IEpNfRGzGlAcYWiZMTGhzJQWDeOlfcC/yww7z A/lHK8C2NNNqdux65WVdGn5jXu7+T/RQov5NEEbDr7zyLGu/SALhzu4JtdV3C0kiZMuz mCC0A897DVxrnCjZlZnQgb81HlgbIbE3vIQkF/XFx2mMBnnhRyOPCF9v/1FrV/cwA4YZ gqeHMG5T2cTC5xsL0jHIZWRfuFC5H16U08jYzKC7wIxTlGplCuaWtxJ6lYukBN+sX9Ds tkmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=GCEO4MBDQjppgNSOIvL4Jqsk1nYh02C3ER1N94T5oLQ=; b=Z42Z0F5434d3ODPr1AJouN6bHO1ToNA/ZtuY0pJ/4oiu0F0Eecq8fKQY2EMHWRX4wR eHq7J9KddAn6WuxoIE08lzeIGDJWJCfI051zs8B2DPivE/XD5O2qaTcoq1sh5ObEnu05 3HFuk6dTJKqREtjjw1RLLjmrtLWQClw1IAAImACQpSzKajxx0xXpFaO/KDIQ4tM6peuX GTDevcwsrNAF0WfvRmpKPJEQSfd/buo+yamlDnFwtvsnMXigIv/qQ499tbdrWvvulpaw 1uIar8ib0BuorC/sq+i4ObMLrFfGd74qfUxNEIwXozhHxCirwtb4+xKhe1IcSf2Ay6vp ZiEw== X-Gm-Message-State: AIkVDXIFx9rFQPgY2FpdKxaEMXI0kiPWtVjR3AXtlqLalAtgxJEKGdAeMToaYPIKtGwa9Q== X-Received: by 10.46.78.1 with SMTP id c1mr22997076ljb.39.1483561495621; Wed, 04 Jan 2017 12:24:55 -0800 (PST) Original-Received: from [192.168.1.101] (nat4-minsk-pool-46-53-176-8.telecom.by. [46.53.176.8]) by smtp.gmail.com with ESMTPSA id j32sm17869720lfi.0.2017.01.04.12.24.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jan 2017 12:24:55 -0800 (PST) In-Reply-To: <83r34iepej.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127755 Archived-At: From 730e455bdba33849bf47126527cc8ca477ebbb82 Mon Sep 17 00:00:00 2001 From: Dmitry Lazurkin Date: Wed, 4 Jan 2017 21:46:21 +0300 Subject: [PATCH] Fix extracting async def type and name in python mode imenu * lisp/progmodes/python.el (python-imenu--get-defun-type-name): New function. (python-imenu--build-tree): Use python-imenu--get-defun-type-name for extract async or simple def type and name at current position. * test/lisp/progmodes/python-tests.el (python-imenu-create-index-1): (python-imenu-create-flat-index-1): Add async def's. --- lisp/progmodes/python.el | 17 ++++++++++++----- test/lisp/progmodes/python-tests.el | 12 ++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 68e19ef..d8262dd 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4415,6 +4415,15 @@ python-imenu-format-parent-item-jump-label "*class definition*" "*function definition*")) +(defun python-imenu--get-defun-type-name () + "Return defun type and name at current position." + (when (looking-at python-nav-beginning-of-defun-regexp) + (let ((split (split-string (match-string-no-properties 0)))) + (if (= (length split) 2) + split + (list (concat (car split) " " (cadr split)) + (car (last split))))))) + (defun python-imenu--put-parent (type name pos tree) "Add the parent with TYPE, NAME and POS to TREE." (let ((label @@ -4432,11 +4441,9 @@ python-imenu--build-tree (setq min-indent (or min-indent 0) prev-indent (or prev-indent python-indent-offset)) (let* ((pos (python-nav-backward-defun)) - (type) - (name (when (and pos (looking-at python-nav-beginning-of-defun-regexp)) - (let ((split (split-string (match-string-no-properties 0)))) - (setq type (car split)) - (cadr split)))) + (defun-type-name (and pos (python-imenu--get-defun-type-name))) + (type (car defun-type-name)) + (name (cadr defun-type-name)) (label (when name (funcall python-imenu-format-item-label-function type name))) (indent (current-indentation)) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 94c356b..2df1bbf 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -3559,6 +3559,9 @@ python-tests-shell-interpreter def c(self): pass + + async def d(self): + pass " (goto-char (point-max)) (should (equal @@ -3580,7 +3583,8 @@ python-tests-shell-interpreter (list "Frob (class)" (cons "*class definition*" (copy-marker 601)) - (cons "c (def)" (copy-marker 626))))) + (cons "c (def)" (copy-marker 626)) + (cons "d (async def)" (copy-marker 665))))) (python-imenu-create-index))))) (ert-deftest python-imenu-create-index-2 () @@ -3702,6 +3706,9 @@ python-tests-shell-interpreter def c(self): pass + + async def d(self): + pass " (goto-char (point-max)) (should (equal @@ -3714,7 +3721,8 @@ python-tests-shell-interpreter (cons "Baz.a" (copy-marker 539)) (cons "Baz.b" (copy-marker 570)) (cons "Baz.Frob" (copy-marker 601)) - (cons "Baz.Frob.c" (copy-marker 626))) + (cons "Baz.Frob.c" (copy-marker 626)) + (cons "Baz.Frob.d" (copy-marker 665))) (python-imenu-create-flat-index))))) (ert-deftest python-imenu-create-flat-index-2 () -- 2.7.4