From unknown Thu Aug 14 18:37:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21783: 25.0.50; python.el does not support new Python 3.5 keywords Resent-From: Lele Gaifax Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Oct 2015 12:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21783 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 21783@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.144612165622258 (code B ref -1); Thu, 29 Oct 2015 12:28:02 +0000 Received: (at submit) by debbugs.gnu.org; 29 Oct 2015 12:27:36 +0000 Received: from localhost ([127.0.0.1]:43353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZrmIV-0005mV-Uw for submit@debbugs.gnu.org; Thu, 29 Oct 2015 08:27:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47277) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zrj4M-0007ha-DY for submit@debbugs.gnu.org; Thu, 29 Oct 2015 05:00:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zrj4K-000827-M2 for submit@debbugs.gnu.org; Thu, 29 Oct 2015 05:00:26 -0400 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 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrj4K-000823-Ix for submit@debbugs.gnu.org; Thu, 29 Oct 2015 05:00:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrj4J-0008MJ-2m for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 05:00:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zrj4C-0007zv-Gn for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 05:00:23 -0400 Received: from mail.arstecnica.it ([144.76.81.238]:40944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrj4C-0007z4-6z for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 05:00:16 -0400 Received: from nautilus (unknown [192.168.1.102]) by mail.arstecnica.it (Postfix) with ESMTPSA id A1DF783E365 for ; Thu, 29 Oct 2015 09:00:05 +0000 (UTC) Received: from nautilus ([151.62.147.82] helo=nautilus) by assp.arstecnica.it with SMTPS(AES128-GCM-SHA256) (2.3.3); 29 Oct 2015 09:00:04 +0000 From: Lele Gaifax User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/25.0.50.12 (x86_64-pc-linux-gnu) Date: Thu, 29 Oct 2015 10:00:04 +0100 Message-ID: <87h9ladp7v.fsf@metapensiero.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Assp-Version: 2.3.3(14029) on assp.arstecnica.it X-Assp-ID: assp.arstecnica.it m1-09205-04025 X-Assp-Session: 13AACEF4 (mail 1) X-Assp-Envelope-From: lele@metapensiero.it X-Assp-Intended-For: bug-gnu-emacs@gnu.org X-Assp-Client-TLS: yes X-Assp-Server-TLS: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Mailman-Approved-At: Thu, 29 Oct 2015 08:27:14 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -4.1 (----) --=-=-= Content-Type: text/plain Python 3.5, released in mid September 2015, introduced a few new keywords to better support asynchronous code, "async" and "await" in particular. See https://www.python.org/dev/peps/pep-0492/ for details. To avoid breaking already written users code, they are technically not "reserved keywords", but accordingly to the plan they will become that in Python 3.7 (https://www.python.org/dev/peps/pep-0492/#id75). Currently python.el doesn't know anything about them, so it obviously cannot properly indent the following code: async def coroutine(foo, bar): | where "|" represent the cursor position, nor highlight them in any way. I'm attaching a patch that implements such support, with some test cases. See also the thread http://thread.gmane.org/gmane.emacs.devel/190950 where I initially sent the same patch and where I've been solicited to create a bug report. Hope this helps, thanks in advance, ciao, lele. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=python_el+pep492.patch Content-Description: Add PEP492 support to python.el diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 6ff12b5..9f5c087 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -384,7 +384,10 @@ python-mode-map (defconst python-rx-constituents `((block-start . ,(rx symbol-start (or "def" "class" "if" "elif" "else" "try" - "except" "finally" "for" "while" "with") + "except" "finally" "for" "while" "with" + ;; Python 3.5+ PEP492 + (and "async" (+ space) + (or "def" "for" "with"))) symbol-end)) (dedenter . ,(rx symbol-start (or "elif" "else" "except" "finally") @@ -395,7 +398,11 @@ python-mode-map symbol-end)) (decorator . ,(rx line-start (* space) ?@ (any letter ?_) (* (any word ?_)))) - (defun . ,(rx symbol-start (or "def" "class") symbol-end)) + (defun . ,(rx symbol-start + (or "def" "class" + ;; Python 3.5+ PEP492 + (and "async" (+ space) "def")) + symbol-end)) (if-name-main . ,(rx line-start "if" (+ space) "__name__" (+ space) "==" (+ space) (any ?' ?\") "__main__" (any ?' ?\") @@ -527,6 +534,8 @@ python-font-lock-keywords ;; fontified like that in order to keep font-lock consistent between ;; Python versions. "nonlocal" + ;; Python 3.5+ PEP492 + (and "async" (+ space) (or "def" "for" "with")) ;; Extra: "self") symbol-end) diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 44b05e2..23d799a 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -604,6 +604,42 @@ python-tests-visible-string (should (eq (car (python-indent-context)) :after-line)) (should (= (python-indent-calculate-indentation) 0)))) +(ert-deftest python-indent-after-async-block-1 () + "Test PEP492 async def." + (python-tests-with-temp-buffer + " +async def foo(a, b, c=True): +" + (should (eq (car (python-indent-context)) :no-indent)) + (should (= (python-indent-calculate-indentation) 0)) + (goto-char (point-max)) + (should (eq (car (python-indent-context)) :after-block-start)) + (should (= (python-indent-calculate-indentation) 4)))) + +(ert-deftest python-indent-after-async-block-2 () + "Test PEP492 async with." + (python-tests-with-temp-buffer + " +async with foo(a) as mgr: +" + (should (eq (car (python-indent-context)) :no-indent)) + (should (= (python-indent-calculate-indentation) 0)) + (goto-char (point-max)) + (should (eq (car (python-indent-context)) :after-block-start)) + (should (= (python-indent-calculate-indentation) 4)))) + +(ert-deftest python-indent-after-async-block-3 () + "Test PEP492 async for." + (python-tests-with-temp-buffer + " +async for a in sequencer(): +" + (should (eq (car (python-indent-context)) :no-indent)) + (should (= (python-indent-calculate-indentation) 0)) + (goto-char (point-max)) + (should (eq (car (python-indent-context)) :after-block-start)) + (should (= (python-indent-calculate-indentation) 4)))) + (ert-deftest python-indent-after-backslash-1 () "The most common case." (python-tests-with-temp-buffer @@ -1483,6 +1519,26 @@ python-tests-visible-string (beginning-of-line) (point)))))) +(ert-deftest python-nav-beginning-of-defun-3 () + (python-tests-with-temp-buffer + " +class C(object): + + async def m(self): + return await self.c() + + async def c(self): + pass +" + (python-tests-look-at "self.c()") + (should (= (save-excursion + (python-nav-beginning-of-defun) + (point)) + (save-excursion + (python-tests-look-at "async def m" -1) + (beginning-of-line) + (point)))))) + (ert-deftest python-nav-end-of-defun-1 () (python-tests-with-temp-buffer " --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. --=-=-=-- From unknown Thu Aug 14 18:37:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21783: Copyright assignment References: <87h9ladp7v.fsf@metapensiero.it> In-Reply-To: <87h9ladp7v.fsf@metapensiero.it> Resent-From: Lele Gaifax Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Dec 2015 10:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21783 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 21783@debbugs.gnu.org Received: via spool by 21783-submit@debbugs.gnu.org id=B21783.145043460018290 (code B ref 21783); Fri, 18 Dec 2015 10:30:02 +0000 Received: (at 21783) by debbugs.gnu.org; 18 Dec 2015 10:30:00 +0000 Received: from localhost ([127.0.0.1]:55158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a9sIS-0004kw-IC for submit@debbugs.gnu.org; Fri, 18 Dec 2015 05:30:00 -0500 Received: from mail.arstecnica.it ([144.76.81.238]:45186) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a9sIQ-0004kg-9g for 21783@debbugs.gnu.org; Fri, 18 Dec 2015 05:29:58 -0500 Received: from nautilus (assp.arstecnica.it [192.168.1.102]) by mail.arstecnica.it (Postfix) with ESMTPSA id 857FB83E344 for <21783@debbugs.gnu.org>; Fri, 18 Dec 2015 10:29:52 +0000 (UTC) Received: from nautilus ([151.62.33.97] helo=nautilus) by assp.arstecnica.it with SMTPS(AES128-GCM-SHA256) (2.3.3); 18 Dec 2015 10:29:51 +0000 From: Lele Gaifax User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.0.50.25 (x86_64-pc-linux-gnu) Date: Fri, 18 Dec 2015 11:29:51 +0100 Message-ID: <87y4csrqw0.fsf@metapensiero.it> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Assp-Version: 2.3.3(14029) on assp.arstecnica.it X-Assp-ID: assp.arstecnica.it m1-34592-00591 X-Assp-Session: A969180C (mail 1) X-Assp-Envelope-From: lele@metapensiero.it X-Assp-Intended-For: 21783@debbugs.gnu.org X-Assp-Client-TLS: yes X-Assp-Server-TLS: yes X-Spam-Score: -0.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: -0.0 (/) Maybe I could have stated that I fulfilled the assignment process (# 988143= ), should that smooth the acceptance of the patch. --=20 nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. From unknown Thu Aug 14 18:37:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21783: Copyright assignment Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Dec 2015 10:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21783 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lele Gaifax , =?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina Cc: 21783@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 21783-submit@debbugs.gnu.org id=B21783.145043609020539 (code B ref 21783); Fri, 18 Dec 2015 10:55:01 +0000 Received: (at 21783) by debbugs.gnu.org; 18 Dec 2015 10:54:50 +0000 Received: from localhost ([127.0.0.1]:55180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a9sgU-0005LC-5x for submit@debbugs.gnu.org; Fri, 18 Dec 2015 05:54:50 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35720) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a9sgS-0005L0-S9 for 21783@debbugs.gnu.org; Fri, 18 Dec 2015 05:54:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9sgK-0002A2-Pj for 21783@debbugs.gnu.org; Fri, 18 Dec 2015 05:54:43 -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.0 required=5.0 tests=BAYES_20,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9sgK-00029k-Mb; Fri, 18 Dec 2015 05:54:40 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1820 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1a9sgJ-0005d2-UP; Fri, 18 Dec 2015 05:54:40 -0500 Date: Fri, 18 Dec 2015 12:55:03 +0200 Message-Id: <83y4csvxfc.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <87y4csrqw0.fsf@metapensiero.it> (message from Lele Gaifax on Fri, 18 Dec 2015 11:29:51 +0100) References: <87h9ladp7v.fsf@metapensiero.it> <87y4csrqw0.fsf@metapensiero.it> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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 (-----) > From: Lele Gaifax > Date: Fri, 18 Dec 2015 11:29:51 +0100 > > Maybe I could have stated that I fulfilled the assignment process (# 988143), > should that smooth the acceptance of the patch. Thanks. This patch should be reviewed and approved first. Fabián, can you look into this patch, please? From unknown Thu Aug 14 18:37:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21783: Copyright assignment Resent-From: Lele Gaifax Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Feb 2016 08:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21783 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 21783@debbugs.gnu.org Received: via spool by 21783-submit@debbugs.gnu.org id=B21783.145431629728439 (code B ref 21783); Mon, 01 Feb 2016 08:45:01 +0000 Received: (at 21783) by debbugs.gnu.org; 1 Feb 2016 08:44:57 +0000 Received: from localhost ([127.0.0.1]:43878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aQA6T-0007Od-91 for submit@debbugs.gnu.org; Mon, 01 Feb 2016 03:44:57 -0500 Received: from mail.arstecnica.it ([144.76.81.238]:38502) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aQA6R-0007OQ-1i for 21783@debbugs.gnu.org; Mon, 01 Feb 2016 03:44:55 -0500 Received: from nautilus (assp.arstecnica.it [192.168.1.102]) by mail.arstecnica.it (Postfix) with ESMTPSA id 67C7383E34E for <21783@debbugs.gnu.org>; Mon, 1 Feb 2016 08:44:48 +0000 (UTC) Received: from nautilus ([151.62.10.4] helo=nautilus) by assp.arstecnica.it with SMTPS(AES128-GCM-SHA256) (2.3.3); 1 Feb 2016 08:44:47 +0000 From: Lele Gaifax In-Reply-To: <83y4csvxfc.fsf@gnu.org> References: <87h9ladp7v.fsf@metapensiero.it> <87y4csrqw0.fsf@metapensiero.it> <83y4csvxfc.fsf@gnu.org> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.0.50.30 (x86_64-pc-linux-gnu) Date: Mon, 01 Feb 2016 09:44:47 +0100 Message-ID: <87d1sgu8e8.fsf@metapensiero.it> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Assp-Version: 2.3.3(14029) on assp.arstecnica.it X-Assp-ID: assp.arstecnica.it m1-16288-01095 X-Assp-Session: 10D7C6A8 (mail 1) X-Assp-Envelope-From: lele@metapensiero.it X-Assp-Intended-For: 21783@debbugs.gnu.org X-Assp-Client-TLS: yes X-Assp-Server-TLS: yes X-Spam-Score: -0.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: -0.0 (/) Is there anything else I could do to help getting this into Emacs 25? thank you&ciao, lele. --=20 nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. From unknown Thu Aug 14 18:37:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21783: Copyright assignment Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Feb 2016 05:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21783 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Lele Gaifax Cc: =?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina , Mark Oteiza , 21783@debbugs.gnu.org Received: via spool by 21783-submit@debbugs.gnu.org id=B21783.145620472025208 (code B ref 21783); Tue, 23 Feb 2016 05:19:02 +0000 Received: (at 21783) by debbugs.gnu.org; 23 Feb 2016 05:18:40 +0000 Received: from localhost ([127.0.0.1]:38844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aY5Mt-0006YW-OF for submit@debbugs.gnu.org; Tue, 23 Feb 2016 00:18:39 -0500 Received: from hermes.netfonds.no ([80.91.224.195]:40410) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aY5Mq-0006YL-HP for 21783@debbugs.gnu.org; Tue, 23 Feb 2016 00:18:38 -0500 Received: from cpe-60-225-211-161.nsw.bigpond.net.au ([60.225.211.161] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aY5MR-000145-C3; Tue, 23 Feb 2016 06:18:12 +0100 From: Lars Ingebrigtsen References: <87h9ladp7v.fsf@metapensiero.it> <87y4csrqw0.fsf@metapensiero.it> <83y4csvxfc.fsf@gnu.org> <87d1sgu8e8.fsf@metapensiero.it> Date: Tue, 23 Feb 2016 16:18:06 +1100 In-Reply-To: <87d1sgu8e8.fsf@metapensiero.it> (Lele Gaifax's message of "Mon, 01 Feb 2016 09:44:47 +0100") Message-ID: <87a8ms0zu9.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-MailScanner-ID: 1aY5MR-000145-C3 X-Netfonds-MailScanner: Found to be clean X-Netfonds-MailScanner-From: larsi@gnus.org MailScanner-NULL-Check: 1456809492.26497@Zldp8BnxfVHcNMhe06rhOA X-Spam-Status: No X-Spam-Score: 0.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: 0.0 (/) Lele Gaifax writes: > Is there anything else I could do to help getting this into Emacs 25? I think we're basically waiting for somebody with Python mode experience to review the patch. Fabi=E1n? Mark? --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Thu Aug 14 18:37:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Lele Gaifax Subject: bug#21783: closed (Patch applied) Message-ID: References: <87h9ladp7v.fsf@metapensiero.it> X-Gnu-PR-Message: they-closed 21783 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 21783@debbugs.gnu.org Date: Wed, 06 Apr 2016 09:00:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1459933202-32283-1" This is a multi-part message in MIME format... ------------=_1459933202-32283-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #21783: 25.0.50; python.el does not support new Python 3.5 keywords which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 21783@debbugs.gnu.org. --=20 21783: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21783 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1459933202-32283-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 21783-close) by debbugs.gnu.org; 6 Apr 2016 08:59:38 +0000 Received: from localhost ([127.0.0.1]:50972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anjJK-0008Nk-E0 for submit@debbugs.gnu.org; Wed, 06 Apr 2016 04:59:38 -0400 Received: from mail-lb0-f181.google.com ([209.85.217.181]:35718) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anjJI-0008NZ-Eb for 21783-close@debbugs.gnu.org; Wed, 06 Apr 2016 04:59:36 -0400 Received: by mail-lb0-f181.google.com with SMTP id bc4so25477100lbc.2 for <21783-close@debbugs.gnu.org>; Wed, 06 Apr 2016 01:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=hTXMXE7SJbVK/3qc+FXYNB/N85ZzbB7pl0KGPeJC+54=; b=LCrADs8oXargsylZm9JDa7azB+jnZ2svILIHpNSAxDDqfxyInvK/F4TYqpRK6QW6u7 rfCsYJ7e44g4dpQ5IRtNpUZMHGBrwvbwLfESVMke3M7O156Dyu6sw7Cg1aCamQRswolp Y8yqLpjIv/qiLujsPxOLG6BTlxFEP2CeqTzXzccAX76NPQls5DhgUB6EP8DXphMaFfgw MByHJ7OA9MJnViKAzFzmLqkkS/tabaoilNaa8qL5u/Cdn4q6Ul35ZAkvvBqr00kcKebJ PyT3x/Hj8+HF1lmqAvPuHHyJAQHi9WrBp5O05HuW65NMKxINAXEAWRgHlXAiA9qru3Nm 3T6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hTXMXE7SJbVK/3qc+FXYNB/N85ZzbB7pl0KGPeJC+54=; b=eUovAwXeBxBDFCq+8IkjlfB3pvEqM+cz2MjkzG9pOesIjvN3MBsMJT1cgxnO1MD99k ZY30svhXmV+/8R5pZoslGuy5EaKsEMxtVNOlpWJ4lkbG0ZvhU9x653R/RenVEHCptsSi yy3NOSKRILYGeaNU0m0ELNDr+gVGe7Gb1HP7EgkLc/ONNqSNjsXZVs3BDS5P+plKrO8A AiaB4Bh8Jli7AVc8NwSAiROgOZTNSmlQLIo9hh7h9sR69vjEE+tgXTAmybSKLTCaBWjH hUGvbnHQj2vtO4s80ZHR8V1lw8EYXUWgsv4nh+PZ3YD3tL4VH6BVevn5QxTIC3AuzlS0 4z0g== X-Gm-Message-State: AD7BkJJk3b61C47eJ/Jkd3HqR4BCK1MakoXDSZNQIchvwcGhvN8InXW3dvdYCgs0/Nb7GLKmA3dUJ04qJUoQ3g== X-Received: by 10.112.202.105 with SMTP id kh9mr10719062lbc.57.1459933170125; Wed, 06 Apr 2016 01:59:30 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Jorgen_Sch=C3=A4fer?= Date: Wed, 06 Apr 2016 08:59:20 +0000 Message-ID: Subject: Patch applied To: 21783-close@debbugs.gnu.org Content-Type: multipart/alternative; boundary=001a11c36c94005063052fcd2e59 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 21783-close 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 (/) --001a11c36c94005063052fcd2e59 Content-Type: text/plain; charset=UTF-8 Hello! I just pushed this patch to git master as 1f6b0bc1. Thank you so much for your contribution and I am very sorry that it took so long to get into the repository. Regards, Jorgen --001a11c36c94005063052fcd2e59 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello!
I just pushed this patch to git master as=C2=A0= 1f6b0bc1. Thank you so much for your contribution and I am very sorry that = it took so long to get into the repository.

Regard= s,
Jorgen
--001a11c36c94005063052fcd2e59-- ------------=_1459933202-32283-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Oct 2015 12:27:36 +0000 Received: from localhost ([127.0.0.1]:43353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZrmIV-0005mV-Uw for submit@debbugs.gnu.org; Thu, 29 Oct 2015 08:27:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47277) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zrj4M-0007ha-DY for submit@debbugs.gnu.org; Thu, 29 Oct 2015 05:00:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zrj4K-000827-M2 for submit@debbugs.gnu.org; Thu, 29 Oct 2015 05:00:26 -0400 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 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrj4K-000823-Ix for submit@debbugs.gnu.org; Thu, 29 Oct 2015 05:00:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrj4J-0008MJ-2m for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 05:00:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zrj4C-0007zv-Gn for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 05:00:23 -0400 Received: from mail.arstecnica.it ([144.76.81.238]:40944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrj4C-0007z4-6z for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 05:00:16 -0400 Received: from nautilus (unknown [192.168.1.102]) by mail.arstecnica.it (Postfix) with ESMTPSA id A1DF783E365 for ; Thu, 29 Oct 2015 09:00:05 +0000 (UTC) Received: from nautilus ([151.62.147.82] helo=nautilus) by assp.arstecnica.it with SMTPS(AES128-GCM-SHA256) (2.3.3); 29 Oct 2015 09:00:04 +0000 From: Lele Gaifax To: bug-gnu-emacs@gnu.org Subject: 25.0.50; python.el does not support new Python 3.5 keywords User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/25.0.50.12 (x86_64-pc-linux-gnu) Date: Thu, 29 Oct 2015 10:00:04 +0100 Message-ID: <87h9ladp7v.fsf@metapensiero.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Assp-Version: 2.3.3(14029) on assp.arstecnica.it X-Assp-ID: assp.arstecnica.it m1-09205-04025 X-Assp-Session: 13AACEF4 (mail 1) X-Assp-Envelope-From: lele@metapensiero.it X-Assp-Intended-For: bug-gnu-emacs@gnu.org X-Assp-Client-TLS: yes X-Assp-Server-TLS: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 29 Oct 2015 08:27:14 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -4.1 (----) --=-=-= Content-Type: text/plain Python 3.5, released in mid September 2015, introduced a few new keywords to better support asynchronous code, "async" and "await" in particular. See https://www.python.org/dev/peps/pep-0492/ for details. To avoid breaking already written users code, they are technically not "reserved keywords", but accordingly to the plan they will become that in Python 3.7 (https://www.python.org/dev/peps/pep-0492/#id75). Currently python.el doesn't know anything about them, so it obviously cannot properly indent the following code: async def coroutine(foo, bar): | where "|" represent the cursor position, nor highlight them in any way. I'm attaching a patch that implements such support, with some test cases. See also the thread http://thread.gmane.org/gmane.emacs.devel/190950 where I initially sent the same patch and where I've been solicited to create a bug report. Hope this helps, thanks in advance, ciao, lele. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=python_el+pep492.patch Content-Description: Add PEP492 support to python.el diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 6ff12b5..9f5c087 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -384,7 +384,10 @@ python-mode-map (defconst python-rx-constituents `((block-start . ,(rx symbol-start (or "def" "class" "if" "elif" "else" "try" - "except" "finally" "for" "while" "with") + "except" "finally" "for" "while" "with" + ;; Python 3.5+ PEP492 + (and "async" (+ space) + (or "def" "for" "with"))) symbol-end)) (dedenter . ,(rx symbol-start (or "elif" "else" "except" "finally") @@ -395,7 +398,11 @@ python-mode-map symbol-end)) (decorator . ,(rx line-start (* space) ?@ (any letter ?_) (* (any word ?_)))) - (defun . ,(rx symbol-start (or "def" "class") symbol-end)) + (defun . ,(rx symbol-start + (or "def" "class" + ;; Python 3.5+ PEP492 + (and "async" (+ space) "def")) + symbol-end)) (if-name-main . ,(rx line-start "if" (+ space) "__name__" (+ space) "==" (+ space) (any ?' ?\") "__main__" (any ?' ?\") @@ -527,6 +534,8 @@ python-font-lock-keywords ;; fontified like that in order to keep font-lock consistent between ;; Python versions. "nonlocal" + ;; Python 3.5+ PEP492 + (and "async" (+ space) (or "def" "for" "with")) ;; Extra: "self") symbol-end) diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 44b05e2..23d799a 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -604,6 +604,42 @@ python-tests-visible-string (should (eq (car (python-indent-context)) :after-line)) (should (= (python-indent-calculate-indentation) 0)))) +(ert-deftest python-indent-after-async-block-1 () + "Test PEP492 async def." + (python-tests-with-temp-buffer + " +async def foo(a, b, c=True): +" + (should (eq (car (python-indent-context)) :no-indent)) + (should (= (python-indent-calculate-indentation) 0)) + (goto-char (point-max)) + (should (eq (car (python-indent-context)) :after-block-start)) + (should (= (python-indent-calculate-indentation) 4)))) + +(ert-deftest python-indent-after-async-block-2 () + "Test PEP492 async with." + (python-tests-with-temp-buffer + " +async with foo(a) as mgr: +" + (should (eq (car (python-indent-context)) :no-indent)) + (should (= (python-indent-calculate-indentation) 0)) + (goto-char (point-max)) + (should (eq (car (python-indent-context)) :after-block-start)) + (should (= (python-indent-calculate-indentation) 4)))) + +(ert-deftest python-indent-after-async-block-3 () + "Test PEP492 async for." + (python-tests-with-temp-buffer + " +async for a in sequencer(): +" + (should (eq (car (python-indent-context)) :no-indent)) + (should (= (python-indent-calculate-indentation) 0)) + (goto-char (point-max)) + (should (eq (car (python-indent-context)) :after-block-start)) + (should (= (python-indent-calculate-indentation) 4)))) + (ert-deftest python-indent-after-backslash-1 () "The most common case." (python-tests-with-temp-buffer @@ -1483,6 +1519,26 @@ python-tests-visible-string (beginning-of-line) (point)))))) +(ert-deftest python-nav-beginning-of-defun-3 () + (python-tests-with-temp-buffer + " +class C(object): + + async def m(self): + return await self.c() + + async def c(self): + pass +" + (python-tests-look-at "self.c()") + (should (= (save-excursion + (python-nav-beginning-of-defun) + (point)) + (save-excursion + (python-tests-look-at "async def m" -1) + (beginning-of-line) + (point)))))) + (ert-deftest python-nav-end-of-defun-1 () (python-tests-with-temp-buffer " --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. --=-=-=-- ------------=_1459933202-32283-1-- From unknown Thu Aug 14 18:37:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21783: closed (Patch applied) Resent-From: Lele Gaifax Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Apr 2016 10:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21783 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 21783@debbugs.gnu.org Received: via spool by 21783-submit@debbugs.gnu.org id=B21783.145993996010723 (code B ref 21783); Wed, 06 Apr 2016 10:53:01 +0000 Received: (at 21783) by debbugs.gnu.org; 6 Apr 2016 10:52:40 +0000 Received: from localhost ([127.0.0.1]:51035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anl4i-0002mt-JG for submit@debbugs.gnu.org; Wed, 06 Apr 2016 06:52:40 -0400 Received: from mail.arstecnica.it ([144.76.81.238]:53246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anl4g-0002mf-Ie for 21783@debbugs.gnu.org; Wed, 06 Apr 2016 06:52:39 -0400 Received: from nautilus (assp.arstecnica.it [192.168.1.102]) by mail.arstecnica.it (Postfix) with ESMTPSA id D961883EC9A for <21783@debbugs.gnu.org>; Wed, 6 Apr 2016 10:52:30 +0000 (UTC) Received: from nautilus ([151.62.77.221] helo=nautilus) by assp.arstecnica.it with SMTPS(AES128-GCM-SHA256) (2.3.3); 6 Apr 2016 10:52:30 +0000 From: Lele Gaifax In-Reply-To: References: <87h9ladp7v.fsf@metapensiero.it> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.0.92.5 (x86_64-pc-linux-gnu) Date: Wed, 06 Apr 2016 12:52:30 +0200 Message-ID: <87oa9nc8lt.fsf@metapensiero.it> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Assp-Version: 2.3.3(14029) on assp.arstecnica.it X-Assp-ID: assp.arstecnica.it m1-39950-02149 X-Assp-Session: AA468114 (mail 1) X-Assp-Envelope-From: lele@metapensiero.it X-Assp-Intended-For: 21783@debbugs.gnu.org X-Assp-Client-TLS: yes X-Assp-Server-TLS: yes X-Spam-Score: -0.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: -0.0 (/) GNU bug Tracking System writes: > I just pushed this patch to git master as 1f6b0bc1. Thank you so much for > your contribution and I am very sorry that it took so long to get into the > repository. Thank you Jorgen, no need to apologize, really! But I wonder: is there any chance to get this "backported" to the emacs-25 branch as well? Is there anything I should do to make that happen? thanks again, ciao, lele. --=20 nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 27 19:38:48 2016 Received: (at control) by debbugs.gnu.org; 27 Apr 2016 23:38:48 +0000 Received: from localhost ([127.0.0.1]:50975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avZ2e-0004qt-6k for submit@debbugs.gnu.org; Wed, 27 Apr 2016 19:38:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57627) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avZ2c-0004qh-Iv for control@debbugs.gnu.org; Wed, 27 Apr 2016 19:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avZ2N-0000TP-MT for control@debbugs.gnu.org; Wed, 27 Apr 2016 19:38:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:32908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avZ2N-0000TL-JA for control@debbugs.gnu.org; Wed, 27 Apr 2016 19:38:31 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1avZ2N-00028k-6U for control@debbugs.gnu.org; Wed, 27 Apr 2016 19:38:31 -0400 Subject: control message for bug 23145 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Wed, 27 Apr 2016 19:38:31 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: control 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: -6.0 (------) forcemerge 21783 23145