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.
Full log
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)]
This bug report was last modified 8 years and 96 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.