From: Dmitry Lazurkin <dilaz03@gmail.com>
To: npostavs@users.sourceforge.net
Cc: 24820@debbugs.gnu.org
Subject: bug#24820: Imenu in `python-mode' does not display function name for async def
Date: Thu, 5 Jan 2017 23:20:44 +0300 [thread overview]
Message-ID: <1c0184af-67cd-edd3-85a0-9543ead3e6e3@gmail.com> (raw)
In-Reply-To: <8760lu5eue.fsf_-_@users.sourceforge.net>
[-- Attachment #1: Type: text/plain, Size: 4155 bytes --]
On 01/05/2017 07:07 AM, npostavs@users.sourceforge.net wrote:
> I don't see any formatting problems in your code, but it looks like the
> patch got word wrapped, I find sending as attachment generally avoids
> such issues.
This is strange because email from my sent emails has not wrapping problem...
Try to send patch in body and in attachment:
From 730e455bdba33849bf47126527cc8ca477ebbb82 Mon Sep 17 00:00:00 2001
From: Dmitry Lazurkin <dilaz03@gmail.com>
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
[-- Attachment #2: 0001-Fix-extracting-async-def-type-and-name-in-python-mod.patch --]
[-- Type: text/x-patch, Size: 3765 bytes --]
From 730e455bdba33849bf47126527cc8ca477ebbb82 Mon Sep 17 00:00:00 2001
From: Dmitry Lazurkin <dilaz03@gmail.com>
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
next prev parent reply other threads:[~2017-01-05 20:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-29 14:34 bug#24820: Imenu in `python-mode' does not display function name for async def Dmitry Lazurkin
2016-12-23 17:32 ` bug#24820: Any suggestions about patch? Dmitry Lazurkin
2016-12-26 22:26 ` npostavs
2017-01-04 16:48 ` bug#24820: I think copyright is assigned Dmitry Lazurkin
2017-01-04 16:55 ` Eli Zaretskii
2017-01-04 20:24 ` bug#24820: Rebase against master Dmitry Lazurkin
2017-01-04 20:27 ` Dmitry Lazurkin
2017-01-05 4:07 ` bug#24820: Imenu in `python-mode' does not display function name for async def npostavs
2017-01-05 10:14 ` Dmitry Lazurkin
2017-01-06 1:19 ` npostavs
2017-01-06 12:07 ` Dmitry Lazurkin
2017-01-06 14:00 ` npostavs
2017-01-06 19:41 ` Dmitry Lazurkin
2017-01-13 1:49 ` npostavs
2017-01-13 9:34 ` dilaz03 .
2017-01-05 20:20 ` Dmitry Lazurkin [this message]
2017-01-05 21:03 ` Dmitry Lazurkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c0184af-67cd-edd3-85a0-9543ead3e6e3@gmail.com \
--to=dilaz03@gmail.com \
--cc=24820@debbugs.gnu.org \
--cc=npostavs@users.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.