From unknown Sat Jun 21 10:46:02 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25734: Python - fix imenu regexp for async functions Resent-From: Michael Kleehammer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Feb 2017 21:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25734 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 25734@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.14871063917475 (code B ref -1); Tue, 14 Feb 2017 21:07:01 +0000 Received: (at submit) by debbugs.gnu.org; 14 Feb 2017 21:06:31 +0000 Received: from localhost ([127.0.0.1]:40281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdkIw-0001wV-Tq for submit@debbugs.gnu.org; Tue, 14 Feb 2017 16:06:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50511) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdkIu-0001wI-NC for submit@debbugs.gnu.org; Tue, 14 Feb 2017 16:06:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdkIo-0000BD-9q for submit@debbugs.gnu.org; Tue, 14 Feb 2017 16:06:23 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50090) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdkIo-0000B4-6r for submit@debbugs.gnu.org; Tue, 14 Feb 2017 16:06:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdkIm-0004tj-DB for bug-gnu-emacs@gnu.org; Tue, 14 Feb 2017 16:06:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdkIh-00006p-F1 for bug-gnu-emacs@gnu.org; Tue, 14 Feb 2017 16:06:20 -0500 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:33918) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cdkIh-00006J-9e for bug-gnu-emacs@gnu.org; Tue, 14 Feb 2017 16:06:15 -0500 Received: by mail-oi0-x235.google.com with SMTP id s203so77596554oie.1 for ; Tue, 14 Feb 2017 13:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kleehammer-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:message-id:subject:mime-version; bh=I4HR8FWNmy9IcujqKkq2BpxNtqqoE7i1H7OJHo8fcl0=; b=E/Gmecj4k3RRkopMyAGVxkyOAag0PIAIvrIEI6O/15/UYGWRotn0DrPNehhOmwRuO3 FuseiA/IeuOtWaLUxSafd6KozeVHaAMpRQo6K8eQam6FY32W9ZWYvA1sEf2E3qJPC6kq Rr9dSiksW+Hl1/uJ8rexy2WikK4rrp94SOau89WbBGFk7nLhHrVht3fYz7gjfEcgAUXb pKxnX+LYPL2L1PNqfFfCmLANxZMf5oSMYqMEtICVqlXQcwSNH6krcuoht5216BepSxut YwVrghryDRWICdSHGAzC+J2LCuVQLMt47Fzvvn8XN/Gt0Lz7df8rov8euLMXZvP1SfjO 2A6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:message-id:subject:mime-version; bh=I4HR8FWNmy9IcujqKkq2BpxNtqqoE7i1H7OJHo8fcl0=; b=WT7IAtIJNKZDIRPAWBweC5GQxHmdepLQCI4aipu8/ITzllcq660PbAo6RVvbF+nRDs pilNYK38mzsxnmRk0C4k4hA4SITYhHBbpa+Ey/8oiUDJv+x/olB4iMP0eY24eGD05/uI MSuAkRL2J0wILt3F93QJvIjL5E3BmQi+UC8UAuhsb6RowGLMoT8zRqrr+Xc8dsn0A/8+ sByVFFXHubc+vZDNv/TQSuS9gRTJRWs29tgsng2c991C563XKwhwbpKCCNJqUVmova+5 RnKk+rEr3kEW7oklX6LWZvJ73r5ABsQwchsyR0IcLQiml1tLnY+Uf2vuBHtGHqEYlZS6 BKgg== X-Gm-Message-State: AMke39mR8tUDNqfD7lQA1a/62l5nb91YqoAwk22bLwdkbWFEsoNCfaSwMjqX2z29ImuYUg== X-Received: by 10.202.68.10 with SMTP id r10mr17539916oia.181.1487106373871; Tue, 14 Feb 2017 13:06:13 -0800 (PST) Received: from [192.168.1.14] ([47.188.195.162]) by smtp.gmail.com with ESMTPSA id u37sm633528otu.41.2017.02.14.13.06.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 13:06:13 -0800 (PST) Date: Tue, 14 Feb 2017 15:01:28 -0600 From: Michael Kleehammer Message-ID: <53fdd849-4f99-48c0-bde7-7d07107984dc@Spark> X-Readdle-Message-ID: 53fdd849-4f99-48c0-bde7-7d07107984dc@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="58a37144_6b8b4567_119e8" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --58a37144_6b8b4567_119e8 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This patch is for python mode. =C2=A0Recently Python 3 added the =E2=80=9C= async=E2=80=9D keyword for functions like so: =C2=A0 =C2=A0 def this=5Fis=5Fnot=5Fasync(): =C2=A0 =C2=A0 =C2=A0 =C2=A0 pass =C2=A0 =C2=A0 async def this=5Fis=5Fasync(): =C2=A0 =C2=A0 =C2=A0 =C2=A0 pass The mode has already been updated to recognize this for most things, but = not imenu. =C2=A0It currently would show: =C2=A0 =C2=A0 this=5Fis=5Fnot=5Fasync (def) =C2=A0 =C2=A0 def (async) The patch below is a minor modification for a regular expression. =C2=A0T= he old one simply took the 2nd token on the line to be the name; the new = one skips the optional =E2=80=9Casync=E2=80=9D keyword. Please note the current imenu is unusable in a file with a lot of async f= unctions - it would be nice if this rolled out with 25.2 if possible, whi= ch 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 =40=40 -1316,7 +1316,7 =40=40 marks the next defun after the ones already= marked.=22 =C2=A0;;; Navigation =C2=A0(defvar python-nav-beginning-of-defun-regexp - =C2=A0(python-rx line-start (* space) defun (+ space) (group symbol-nam= e)) + =C2=A0(python-rx line-start (* space) (* =22async=22 space) defun (+ sp= ace) (group symbol-name)) =C2=A0 =C2=A0=22Regexp matching class or function definition. =C2=A0The name of the defun should be grouped so it can be retrieved =C2=A0via =60match-string'.=22) --58a37144_6b8b4567_119e8 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
This patch is fo= r python mode. &=23160;Recently Python 3 added the =E2=80=9Casync=E2=80=9D= keyword for functions like so:

&=23160; &=23160; def this=5Fis=5Fnot=5Fasync():
&=23160; &=23160; &=23160; &=23160; pass

&=23160; &=23160; async def this=5Fis=5Fasync():
&=23160; &=23160; &=23160; &=23160; pass

The mode has already been updated to recognize this for most things,= but not imenu. &=23160;It currently would show:

&=23160; &=23160; this=5Fis=5Fnot=5Fasync (def)
&=23160; &=23160; def (async)

The patch below is a minor modification for a regular expression. &=23= 160;The old one simply took the 2nd token on the line to be the name; the= new one skips the optional =E2=80=9Casync=E2=80=9D keyword.

Please note the current imenu is unusable in a file with a lot of as= ync 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
=40=40 -1316,7 +1316,7 =40=40 marks the next defun after the ones al= ready marked.=22
&=23160;;;; Navigation
&=23160;
&=23160;(defvar python-nav-beginning-of-defun-regexp
- &=23160;(python-rx line-start (* space) defun (+ space) (group sym= bol-name))
+ &=23160;(python-rx line-start (* space) (* =22async=22 space) defu= n (+ space) (group symbol-name))
&=23160; &=23160;=22Regexp matching class or function definition.
&=23160;The name of the defun should be grouped so it can be retriev= ed
&=23160;via =60match-string'.=22)

--58a37144_6b8b4567_119e8-- From unknown Sat Jun 21 10:46:02 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25734: Python - fix imenu regexp for async functions Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Feb 2017 01:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25734 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Michael Kleehammer Cc: 25734@debbugs.gnu.org Received: via spool by 25734-submit@debbugs.gnu.org id=B25734.148712232930704 (code B ref 25734); Wed, 15 Feb 2017 01:33:02 +0000 Received: (at 25734) by debbugs.gnu.org; 15 Feb 2017 01:32:09 +0000 Received: from localhost ([127.0.0.1]:40361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdoS0-0007zA-TM for submit@debbugs.gnu.org; Tue, 14 Feb 2017 20:32:09 -0500 Received: from mail-it0-f42.google.com ([209.85.214.42]:37147) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdoRz-0007ym-9B for 25734@debbugs.gnu.org; Tue, 14 Feb 2017 20:32:07 -0500 Received: by mail-it0-f42.google.com with SMTP id x75so55911015itb.0 for <25734@debbugs.gnu.org>; Tue, 14 Feb 2017 17:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=+KBbUvjk39ELRZL60ct53fwCNn+OwPLsh61AUIrD7gE=; b=R9GezYGF7oz+funTa2tt4vguy77WdSZ30plZKDpDrxXqDuYlpgEmJq9KwK/PHn1qVI cltW5fsuz4GYoDAh/snaI9QH4BzX38iHgCYSxa7v8TfgHhkjoUFEQRVPyzUwovcpCgyw bAdgoYVSjK07+NCxfyFRotgggr8xQQ2ourBd4lr5iduMnziYx6ppERBDTHebg66REGBG C13QHwudeSjUN/g9zafMGgYrGIyRN23nCP2fmTeo3dF6BNye/+/kRUa2oJ1TIz7zJ+aL HjV4E4Xz4gGMCr0MNgZsJDq4tRUdZ72QNmKlOZSk7k4ond+6fPsIn0y2iVv1MGZdvu1t ba3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=+KBbUvjk39ELRZL60ct53fwCNn+OwPLsh61AUIrD7gE=; b=H5138dlhW3YgQdUnCP2GP1phpExH6G8ipWlLyRWzKGNp3Fmcvy4L/r4Oknz9hglkcU I7dGXWKdx2/0jr5mRf+kdGw3uuKG2+BaBBpakRiMmas5cR8lc2FOBnB9lKz7wGAyXgxP a+Q1D4y7mH4atKfwVT1ID5rcKypBKFpXN6XoRU2uP8Sdf3VfusoEnLdUuk6MqHwf/Ky7 BWv+s1tWxXBIU5Do/vBHrdyOdXPmhr4D6hale7b/vuAn7XuhTUbRVDUsSXhx8OMHgAqo 4QEmMCAbf7soaU1SXxN+7z4V72URFLZEB9dFymmYPz8VWxM3WKZ0/c0Y+PVol8cysDcn e5eQ== X-Gm-Message-State: AMke39ke6cCUSuEOTdhjtrpjpQNnzu8QvhlIIpJM9rk34xaylMKQaCd0eUZMF/8VJOvoHw== X-Received: by 10.36.84.148 with SMTP id t142mr6776275ita.90.1487122321642; Tue, 14 Feb 2017 17:32:01 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id m79sm1113017ioo.0.2017.02.14.17.32.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Feb 2017 17:32:01 -0800 (PST) From: npostavs@users.sourceforge.net References: <53fdd849-4f99-48c0-bde7-7d07107984dc@Spark> Date: Tue, 14 Feb 2017 20:33:10 -0500 In-Reply-To: <53fdd849-4f99-48c0-bde7-7d07107984dc@Spark> (Michael Kleehammer's message of "Tue, 14 Feb 2017 15:01:28 -0600") Message-ID: <878tp8kzl5.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) Michael Kleehammer 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 =E2=80=9Casync=E2=80=9D 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. From unknown Sat Jun 21 10:46:02 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25734: Python - fix imenu regexp for async functions Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Feb 2017 14:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25734 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Michael Kleehammer Cc: 25734@debbugs.gnu.org Received: via spool by 25734-submit@debbugs.gnu.org id=B25734.148742771016018 (code B ref 25734); Sat, 18 Feb 2017 14:22:01 +0000 Received: (at 25734) by debbugs.gnu.org; 18 Feb 2017 14:21:50 +0000 Received: from localhost ([127.0.0.1]:44426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cf5tW-0004AD-JE for submit@debbugs.gnu.org; Sat, 18 Feb 2017 09:21:50 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:35516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cf5tU-00049u-Ca; Sat, 18 Feb 2017 09:21:48 -0500 Received: by mail-io0-f194.google.com with SMTP id m98so1400687iod.2; Sat, 18 Feb 2017 06:21:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=izbwbQku88SCppDvuTtbPAhpZmRyPV1wGLCmvBCaC8s=; b=Z1kcZrkHqOROZ7Ybv7TMQcDEM8ws5MTBy35DoyJ5zUSt3trqXAKtvCs7y6FaQphQTz whjHEivTwrDxBXtxrV82NsCV3U8sxb9gGgkqQtDL6m1lYq83QULJ/34zu8QEa9LC0Flq 5h7X3re84uNIsCJXorYWnEdU8dSsL3KzDuhAAfJu4E67GMCiec0l5Ck6UufM4sVmgb6k BiFRipDTI1ZCLRwRBgiRq0mCj3MS4LRrDynsN3qZ3LzDZSwEPn4GrGsbI0jdcHXsbYEB JOB3zDPYiAPFTr6UnlK5Vi2ZK0qr53ov5zA3ZcBzKxCngWmJGK3sQHRWIIS2buxpxC5J iVWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=izbwbQku88SCppDvuTtbPAhpZmRyPV1wGLCmvBCaC8s=; b=jRbJHhQeTgAzNSjGmalyphBu0TQ5vslKmbdaaNgZMrU10iD1nr3za3dKTpQX8gESRp sdHayeNlSCpfmLnrBpMp1qRpEvS0rgnutBZYPGFxfEzBSf0bONYEvi6qQ5nxU/Jb13YQ at1dO75+ozb9H6SsKnpCplZQoid8nJYGlhblm86T57miT8yallswuoamuFDIpHhtdwvr X3nliGcUcFStoiW/gQRs9jSaJPHAUyikniInyf161cL6/hWGxP+46qSf6gjsRx9gvZVz 86qSuL0SpT2ReG7/9xpdN8f8A7fDQWgMypt+NKgbWBvYqN695eZfzDobyOgaYp/bafqF 9eaQ== X-Gm-Message-State: AMke39mGa0HLXqOyo7LRQ3bPwU7ZM50FuCKg29DnDS18zKpQd4MPUaGCoSRBdeFGTqPdOw== X-Received: by 10.107.34.10 with SMTP id i10mr10398545ioi.41.1487427702888; Sat, 18 Feb 2017 06:21:42 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id e139sm6384528iof.54.2017.02.18.06.21.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Feb 2017 06:21:42 -0800 (PST) From: npostavs@users.sourceforge.net References: <53fdd849-4f99-48c0-bde7-7d07107984dc@Spark> Date: Sat, 18 Feb 2017 09:22:53 -0500 In-Reply-To: <53fdd849-4f99-48c0-bde7-7d07107984dc@Spark> (Michael Kleehammer's message of "Tue, 14 Feb 2017 15:01:28 -0600") Message-ID: <87shnbk282.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) unarchive 24820 forcemerge 24820 25734 quit Michael Kleehammer writes: > This patch is for python mode. Recently Python 3 added the =E2=80=9Casync= =E2=80=9D > 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 =E2=80=9Casync=E2=80=9D 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).