GNU bug report logs -
#25734
Python - fix imenu regexp for async functions
Previous Next
Reported by: Michael Kleehammer <michael <at> kleehammer.com>
Date: Tue, 14 Feb 2017 21:07:01 UTC
Severity: minor
Tags: fixed, patch
Merged with 24820
Found in version 25
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25734 in the body.
You can then email your comments to 25734 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25734
; Package
emacs
.
(Tue, 14 Feb 2017 21:07:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Michael Kleehammer <michael <at> kleehammer.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 14 Feb 2017 21:07:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
This patch is for python mode. Recently Python 3 added the “async” keyword for functions like so:
def this_is_not_async():
pass
async def this_is_async():
pass
The mode has already been updated to recognize this for most things, but not imenu. It currently would show:
this_is_not_async (def)
def (async)
The patch below is a minor modification for a regular expression. The old one simply took the 2nd token on the line to be the name; the new one skips the optional “async” keyword.
Please note the current imenu is unusable in a file with a lot of async functions - it would be nice if this rolled out with 25.2 if possible, which I believe adds the rest of async support.
Thanks,
Michael Kleehammer
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 90b5e4e0dc..5ca23fb9ab 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1316,7 +1316,7 @@ marks the next defun after the ones already marked."
;;; Navigation
(defvar python-nav-beginning-of-defun-regexp
- (python-rx line-start (* space) defun (+ space) (group symbol-name))
+ (python-rx line-start (* space) (* "async" space) defun (+ space) (group symbol-name))
"Regexp matching class or function definition.
The name of the defun should be grouped so it can be retrieved
via `match-string'.")
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25734
; Package
emacs
.
(Wed, 15 Feb 2017 01:33:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 25734 <at> debbugs.gnu.org (full text, mbox):
Michael Kleehammer <michael <at> kleehammer.com> writes:
>
> The patch below is a minor modification for a regular expression. The
> old one simply took the 2nd token on the line to be the name; the new
> one skips the optional “async” keyword.
>
> Please note the current imenu is unusable in a file with a lot of
> async functions - it would be nice if this rolled out with 25.2 if
> possible, which I believe adds the rest of async support.
There was a patch for a similar problem in #24820, but when looking at
the code touched there, it seems that the sub-groups of
python-nav-beginning-of-defun-regexp are not used
(python-imenu--put-parent uses "group 0"). Did I miss something?
I applied that patch to master (i.e., what will be 26.1), by the way.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25734
; Package
emacs
.
(Sat, 18 Feb 2017 14:22:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 25734 <at> debbugs.gnu.org (full text, mbox):
unarchive 24820
forcemerge 24820 25734
quit
Michael Kleehammer <michael <at> kleehammer.com> writes:
> This patch is for python mode. Recently Python 3 added the “async”
> keyword for functions like so:
>
> def this_is_not_async():
> pass
>
> async def this_is_async():
> pass
>
> The mode has already been updated to recognize this for most things,
> but not imenu. It currently would show:
>
> this_is_not_async (def)
> def (async)
>
> The patch below is a minor modification for a regular expression. The
> old one simply took the 2nd token on the line to be the name; the new
> one skips the optional “async” keyword.
As far as I can tell, your patch has no effect on imenu, after applying
it and doing M-x imenu RET TAB, I get this *Completions* buffer:
Click on a completion to select it.
In this buffer, type RET to select the completion near point.
Possible completions are:
*Rescan*
def.(async)
this_is_not_async.(def)
Since the patch in #24820 does fix the problem, I'm merging this bug
into that one.
> Please note the current imenu is unusable in a file with a lot of
> async functions - it would be nice if this rolled out with 25.2 if
> possible, which I believe adds the rest of async support.
AFAIK, it's too late to fix non-critical bugs in emacs-25, but python.el
is both in Emacs "core" and a GNU ELPA package, so you can install the
version from master using package.el (when we bump its package version,
that is).
Forcibly Merged 24820 25734.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 18 Feb 2017 14:22:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 19 Mar 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 95 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.