* bug#24820: Imenu in `python-mode' does not display function name for async def @ 2016-10-29 14:34 Dmitry Lazurkin 2016-12-23 17:32 ` bug#24820: Any suggestions about patch? Dmitry Lazurkin 2017-01-04 16:48 ` bug#24820: I think copyright is assigned Dmitry Lazurkin 0 siblings, 2 replies; 17+ messages in thread From: Dmitry Lazurkin @ 2016-10-29 14:34 UTC (permalink / raw) To: 24820 Package: emacs Version: 25 Tags: patch From 9429522de96c27980f61bc107c4801216994d80b Mon Sep 17 00:00:00 2001 From: Dmitry Lazurkin <dilaz03@gmail.com> Date: Sat, 29 Oct 2016 16:51:40 +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/automated/python-tests.el (python-imenu-create-index-1, python-imenu-create-flat-index-1): Add async def's. --- lisp/progmodes/python.el | 16 +++++++++++----- test/automated/python-tests.el | 12 ++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 49f7bcf..60bd4dc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4389,6 +4389,14 @@ 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 + (cdr split))))) + (defun python-imenu--put-parent (type name pos tree) "Add the parent with TYPE, NAME and POS to TREE." (let ((label @@ -4406,11 +4414,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/automated/python-tests.el b/test/automated/python-tests.el index 54ed922..3cdabf8 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -3552,6 +3552,9 @@ python-tests-shell-interpreter def c(self): pass + + async def d(self): + pass " (goto-char (point-max)) (should (equal @@ -3573,7 +3576,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 (def)" (copy-marker 665))))) (python-imenu-create-index))))) (ert-deftest python-imenu-create-index-2 () @@ -3695,6 +3699,9 @@ python-tests-shell-interpreter def c(self): pass + + async def d(self): + pass " (goto-char (point-max)) (should (equal @@ -3707,7 +3714,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 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#24820: Any suggestions about patch? 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 ` Dmitry Lazurkin 2016-12-26 22:26 ` npostavs 2017-01-04 16:48 ` bug#24820: I think copyright is assigned Dmitry Lazurkin 1 sibling, 1 reply; 17+ messages in thread From: Dmitry Lazurkin @ 2016-12-23 17:32 UTC (permalink / raw) To: 24820 I have not quick navigation to async method without this patch. What i should do for merging this patch? ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Any suggestions about patch? 2016-12-23 17:32 ` bug#24820: Any suggestions about patch? Dmitry Lazurkin @ 2016-12-26 22:26 ` npostavs 0 siblings, 0 replies; 17+ messages in thread From: npostavs @ 2016-12-26 22:26 UTC (permalink / raw) To: Dmitry Lazurkin; +Cc: 24820 Dmitry Lazurkin <dilaz03@gmail.com> writes: > I have not quick navigation to async method without this patch. What i > should do for merging this patch? The patch looks good to me, except a minor formatting mistake in the commit message. * test/automated/python-tests.el (python-imenu-create-index-1, python-imenu-create-flat-index-1): Add async def's. should be * test/automated/python-tests.el (python-imenu-create-index-1): (python-imenu-create-flat-index-1): Add async def's. Have you done copyright assignment for Emacs? I think your current patch is a bit over the limit of what we can accept without an assignment (unless we don't count lines added to tests?). Though if you didn't refactor into the new function python-imenu--get-defun-type-name it could probably squeeze in. The form to start the assignment process is at http://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/Copyright/request-assign.program ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: I think copyright is assigned 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 @ 2017-01-04 16:48 ` Dmitry Lazurkin 2017-01-04 16:55 ` Eli Zaretskii 1 sibling, 1 reply; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-04 16:48 UTC (permalink / raw) To: 24820 Hello. > Hello, > > Your assignment/disclaimer process with the FSF is currently > complete; your fully executed PDF will be sent to you in a separate > email immediately following this one. > > Please remember to let us know when your employment status changes, as > this may affect your assignment status. > > Thank you for your contribution! > > All the best, > > Sincerely, I think copyright is assigned. Or not? Do you want merge this fix to branch 25.0? Or to master? ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: I think copyright is assigned 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 0 siblings, 2 replies; 17+ messages in thread From: Eli Zaretskii @ 2017-01-04 16:55 UTC (permalink / raw) To: Dmitry Lazurkin; +Cc: 24820 > From: Dmitry Lazurkin <dilaz03@gmail.com> > Date: Wed, 4 Jan 2017 19:48:48 +0300 > > Do you want merge this fix to branch 25.0? Or to master? Is this a problem that is new with Emacs 25.1? If not, then it should go to the master branch. Thanks. ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Rebase against master 2017-01-04 16:55 ` Eli Zaretskii @ 2017-01-04 20:24 ` Dmitry Lazurkin 2017-01-04 20:27 ` Dmitry Lazurkin 1 sibling, 0 replies; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-04 20:24 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 24820 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 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#24820: Rebase against master 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 1 sibling, 1 reply; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-04 20:27 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 24820 Some fixes: - fix commit message - return imenu type "async def" for async def's (is formatting code ugly?) ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 2017-01-04 20:27 ` Dmitry Lazurkin @ 2017-01-05 4:07 ` npostavs 2017-01-05 10:14 ` Dmitry Lazurkin ` (2 more replies) 0 siblings, 3 replies; 17+ messages in thread From: npostavs @ 2017-01-05 4:07 UTC (permalink / raw) To: Dmitry Lazurkin; +Cc: 24820 Dmitry Lazurkin <dilaz03@gmail.com> writes: > Some fixes: > - fix commit message > - return imenu type "async def" for async def's Thanks. I'll push this to master in a week or so, unless there are objections. > (is formatting code ugly?) 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. > - (type) > - (name (when (and pos (looking-at > python-nav-beginning-of-defun-regexp)) > - (let ((split (split-string > (match-string-no-properties 0)))) ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 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-05 20:20 ` Dmitry Lazurkin 2017-01-05 21:03 ` Dmitry Lazurkin 2 siblings, 1 reply; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-05 10:14 UTC (permalink / raw) To: npostavs; +Cc: 24820 On 01/05/2017 07:07 AM, npostavs@users.sourceforge.net wrote: >> (is formatting code ugly?) > I don't see any formatting problems in your code, but it looks like the > patch got word wrapped, Formatting of "async def": + (list (concat (car split) " " (cadr split)) + (car (last split))))))) > I find sending as attachment generally avoids > such issues. > >> - (type) >> - (name (when (and pos (looking-at >> python-nav-beginning-of-defun-regexp)) >> - (let ((split (split-string >> (match-string-no-properties 0)))) > Is resending patch as attachment correct for debbugs.gnu.org? ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 2017-01-05 10:14 ` Dmitry Lazurkin @ 2017-01-06 1:19 ` npostavs 2017-01-06 12:07 ` Dmitry Lazurkin 0 siblings, 1 reply; 17+ messages in thread From: npostavs @ 2017-01-06 1:19 UTC (permalink / raw) To: Dmitry Lazurkin; +Cc: 24820 Dmitry Lazurkin <dilaz03@gmail.com> writes: > On 01/05/2017 07:07 AM, npostavs@users.sourceforge.net wrote: >>> (is formatting code ugly?) >> I don't see any formatting problems in your code, > > Formatting of "async def": > + (list (concat (car split) " " (cadr split)) > + (car (last split))))))) Formatting looks fine here. Since I'm staring at it anyway, it could be optimized like so: (cons (concat (car split) " " (cadr split)) (last split)) It's fine either way though. ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 2017-01-06 1:19 ` npostavs @ 2017-01-06 12:07 ` Dmitry Lazurkin 2017-01-06 14:00 ` npostavs 0 siblings, 1 reply; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-06 12:07 UTC (permalink / raw) To: npostavs; +Cc: 24820 On 01/06/2017 04:19 AM, npostavs@users.sourceforge.net wrote: > (cons (concat (car split) " " (cadr split)) > (last split)) This is not so easy because variable "split" is list which returned in prev branch of if. ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 2017-01-06 12:07 ` Dmitry Lazurkin @ 2017-01-06 14:00 ` npostavs 2017-01-06 19:41 ` Dmitry Lazurkin 0 siblings, 1 reply; 17+ messages in thread From: npostavs @ 2017-01-06 14:00 UTC (permalink / raw) To: Dmitry Lazurkin; +Cc: 24820 Dmitry Lazurkin <dilaz03@gmail.com> writes: > On 01/06/2017 04:19 AM, npostavs@users.sourceforge.net wrote: >> (cons (concat (car split) " " (cadr split)) >> (last split)) > This is not so easy because variable "split" is list which returned in > prev branch of if. So, why is that a problem? ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 2017-01-06 14:00 ` npostavs @ 2017-01-06 19:41 ` Dmitry Lazurkin 2017-01-13 1:49 ` npostavs 0 siblings, 1 reply; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-06 19:41 UTC (permalink / raw) To: npostavs; +Cc: 24820 On 01/06/2017 05:00 PM, npostavs@users.sourceforge.net wrote: > So, why is that a problem? This is not problem for me. ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 2017-01-06 19:41 ` Dmitry Lazurkin @ 2017-01-13 1:49 ` npostavs 2017-01-13 9:34 ` dilaz03 . 0 siblings, 1 reply; 17+ messages in thread From: npostavs @ 2017-01-13 1:49 UTC (permalink / raw) To: Dmitry Lazurkin; +Cc: 24820 tags 24820 fixed close 24820 26.1 quit Dmitry Lazurkin <dilaz03@gmail.com> writes: > On 01/06/2017 05:00 PM, npostavs@users.sourceforge.net wrote: >> So, why is that a problem? > > This is not problem for me. Okay, then I'm not quite sure what we were talking about. Anyway, like I said before, your patch looks fine so I've pushed it to master [1: d4a9708]. I added "(Bug#24820)" to the commit, but I didn't change the code. 1: 2017-01-12 20:40:19 -0500 d4a97088f69eb5729261ee4581cfb7d60c673ebd Fix extracting async def type and name in python mode imenu ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 2017-01-13 1:49 ` npostavs @ 2017-01-13 9:34 ` dilaz03 . 0 siblings, 0 replies; 17+ messages in thread From: dilaz03 . @ 2017-01-13 9:34 UTC (permalink / raw) To: npostavs; +Cc: 24820 [-- Attachment #1: Type: text/plain, Size: 730 bytes --] Thanks. 13 янв. 2017 г. 4:48 пользователь <npostavs@users.sourceforge.net> написал: > tags 24820 fixed > close 24820 26.1 > quit > > Dmitry Lazurkin <dilaz03@gmail.com> writes: > > > On 01/06/2017 05:00 PM, npostavs@users.sourceforge.net wrote: > >> So, why is that a problem? > > > > This is not problem for me. > > Okay, then I'm not quite sure what we were talking about. Anyway, like > I said before, your patch looks fine so I've pushed it to master [1: > d4a9708]. I added "(Bug#24820)" to the commit, but I didn't change the > code. > > 1: 2017-01-12 20:40:19 -0500 d4a97088f69eb5729261ee4581cfb7d60c673ebd > Fix extracting async def type and name in python mode imenu > [-- Attachment #2: Type: text/html, Size: 1188 bytes --] ^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 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-05 20:20 ` Dmitry Lazurkin 2017-01-05 21:03 ` Dmitry Lazurkin 2 siblings, 0 replies; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-05 20:20 UTC (permalink / raw) To: npostavs; +Cc: 24820 [-- 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 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#24820: Imenu in `python-mode' does not display function name for async def 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-05 20:20 ` Dmitry Lazurkin @ 2017-01-05 21:03 ` Dmitry Lazurkin 2 siblings, 0 replies; 17+ messages in thread From: Dmitry Lazurkin @ 2017-01-05 21:03 UTC (permalink / raw) To: npostavs; +Cc: 24820 [-- Attachment #1: Type: text/plain, Size: 64 bytes --] Oh, i missed "(Bug#24820)" in commit message. [-- Attachment #2: Type: text/html, Size: 825 bytes --] ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2017-01-13 9:34 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2017-01-05 21:03 ` Dmitry Lazurkin
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).