GNU bug report logs - #76353
[PATCH] Add python2-mode and python2-ts-mode

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: kobarity <kobarity@HIDDEN>; Keywords: patch; dated Sun, 16 Feb 2025 22:32:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 76353 <at> debbugs.gnu.org:


Received: (at 76353) by debbugs.gnu.org; 17 Feb 2025 14:37:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 17 09:37:15 2025
Received: from localhost ([127.0.0.1]:45026 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tk2FH-0001fP-5x
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2025 09:37:15 -0500
Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:51335)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <kobarity@HIDDEN>)
 id 1tk2FD-0001eo-D3
 for 76353 <at> debbugs.gnu.org; Mon, 17 Feb 2025 09:37:12 -0500
Received: by mail-pl1-x629.google.com with SMTP id
 d9443c01a7336-221050f3f00so35996205ad.2
 for <76353 <at> debbugs.gnu.org>; Mon, 17 Feb 2025 06:37:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1739803025; x=1740407825; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:user-agent:references
 :in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject
 :date:message-id:reply-to;
 bh=yg0GshcfBs49x0kyPDWsrtw7oFKnmVhwNncz2838bBM=;
 b=hiY3VZT3ngDkxA2sfHHtXFlnImNc0qltlioYoR7BW3KSVefibA8xg6s2xnYcO4Sm2D
 vxh/moe0USdWb8e6VSUVtuClodkUVFFO3TtiK1sXlofoL2AzLfBN/qyH2ur8T0MtyCFC
 2PabTn30QncJaYOIJ/UMurBDIS03lHBeCAxS+sqp5umIgYVHKi9xtgQja5dsXLoPdF15
 szRH5z819woo4PaFvymwiVKR0mNWXAzgZzIsgHA/E8dnF36T4NdNs68cqtdLwsHml9Au
 vS7dth7XPt2jFYoec5T9DdaV50enNSjMsYKlq4LJ3NKWdUbhZJSfNyYjr/+n/jvsUwjC
 hXpA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1739803025; x=1740407825;
 h=content-transfer-encoding:mime-version:user-agent:references
 :in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=yg0GshcfBs49x0kyPDWsrtw7oFKnmVhwNncz2838bBM=;
 b=mrPN1T28i7gihAUe8D1e3AknJYUlx5uFP2VzUWsfZ6wec8OcddwLvDjC470nBpKRBb
 GjRuB6NacNhgMofNcFbcQ9viM5zdKNaz4jo8w8lnm/5p+H+m5Pb5XGMd8oYq0Z19aJQy
 M9acVjQkOj7iWZz7wKXyE3cdMJZGSb3y5hyoe+/15Kl/LoOCCVNtD2es7umguHcdKRb1
 4xRDtsDLodrkVZXf55eRZADk4PinPQSjiXFo/TNpxQK63hacYByuo46xHl3PjPAejsuf
 w5qP9YmoxD2LHtdqPqzIgbG37jMJ9MjNTjGV20bPWwqv8s6AoBsSC8pXcCClN1+z9lmE
 UOUg==
X-Forwarded-Encrypted: i=1;
 AJvYcCWf4bnVVSdqbmhAr1GkLe5FaPRDlZr3rKrzf6LzJ3XHfBlW9AU/f5mc2xVqC/gikzEIL1TVWw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YwKozJvbgEXTP/R4wkF1BBjpY0znwiKgeRMqSyh4PJuZhEBTcbL
 5gxMr1aXGy04vYwxbTaBkNDkXs1bPmOR5eRtNRpA4Z/9prAe2j0J
X-Gm-Gg: ASbGncvl+XUpxRU19bflMlMwYtL5gzKvmmDC5ygmyMMEn0GSqsLEdxH4HgQH6hkEsxJ
 goZq9oPQEf1rnUyH0WRCatZc3g5pYoXxuJFvlaGWWyTb39hmx4l2weY2YvnLW6ekuXiVBtGWM3Y
 BhxoNs/FCkL7uTxHRE7cM4DhM9gsQaL4pZOYa/NkhUuHYNQdHyNSeQiWIcs6jZUdN+AO2/LRZWT
 RPaWVF/gqFaVIKDhZ7Idz+dxRk1cfuUBwjJN9LG4d8fG+SBdbIIUmVeZvO9bpU8Yfxz6idh1Mtl
 XsKSTRebtbWi40/1Ib4Q0ER5vHQjjl8dF1Kwh9EYcbMp7w==
X-Google-Smtp-Source: AGHT+IEBIwDfjaiVLsal3X97guwZE+ZyinZ/lCuFw3t9j/NNribVqccArCFxlba3eFx46Qc0wAgluw==
X-Received: by 2002:a17:902:f54e:b0:220:ca08:8986 with SMTP id
 d9443c01a7336-2210402d6b2mr185994265ad.22.1739803025221; 
 Mon, 17 Feb 2025 06:37:05 -0800 (PST)
Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-220d545d093sm72092855ad.128.2025.02.17.06.37.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 17 Feb 2025 06:37:04 -0800 (PST)
Date: Mon, 17 Feb 2025 23:37:02 +0900
Message-ID: <eke7seocr629.wl-kobarity@HIDDEN>
From: kobarity <kobarity@HIDDEN>
To: Konstantin Kharlamov <Hi-Angel@HIDDEN>
Subject: Re: bug#76353: [PATCH] Add python2-mode and python2-ts-mode
In-Reply-To: <931623259b3b334d73bf56ebda946ff0a153494a.camel@HIDDEN>
References: <eke7wmdpr070.wl-kobarity@HIDDEN>
 <3d090b7d07e854585c0afe4699e165a47dbfdeb4.camel@HIDDEN>
 <af2ac16a142935b8a47729a2beb09b9ffa80fe7b.camel@HIDDEN>
 <86frkcbvua.fsf@HIDDEN>
 <931623259b3b334d73bf56ebda946ff0a153494a.camel@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76353
Cc: 76353 <at> debbugs.gnu.org, tomas@HIDDEN, stefankangas@HIDDEN,
 kevin.legouguec@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, shipmints@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Konstantin Kharlamov wrote:
>=20
> On Mon, 2025-02-17 at 14:26 +0200, Eli Zaretskii wrote:
> > > From: Konstantin Kharlamov <Hi-Angel@HIDDEN>
> > > Date: Mon, 17 Feb 2025 07:57:57 +0300
> > >=20
> > > On Mon, 2025-02-17 at 07:53 +0300, Konstantin Kharlamov wrote:
> > > > but AFAIK in Emacs this
> > > > mandatory, so other than that looks good to me =F0=9F=91=8D=20
> > >=20
> > > s/mandatory/isn't mandatory
> >=20
> > What is...not "mandatory", but "very much desirable", is to avoid
> > separate commits that must be applied together or not at all.=C2=A0 Even
> > if
> > they change different and separate parts of Emacs.
>=20
> Sure.  A commit should be self-contained functional change, unrelated
> to other commits (unless the opposite is desired by maintainers for
> specific reasons, which happens rarely).  It is kobarity's case though,
> because kobarity mentioned the change may be sent separately =F0=9F=98=8A

I agree that it is better to fix the separate issues in their own
patches, and since I think the discussion of adding a `python2-mode'
will take a bit of time, I have sent the FFAP fix to
76364 <at> debbugs.gnu.org.  The FFAP fix is small and I expect it to be
accepted relatively quickly.  Once the fix is committed, I will rebase
the `python2-mode' patch.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76353; Package emacs. Full text available.

Message received at 76353 <at> debbugs.gnu.org:


Received: (at 76353) by debbugs.gnu.org; 17 Feb 2025 12:47:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 17 07:47:57 2025
Received: from localhost ([127.0.0.1]:44418 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tk0XU-0001Mu-Uf
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2025 07:47:57 -0500
Received: from forward102a.mail.yandex.net ([178.154.239.85]:58364)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <Hi-Angel@HIDDEN>)
 id 1tk0XS-0001MS-Fg
 for 76353 <at> debbugs.gnu.org; Mon, 17 Feb 2025 07:47:55 -0500
Received: from mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net
 (mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net
 [IPv6:2a02:6b8:c0f:4883:0:640:cc3a:0])
 by forward102a.mail.yandex.net (Yandex) with ESMTPS id C58F260B5A;
 Mon, 17 Feb 2025 15:47:46 +0300 (MSK)
Received: by mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net
 (smtp/Yandex) with ESMTPSA id elTWso0OgeA0-tSVyYerd; 
 Mon, 17 Feb 2025 15:47:46 +0300
X-Yandex-Fwd: 1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1739796466; bh=rOegmYcaAgjRilYg2fdUiwlnQcQauS7MCsVd3SSG5kU=;
 h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID;
 b=drghepJj6lHBA+n5smRDY3yZqCyFvRTSvCPLz0GpgKCRPrI35Kr32j3yBtM3vnaJs
 +c+2WHb/vKfTda56QOeMSfoVHzyl+y7zLxyks1LaC1UkqvnLNfh7NcCiwz5s0C5c4K
 WHbrv5+xQ/8V7XACPhGCConX7MYWU7u4mWSm7vtg=
Authentication-Results: mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net;
 dkim=pass header.i=@yandex.ru
Message-ID: <931623259b3b334d73bf56ebda946ff0a153494a.camel@HIDDEN>
Subject: Re: bug#76353: [PATCH] Add python2-mode and python2-ts-mode
From: Konstantin Kharlamov <Hi-Angel@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Date: Mon, 17 Feb 2025 15:47:39 +0300
In-Reply-To: <86frkcbvua.fsf@HIDDEN>
References: <eke7wmdpr070.wl-kobarity@HIDDEN>
 <3d090b7d07e854585c0afe4699e165a47dbfdeb4.camel@HIDDEN>
 <af2ac16a142935b8a47729a2beb09b9ffa80fe7b.camel@HIDDEN>
 <86frkcbvua.fsf@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
User-Agent: Evolution 3.54.3 
MIME-Version: 1.0
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 76353
Cc: 76353 <at> debbugs.gnu.org, tomas@HIDDEN, stefankangas@HIDDEN,
 kevin.legouguec@HIDDEN, kobarity@HIDDEN, shipmints@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Mon, 2025-02-17 at 14:26 +0200, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <Hi-Angel@HIDDEN>
> > Date: Mon, 17 Feb 2025 07:57:57 +0300
> >=20
> > On Mon, 2025-02-17 at 07:53 +0300, Konstantin Kharlamov wrote:
> > > but AFAIK in Emacs this
> > > mandatory, so other than that looks good to me =F0=9F=91=8D=20
> >=20
> > s/mandatory/isn't mandatory
>=20
> What is...not "mandatory", but "very much desirable", is to avoid
> separate commits that must be applied together or not at all.=C2=A0 Even
> if
> they change different and separate parts of Emacs.

Sure.  A commit should be self-contained functional change, unrelated
to other commits (unless the opposite is desired by maintainers for
specific reasons, which happens rarely).  It is kobarity's case though,
because kobarity mentioned the change may be sent separately =F0=9F=98=8A




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76353; Package emacs. Full text available.

Message received at 76353 <at> debbugs.gnu.org:


Received: (at 76353) by debbugs.gnu.org; 17 Feb 2025 12:27:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 17 07:27:07 2025
Received: from localhost ([127.0.0.1]:44268 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tk0DL-00054Y-6h
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2025 07:27:07 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:39288)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tk0DI-00053S-Gz
 for 76353 <at> debbugs.gnu.org; Mon, 17 Feb 2025 07:27:05 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1tk0DC-0006pR-Pa; Mon, 17 Feb 2025 07:26:58 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=aJQoOnqhSa4wDXS+QeIyf203cJRYuW9ah3PWaUaaYFQ=; b=O4AgPvn++cuFcmgQ7/eE
 Tz/9D+jBdH6JRqZyQBO3tgmeyjy4xy1qHaabq+1wiqP68hHO3fxmYYRmVpQTfheddAOlKBVJJ6BUc
 msp4HBR1qTGMEjXtBFfy7udhiKaXjPwG3RBiKra9NaokvISJDZUNvlXwQjXokUcXYgraWwuVoUNPH
 IvW98odm2M5WuFoGBpCSVBACj8R6i4KY6ZBjFXvQu+jGB4itO5rLYthfLPk9dfVjuiWQy+4IJAGo1
 JdHgw8c0y2cnVT6mBnhVr14Pp6b+Ez9nKVuVCAS1lCLMNa/iu+m3innBNpTZarTxjga1RlgBWuJQj
 7ACR1Imdx757WA==;
Date: Mon, 17 Feb 2025 14:26:53 +0200
Message-Id: <86frkcbvua.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Konstantin Kharlamov <Hi-Angel@HIDDEN>
In-Reply-To: <af2ac16a142935b8a47729a2beb09b9ffa80fe7b.camel@HIDDEN>
 (message from Konstantin Kharlamov on Mon, 17 Feb 2025 07:57:57 +0300)
Subject: Re: bug#76353: [PATCH] Add python2-mode and python2-ts-mode
References: <eke7wmdpr070.wl-kobarity@HIDDEN>
 <3d090b7d07e854585c0afe4699e165a47dbfdeb4.camel@HIDDEN>
 <af2ac16a142935b8a47729a2beb09b9ffa80fe7b.camel@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76353
Cc: 76353 <at> debbugs.gnu.org, tomas@HIDDEN, stefankangas@HIDDEN,
 kevin.legouguec@HIDDEN, kobarity@HIDDEN, shipmints@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Konstantin Kharlamov <Hi-Angel@HIDDEN>
> Date: Mon, 17 Feb 2025 07:57:57 +0300
> 
> On Mon, 2025-02-17 at 07:53 +0300, Konstantin Kharlamov wrote:
> > but AFAIK in Emacs this
> > mandatory, so other than that looks good to me 👍 
> 
> s/mandatory/isn't mandatory

What is...not "mandatory", but "very much desirable", is to avoid
separate commits that must be applied together or not at all.  Even if
they change different and separate parts of Emacs.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76353; Package emacs. Full text available.

Message received at 76353 <at> debbugs.gnu.org:


Received: (at 76353) by debbugs.gnu.org; 17 Feb 2025 04:58:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 16 23:58:09 2025
Received: from localhost ([127.0.0.1]:40927 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tjtCq-0008QI-MB
	for submit <at> debbugs.gnu.org; Sun, 16 Feb 2025 23:58:09 -0500
Received: from forward101a.mail.yandex.net ([178.154.239.84]:34032)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <Hi-Angel@HIDDEN>)
 id 1tjtCn-0008P1-Cn
 for 76353 <at> debbugs.gnu.org; Sun, 16 Feb 2025 23:58:06 -0500
Received: from mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net
 (mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net
 [IPv6:2a02:6b8:c0f:2f03:0:640:5d54:0])
 by forward101a.mail.yandex.net (Yandex) with ESMTPS id 9CAD860C96;
 Mon, 17 Feb 2025 07:57:58 +0300 (MSK)
Received: by mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net
 (smtp/Yandex) with ESMTPSA id vvLkshgOpeA0-qbOWtzQT; 
 Mon, 17 Feb 2025 07:57:58 +0300
X-Yandex-Fwd: 1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1739768278; bh=+MfVm5NgbWSmRhsj/6vsIsBY1IsUSuGRnQfVKmNKfKc=;
 h=In-Reply-To:Date:References:To:From:Subject:Message-ID;
 b=U5odunbhafPMxM1EbdnRbi5gSZFUkrJWDN7nQUFvWihqRoj/Q1m9fNzPBxja/dfOP
 bTzw2asbLNKY3K5fVWJ7aa9u1Jc/MivHDwjADK1qQyKdj8RrntkSvaYM0EvTX8DlT0
 7/S1w3tqoJetn0rydERg1BmU0dgA/7UUuAikZBLM=
Authentication-Results: mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net;
 dkim=pass header.i=@yandex.ru
Message-ID: <af2ac16a142935b8a47729a2beb09b9ffa80fe7b.camel@HIDDEN>
Subject: Re: [PATCH] Add python2-mode and python2-ts-mode
From: Konstantin Kharlamov <Hi-Angel@HIDDEN>
To: kobarity <kobarity@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>, 
 tomas@HIDDEN, Ship Mints <shipmints@HIDDEN>,
 =?ISO-8859-1?Q?K=E9vin?= Le Gouguec <kevin.legouguec@HIDDEN>,
 76353 <at> debbugs.gnu.org
Date: Mon, 17 Feb 2025 07:57:57 +0300
In-Reply-To: <3d090b7d07e854585c0afe4699e165a47dbfdeb4.camel@HIDDEN>
References: <eke7wmdpr070.wl-kobarity@HIDDEN>
 <3d090b7d07e854585c0afe4699e165a47dbfdeb4.camel@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
User-Agent: Evolution 3.54.3 
MIME-Version: 1.0
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76353
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Mon, 2025-02-17 at 07:53 +0300, Konstantin Kharlamov wrote:
> but AFAIK in Emacs this
> mandatory, so other than that looks good to me =F0=9F=91=8D=20

s/mandatory/isn't mandatory




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76353; Package emacs. Full text available.

Message received at 76353 <at> debbugs.gnu.org:


Received: (at 76353) by debbugs.gnu.org; 17 Feb 2025 04:53:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 16 23:53:23 2025
Received: from localhost ([127.0.0.1]:40902 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tjt8F-0007tG-H7
	for submit <at> debbugs.gnu.org; Sun, 16 Feb 2025 23:53:23 -0500
Received: from forward500d.mail.yandex.net ([178.154.239.208]:50500)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <Hi-Angel@HIDDEN>)
 id 1tjt8B-0007sU-Cq
 for 76353 <at> debbugs.gnu.org; Sun, 16 Feb 2025 23:53:21 -0500
Received: from mail-nwsmtp-smtp-production-main-95.klg.yp-c.yandex.net
 (mail-nwsmtp-smtp-production-main-95.klg.yp-c.yandex.net
 [IPv6:2a02:6b8:c42:694a:0:640:6efd:0])
 by forward500d.mail.yandex.net (Yandex) with ESMTPS id 7416360E0E;
 Mon, 17 Feb 2025 07:53:11 +0300 (MSK)
Received: by mail-nwsmtp-smtp-production-main-95.klg.yp-c.yandex.net
 (smtp/Yandex) with ESMTPSA id ArLdAveOea60-qtb5IPmb; 
 Mon, 17 Feb 2025 07:53:10 +0300
X-Yandex-Fwd: 1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1739767990; bh=02f6HAPUSVfa/n5AfOD7GEpPUKxwvkYUwpdXU8zmM1U=;
 h=In-Reply-To:Date:References:To:From:Subject:Message-ID;
 b=Aj3Z7eEW+FzCp2rZ1d+AgdW3rr3tKi4Ize7Btj2UADz+tbNt52dU96kucFq/Ao4PU
 RW90JpsvzJ4vMMOzBBjiYEs5hF+ptks/iw14KEHsw7fU+9RrXyuq8Qk7O1V5aNfw41
 CWAAMwR8mrJh8GG1a0fXs3fUjQTpVWojmhTDXeCo=
Authentication-Results: mail-nwsmtp-smtp-production-main-95.klg.yp-c.yandex.net;
 dkim=pass header.i=@yandex.ru
Message-ID: <3d090b7d07e854585c0afe4699e165a47dbfdeb4.camel@HIDDEN>
Subject: Re: [PATCH] Add python2-mode and python2-ts-mode
From: Konstantin Kharlamov <Hi-Angel@HIDDEN>
To: kobarity <kobarity@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>, 
 tomas@HIDDEN, Ship Mints <shipmints@HIDDEN>,
 =?ISO-8859-1?Q?K=E9vin?= Le Gouguec <kevin.legouguec@HIDDEN>,
 76353 <at> debbugs.gnu.org
Date: Mon, 17 Feb 2025 07:53:04 +0300
In-Reply-To: <eke7wmdpr070.wl-kobarity@HIDDEN>
References: <eke7wmdpr070.wl-kobarity@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
User-Agent: Evolution 3.54.3 
MIME-Version: 1.0
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76353
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Mon, 2025-02-17 at 07:31 +0900, kobarity wrote:
> There was a request to prevent the Python 2-only builtin "file" from
> being highlighted, and we discussed this in emacs-devel:
>=20
> https://lists.gnu.org/archive/html/emacs-devel/2025-01/msg00839.html
> https://lists.gnu.org/archive/html/emacs-devel/2025-02/msg00041.html
>=20
> One idea was to introduce the customizable variable `python-2-
> support'
> and it was implemented in commit
> 999d054dc1e265f1a39c10035a3a3f7f75de8445.=C2=A0 However, there was a
> suggestion to create a mode for Python 2.
>=20
> Attached is a patch to add `python2-mode' and `python2-ts-mode'.
> Please give your opinion on introducing them.=C2=A0 I think the pros and
> cons of this patch are as follows:
>=20
> Pros:
> - While `python-2-support' is a global setting, `python2-mode' and
> =C2=A0 `python2-ts-mode' can be used simultaneously with `python-mode' an=
d
> =C2=A0 `python-ts-mode'.
> - You can take advantage of the various means of mode selection
> =C2=A0 offered by Emacs.
> - While Python 3-only keywords/builtins are highlighted even if
> =C2=A0 `python-2-support' is enabled, they are not highlighted in
> =C2=A0 `python2-mode' and `python2-ts-mode'.
> - Keywords/Builtins are organized so they can be easily customized in
> =C2=A0 init.el.
>=20
> Cons:
> - There is a risk of bugs being introduced because of a certain
> amount
> =C2=A0 of change.
> - The separation of features is incomplete.=C2=A0 For example, Python
> =C2=A0 3-only features such as f-strings and type annotations are
> =C2=A0 supported even in `python2-mode' or `python2-ts-mode'.
>=20
> In the process of making this patch, I noticed that the FFAP support
> does not work in `python-ts-mode'.=C2=A0 This patch includes that fix.=C2=
=A0 If
> we decide not to adopt this patch, I will propose only the FFAP
> support fix in another patch.

LGTM!

I'd have separated FFAP support to a distinct commit anyway because
that simplifies review and logs reading, but AFAIK in Emacs this
mandatory, so other than that looks good to me =F0=9F=91=8D=20




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76353; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Feb 2025 22:31:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 16 17:31:51 2025
Received: from localhost ([127.0.0.1]:38644 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tjnB0-000275-Px
	for submit <at> debbugs.gnu.org; Sun, 16 Feb 2025 17:31:51 -0500
Received: from lists.gnu.org ([2001:470:142::17]:33854)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kobarity@HIDDEN>)
 id 1tjnAx-00026B-Fm
 for submit <at> debbugs.gnu.org; Sun, 16 Feb 2025 17:31:48 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <kobarity@HIDDEN>)
 id 1tjnAp-0000cx-2z
 for bug-gnu-emacs@HIDDEN; Sun, 16 Feb 2025 17:31:39 -0500
Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <kobarity@HIDDEN>)
 id 1tjnAn-0000xD-2p
 for bug-gnu-emacs@HIDDEN; Sun, 16 Feb 2025 17:31:38 -0500
Received: by mail-pl1-x632.google.com with SMTP id
 d9443c01a7336-220f4dd756eso39016705ad.3
 for <bug-gnu-emacs@HIDDEN>; Sun, 16 Feb 2025 14:31:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1739745095; x=1740349895; darn=gnu.org;
 h=mime-version:user-agent:subject:to:from:message-id:date:from:to:cc
 :subject:date:message-id:reply-to;
 bh=8fmDtRc9Pq54i5wc0ueOxXr7d9Dum+dCoByafmymq6Y=;
 b=mifjGeKgKnaQrcSj1jIab3hpmTJvzaMXr27KWYOaEBZxtyUUniWBmBOCrl7nznScvo
 e7ljahmiyuNHhrezxt/7paKJQWVgBUkFA0MSVjcOpSXysm4m873WQJtLp2+ZoS/6AJ63
 nwHocJsbEQzbB8Sn87nMfxnx3ZZTP6OsrhRdTH/BulIeWu4M2QuHw7JEsMWKr8jOpRmv
 0LgjMYh8h2ArN0Zxc2shVHHOJjlXeLjt+/so8GTTkiH/LcIAGmPqVOeu7F87HjquZqYc
 vAPA93Z+gYGsLkPaG7eNIpwtj8Ifnw1NY/ZDarwJbS/DU907qiB0UPAqHy5qoiINWsK4
 6nyg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1739745095; x=1740349895;
 h=mime-version:user-agent:subject:to:from:message-id:date
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=8fmDtRc9Pq54i5wc0ueOxXr7d9Dum+dCoByafmymq6Y=;
 b=F8hjdNctJebsAjfxWnPPArd8GSFkkqiY+Jq/V5Biz4gFcj760uVNdPthVmkcocdVs3
 SOdTSpDyEXG4AG2zBiAKd525iLAUicY8LfR8r2PmWoZAuajpDZO4RsxbbNB3780Kc0pq
 /ypZuba8JaPRp8/7rVJGq0rBUtkkoND8PsyCar8AfrxAn8jrdSUT8fI/nmqdv0ARoS28
 5iCs4bWWEKapXyuaAVkJDEeAsbSvKxLaBp41SWAdNH61Laso3CM5eXkQwvS5R9aJsamW
 o0ZaLQ0bnmG7HgWI1nIc5xqWJlSBLh/MRSGrYeZNhEdB3xe0UKidMB5r3HvBCB4C+0FW
 jptg==
X-Forwarded-Encrypted: i=1;
 AJvYcCUkIo0W+vz0ql6pc8LysCnhT9UFfLa88EKHgUwARMeHhGNQtXgi+Jztu1Pi+i5vp5woxpHwAZzuWqfvtrZA@HIDDEN
X-Gm-Message-State: AOJu0YyO5m3OZpc1QnH0PxLhDdPZMPZI0EfrdsRFZFac5nh2I5OIAcpB
 l3fo08V5eQbarqj1pdJnCcB4ybEyHKMrCmyMPllWi236r9aYiiQT
X-Gm-Gg: ASbGnctdoSrXDcniD1Gc112PJFgPtHrHaPTOIbLSr7psdKkikbyAasYLh6f36XriAcM
 fPvh3EBKY+Mz/intOX9ljbgHqiCxnJ2plveW/0hYmV08sB+OjZP+gX1VU/IX4tY/nk1edKt+6Y7
 WZ61pjElPdby9a6YXlMKYDXEsH8jspx/xBtaGwLeDg33leU7ILflDy4ox3GWUKUIWtq16xvzkmp
 1pj2v7anzzu9RY35hj87T2PDN1gGpD36h32n6DpPidqvF1hGSw9WI1sxEk5Srgv2fcWA3bifcCx
 gmP+9Y78T5QIDZCSxNRislrtGBc07IiBL9f3a53t4r6KEQ==
X-Google-Smtp-Source: AGHT+IEuj3uHOONs2TrGJO2LgsXlMlroaoPAvmO4jh8Ia3ZWLU1BQwNxFELj+Cg+0xviR3D55OqvFQ==
X-Received: by 2002:a17:902:e546:b0:216:5294:619b with SMTP id
 d9443c01a7336-221040d82e7mr126597895ad.47.1739745095234; 
 Sun, 16 Feb 2025 14:31:35 -0800 (PST)
Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161])
 by smtp.gmail.com with ESMTPSA id
 41be03b00d2f7-add286bc8e8sm3908282a12.39.2025.02.16.14.31.32
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 16 Feb 2025 14:31:34 -0800 (PST)
Date: Mon, 17 Feb 2025 07:31:31 +0900
Message-ID: <eke7wmdpr070.wl-kobarity@HIDDEN>
From: kobarity <kobarity@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>, tomas@HIDDEN, Konstantin
 Kharlamov <Hi-Angel@HIDDEN>, Ship Mints <shipmints@HIDDEN>,
 =?ISO-8859-1?Q?K=E9vin?= Le Gouguec <kevin.legouguec@HIDDEN>,
 bug-gnu-emacs@HIDDEN
Subject: [PATCH] Add python2-mode and python2-ts-mode
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: multipart/mixed; boundary="Multipart_Mon_Feb_17_07:31:31_2025-1"
Received-SPF: pass client-ip=2607:f8b0:4864:20::632;
 envelope-from=kobarity@HIDDEN; helo=mail-pl1-x632.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--Multipart_Mon_Feb_17_07:31:31_2025-1
Content-Type: text/plain; charset=US-ASCII

There was a request to prevent the Python 2-only builtin "file" from
being highlighted, and we discussed this in emacs-devel:

https://lists.gnu.org/archive/html/emacs-devel/2025-01/msg00839.html
https://lists.gnu.org/archive/html/emacs-devel/2025-02/msg00041.html

One idea was to introduce the customizable variable `python-2-support'
and it was implemented in commit
999d054dc1e265f1a39c10035a3a3f7f75de8445.  However, there was a
suggestion to create a mode for Python 2.

Attached is a patch to add `python2-mode' and `python2-ts-mode'.
Please give your opinion on introducing them.  I think the pros and
cons of this patch are as follows:

Pros:
- While `python-2-support' is a global setting, `python2-mode' and
  `python2-ts-mode' can be used simultaneously with `python-mode' and
  `python-ts-mode'.
- You can take advantage of the various means of mode selection
  offered by Emacs.
- While Python 3-only keywords/builtins are highlighted even if
  `python-2-support' is enabled, they are not highlighted in
  `python2-mode' and `python2-ts-mode'.
- Keywords/Builtins are organized so they can be easily customized in
  init.el.

Cons:
- There is a risk of bugs being introduced because of a certain amount
  of change.
- The separation of features is incomplete.  For example, Python
  3-only features such as f-strings and type annotations are
  supported even in `python2-mode' or `python2-ts-mode'.

In the process of making this patch, I noticed that the FFAP support
does not work in `python-ts-mode'.  This patch includes that fix.  If
we decide not to adopt this patch, I will propose only the FFAP
support fix in another patch.

--Multipart_Mon_Feb_17_07:31:31_2025-1
Content-Type: application/octet-stream; type=patch; name="0001-Add-python2-mode-and-python2-ts-mode.patch"
Content-Disposition: attachment; filename="0001-Add-python2-mode-and-python2-ts-mode.patch"
Content-Transfer-Encoding: 7bit

From 0125c1b3075f22dca0e0033394dd5bb20eee9283 Mon Sep 17 00:00:00 2001
From: kobarity <kobarity@HIDDEN>
Date: Sun, 16 Feb 2025 23:31:05 +0900
Subject: [PATCH] Add python2-mode and python2-ts-mode

To avoid highlighting Python 2-only builtins in 'python-mode'
and 'python-ts-mode', add 'python2-mode' and 'python2-ts-mode'
and separate the mode for Python 2 from the mode for Python 3.
Independent modes are more flexible than the customizable
variable 'python-2-support'.

* lisp/progmodes/python.el (interpreter-mode-alist): Add
python2-mode.
(python-2-support, python-font-lock-builtins)
(python-font-lock-builtin-exceptions): Removed.
(python2-font-lock-keywords-level-1)
(python-font-lock-keywords-common)
(python-font-lock-keywords-python3)
(python-font-lock-builtin-exceptions-common)
(python-font-lock-constants)
(python2-font-lock-keywords-level-2)
(python2-font-lock-keywords-maximum-decoration)
(python2-font-lock-keywords, python2--treesit-keywords)
(python2--treesit-builtins, python2--treesit-exceptions)
(python2--treesit-settings): New variables.
(python-font-lock-builtins-common): Renamed from
python-font-lock-builtins-python3.
(python--font-lock-keywords-level-1)
(python--font-lock-keywords, python--font-lock-builtins)
(python--font-lock-builtin-exceptions)
(python--font-lock-regex-symbols)
(python--font-lock-keywords-level-2)
(python--font-lock-keywords-maximum-decoration)
(python--treesit-keywords, python--treesit-builtins)
(python--treesit-exceptions, python--treesit-settings): New
functions.
(ffap-alist): Add Python related modes.
(python-base-mode): Add 'python2-mode' and 'python2-ts-mode' to
'hs-special-modes-alist'.
(python3-mode): New alias.
(python2-mode, python2-ts-mode): New modes.
* test/lisp/progmodes/python-tests.el
(python-tests-assert-faces): Add optional arg PYTHON2-FACES.
(python2-ts-tests-with-temp-buffer): New macro.
(python-font-lock-keywords-1)
(python-font-lock-builtins-1)
(python-font-lock-builtin-exceptions-1)
(python-font-lock-builtin-exceptions-2)
(python-ts-mode-keyword-face)
(python2-ts-mode-keyword-face)
(python-ts-mode-builtin-face)
(python2-ts-mode-builtin-face)
(python-ts-mode-exception-1)
(python2-ts-mode-exception-1)
(python-ts-mode-exception-2)
(python2-ts-mode-exception-2): New tests.
---
 etc/NEWS                            |  10 +-
 lisp/progmodes/python.el            | 339 +++++++++++++++++++---------
 test/lisp/progmodes/python-tests.el | 106 ++++++++-
 3 files changed, 336 insertions(+), 119 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 6d934b2029c..13a764928d4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1085,12 +1085,12 @@ customize these variables to "python3" if you want to use Python 3
 instead.
 
 ---
-*** Python 2 support is now optional and disabled by default.
+*** 'python2-mode' and 'python2-ts-mode' for Python 2 are added.
 Since Python 2 EOL was over 5 years ago, this release removes Python
-2-only builtins such as "file" from the default highlighting in
-'python-mode' and 'python-ts-mode'.  If you would like them highlighted,
-customize the new user option 'python-2-support' to a non-nil value and
-restart Emacs.
+2-only builtins such as "file" from the highlighting in 'python-mode'.
+To make Python 2-only builtins be highlighted, use 'python2-mode' or
+'python2-ts-mode'.  Python 3-only keywords/builtins will not be
+highlighted in these modes.
 
 ---
 *** Support of 'electric-layout-mode' added.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index a42e2b2a28a..a40feb71805 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -292,6 +292,8 @@ python--auto-mode-alist-regexp
 (add-to-list 'auto-mode-alist (cons python--auto-mode-alist-regexp 'python-mode))
 ;;;###autoload
 (add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-mode))
+;;;###autoload
+(add-to-list 'interpreter-mode-alist '("python2[0-9.]*" . python2-mode))
 
 (defgroup python nil
   "Python Language's flying circus support for Emacs."
@@ -316,16 +318,6 @@ python-interpreter-args
   :version "30.1"
   :type 'string)
 
-(defcustom python-2-support nil
-  "If non-nil, enable Python 2 support.
-Currently only affects highlighting.
-
-After customizing this variable, you must restart Emacs for it to take
-effect."
-  :version "31.1"
-  :type 'boolean
-  :safe 'booleanp)
-
 
 ;;; Bindings
 
@@ -689,21 +681,59 @@ python--string-bytes-literal-matcher
              until (or (not result) result-valid)
              finally return (and result-valid result))))
 
-(defvar python-font-lock-keywords-level-1
+(defun python--font-lock-keywords-level-1 (_version)
+  "Return the default `python-font-lock-keywords-level-1'.
+Argument VERSION is currently ignored."
   `((,(python-rx symbol-start "def" (1+ space) (group symbol-name))
      (1 font-lock-function-name-face))
     (,(python-rx symbol-start "class" (1+ space) (group symbol-name))
-     (1 font-lock-type-face)))
+     (1 font-lock-type-face))))
+
+(defvar python-font-lock-keywords-level-1
+  (python--font-lock-keywords-level-1 3)
   "Font lock keywords to use in `python-mode' for level 1 decoration.
 
 This is the minimum decoration level, including function and
 class declarations.")
 
+(defvar python2-font-lock-keywords-level-1
+  (python--font-lock-keywords-level-1 2)
+  "Font lock keywords to use in `python2-mode' for level 1 decoration.
+
+This is the minimum decoration level, including function and
+class declarations.")
+
+(defvar python-font-lock-keywords-common
+  '("and" "del" "from" "not" "while" "as" "elif" "global" "or" "with"
+    "assert" "else" "if" "pass" "yield" "break" "except" "import" "class"
+    "in" "raise" "continue" "finally" "is" "return" "def" "for" "lambda"
+    "try"
+    ;; Extra:
+    "self"))
+
+(defvar python-font-lock-keywords-python3
+  '(;; False, None, and True are listed as keywords on the Python 3
+    ;; documentation, but since they also qualify as constants they are
+    ;; 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"))
+    "await"
+    ;; Python 3.10+
+    "match" "case"))
+
+(defun python--font-lock-keywords (version)
+  "Return a list of keywords for the VERSION of Python."
+  (append python-font-lock-keywords-common
+          (when (= version 3)
+            python-font-lock-keywords-python3)))
+
 (defvar python-font-lock-builtin-types
   '("bool" "bytearray" "bytes" "complex" "dict" "float" "frozenset"
     "int" "list" "memoryview" "range" "set" "str" "tuple"))
 
-(defvar python-font-lock-builtins-python3
+(defvar python-font-lock-builtins-common
   '("abs" "aiter" "all" "anext" "any" "ascii" "bin" "breakpoint"
     "callable" "chr" "classmethod" "compile" "delattr" "dir" "divmod"
     "enumerate" "eval" "exec" "filter" "format" "getattr" "globals"
@@ -718,11 +748,6 @@ python-font-lock-builtins-python2
     "reload" "unichr" "unicode" "xrange" "apply" "buffer" "coerce"
     "intern"))
 
-(defvar python-font-lock-builtins
-  (append python-font-lock-builtins-python3
-          (when python-2-support
-            python-font-lock-builtins-python2)))
-
 (defvar python-font-lock-special-attributes
   '(;; https://docs.python.org/3/reference/datamodel.html
     "__annotations__" "__bases__" "__closure__" "__code__"
@@ -733,39 +758,91 @@ python-font-lock-special-attributes
     ;; Extras:
     "__all__"))
 
-(defvar python-font-lock-keywords-level-2
-  `(,@python-font-lock-keywords-level-1
-    ,(rx symbol-start
-         (or
-          "and" "del" "from" "not" "while" "as" "elif" "global" "or" "with"
-          "assert" "else" "if" "pass" "yield" "break" "except" "import" "class"
-          "in" "raise" "continue" "finally" "is" "return" "def" "for" "lambda"
-          "try"
-          ;; False, None, and True are listed as keywords on the Python 3
-          ;; documentation, but since they also qualify as constants they are
-          ;; 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"))
-          "await"
-          ;; Python 3.10+
-          "match" "case"
-          ;; Extra:
-          "self")
-         symbol-end)
+(defun python--font-lock-builtins (version)
+  "Return a list of builtins for the VERSION of Python."
+  (append python-font-lock-builtin-types
+          python-font-lock-builtins-common
+          (when (= version 2)
+            python-font-lock-builtins-python2)
+          python-font-lock-special-attributes))
+
+(defvar python-font-lock-builtin-exceptions-common
+  '("ArithmeticError" "AssertionError" "AttributeError" "BaseException"
+    "BufferError" "BytesWarning" "DeprecationWarning" "EOFError"
+    "EnvironmentError" "Exception" "FloatingPointError" "FutureWarning"
+    "GeneratorExit" "IOError" "ImportError" "ImportWarning"
+    "IndentationError" "IndexError" "KeyError" "KeyboardInterrupt"
+    "LookupError" "MemoryError" "NameError" "NotImplementedError"
+    "OSError" "OverflowError" "PendingDeprecationWarning"
+    "ReferenceError" "RuntimeError" "RuntimeWarning" "StopIteration"
+    "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError"
+    "TypeError" "UnboundLocalError" "UnicodeDecodeError"
+    "UnicodeEncodeError" "UnicodeError" "UnicodeTranslateError"
+    "UnicodeWarning" "UserWarning" "ValueError" "Warning"
+    "ZeroDivisionError"
+    ;; OS specific
+    "VMSError" "WindowsError"))
+
+(defvar python-font-lock-builtin-exceptions-python3
+  '("BlockingIOError" "BrokenPipeError" "ChildProcessError"
+    "ConnectionAbortedError" "ConnectionError" "ConnectionRefusedError"
+    "ConnectionResetError" "EncodingWarning" "FileExistsError"
+    "FileNotFoundError" "InterruptedError" "IsADirectoryError"
+    "NotADirectoryError" "ModuleNotFoundError" "PermissionError"
+    "ProcessLookupError" "PythonFinalizationError" "RecursionError"
+    "ResourceWarning" "StopAsyncIteration" "TimeoutError"
+    "BaseExceptionGroup" "ExceptionGroup"))
+
+(defvar python-font-lock-builtin-exceptions-python2
+  '("StandardError"))
+
+(defun python--font-lock-builtin-exceptions (version)
+  "Return a list of builtin exceptions for the VERSION of Python."
+  (append python-font-lock-builtin-exceptions-common
+          (when (= version 3)
+            python-font-lock-builtin-exceptions-python3)
+          (when (= version 2)
+            python-font-lock-builtin-exceptions-python2)))
+
+(defvar python-font-lock-constants
+  '("Ellipsis" "False" "None" "NotImplemented" "True" "__debug__"
+    ;; copyright, license, credits, quit and exit are added by the site
+    ;; module and they are not intended to be used in programs
+    "copyright" "credits" "exit" "license" "quit"))
+
+(defun python--font-lock-regex-symbols (symbols)
+  "Translate the list of SYMBOLS into a string regexp."
+  (rx-to-string `(seq symbol-start
+                      (or ,@symbols)
+                      symbol-end)))
+
+(defun python--font-lock-keywords-level-2 (version)
+  "Return the default `python-font-lock-keywords-level-2'.
+Adjusted based on Python VERSION."
+  `(,@(if (= version 2)
+          python2-font-lock-keywords-level-1
+        python-font-lock-keywords-level-1)
+    ,(python--font-lock-regex-symbols (python--font-lock-keywords version))
     ;; Builtins
-    (,(rx-to-string `(seq symbol-start
-                          (or ,@(append python-font-lock-builtin-types
-                                        python-font-lock-builtins
-                                        python-font-lock-special-attributes))
-                          symbol-end)) . font-lock-builtin-face))
+    (,(python--font-lock-regex-symbols (python--font-lock-builtins version))
+     . font-lock-builtin-face)))
+
+(defvar python-font-lock-keywords-level-2
+  (python--font-lock-keywords-level-2 3)
   "Font lock keywords to use in `python-mode' for level 2 decoration.
 
 This is the medium decoration level, including everything in
 `python-font-lock-keywords-level-1', as well as keywords and
 builtins.")
 
+(defvar python2-font-lock-keywords-level-2
+  (python--font-lock-keywords-level-2 2)
+  "Font lock keywords to use in `python2-mode' for level 2 decoration.
+
+This is the medium decoration level, including everything in
+`python-font-lock-keywords-level-1', as well as keywords and
+builtins.")
+
 (defun python-font-lock-assignment-matcher (regexp)
   "Font lock matcher for assignments based on REGEXP.
 Search for next occurrence if REGEXP matched within a `paren'
@@ -781,61 +858,24 @@ python-font-lock-assignment-matcher
                         (equal (char-after) ?=))
                return (progn (backward-char) t))))
 
-(defvar python-font-lock-builtin-exceptions-python3
-  '(;; Python 2 and 3:
-    "ArithmeticError" "AssertionError" "AttributeError" "BaseException"
-    "BufferError" "BytesWarning" "DeprecationWarning" "EOFError"
-    "EnvironmentError" "Exception" "FloatingPointError" "FutureWarning"
-    "GeneratorExit" "IOError" "ImportError" "ImportWarning"
-    "IndentationError" "IndexError" "KeyError" "KeyboardInterrupt"
-    "LookupError" "MemoryError" "NameError" "NotImplementedError"
-    "OSError" "OverflowError" "PendingDeprecationWarning"
-    "ReferenceError" "RuntimeError" "RuntimeWarning" "StopIteration"
-    "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError"
-    "TypeError" "UnboundLocalError" "UnicodeDecodeError"
-    "UnicodeEncodeError" "UnicodeError" "UnicodeTranslateError"
-    "UnicodeWarning" "UserWarning" "ValueError" "Warning"
-    "ZeroDivisionError"
-    ;; Python 3:
-    "BlockingIOError" "BrokenPipeError" "ChildProcessError"
-    "ConnectionAbortedError" "ConnectionError" "ConnectionRefusedError"
-    "ConnectionResetError" "EncodingWarning" "FileExistsError"
-    "FileNotFoundError" "InterruptedError" "IsADirectoryError"
-    "NotADirectoryError" "ModuleNotFoundError" "PermissionError"
-    "ProcessLookupError" "PythonFinalizationError" "RecursionError"
-    "ResourceWarning" "StopAsyncIteration" "TimeoutError"
-    "BaseExceptionGroup" "ExceptionGroup"
-    ;; OS specific
-    "VMSError" "WindowsError"))
-
-(defvar python-font-lock-builtin-exceptions-python2
-  '("StandardError"))
-
-(defvar python-font-lock-builtin-exceptions
-  (append python-font-lock-builtin-exceptions-python3
-          (when python-2-support
-            python-font-lock-builtin-exceptions-python2)))
-
-(defvar python-font-lock-keywords-maximum-decoration
+(defun python--font-lock-keywords-maximum-decoration (version)
+  "Return the default `python-font-lock-keywords-maximum-decoration'.
+Adjusted based on Python VERSION."
   `((python--font-lock-f-strings)
-    ,@python-font-lock-keywords-level-2
+    ,@(if (= version 2)
+          python2-font-lock-keywords-level-2
+        python-font-lock-keywords-level-2)
     ;; Constants
-    (,(rx symbol-start
-          (or
-           "Ellipsis" "False" "None" "NotImplemented" "True" "__debug__"
-           ;; copyright, license, credits, quit and exit are added by the site
-           ;; module and they are not intended to be used in programs
-           "copyright" "credits" "exit" "license" "quit")
-          symbol-end)
+    (,(python--font-lock-regex-symbols python-font-lock-constants)
      . font-lock-constant-face)
     ;; Decorators.
     (,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_))
                                             (0+ "." (1+ (or word ?_)))))
      (1 font-lock-type-face))
     ;; Builtin Exceptions
-    (,(rx-to-string `(seq symbol-start
-                          (or ,@python-font-lock-builtin-exceptions)
-                          symbol-end)) . font-lock-type-face)
+    (,(python--font-lock-regex-symbols
+       (python--font-lock-builtin-exceptions version))
+     . font-lock-type-face)
     ;; single assignment with/without type hints, e.g.
     ;;   a: int = 5
     ;;   b: Tuple[Optional[int], Union[Sequence[str], str]] = (None, 'foo')
@@ -916,13 +956,24 @@ python-font-lock-keywords-maximum-decoration
     (,(python--string-bytes-literal-matcher
        (python-rx string-escape-sequence)
        python--not-raw-string-literal-start-regexp)
-     (1 'font-lock-constant-face t)))
+     (1 'font-lock-constant-face t))))
+
+(defvar python-font-lock-keywords-maximum-decoration
+  (python--font-lock-keywords-maximum-decoration 3)
   "Font lock keywords to use in `python-mode' for maximum decoration.
 
 This decoration level includes everything in
 `python-font-lock-keywords-level-2', as well as constants,
 decorators, exceptions, and assignments.")
 
+(defvar python2-font-lock-keywords-maximum-decoration
+  (python--font-lock-keywords-maximum-decoration 2)
+  "Font lock keywords to use in `python2-mode' for maximum decoration.
+
+This decoration level includes everything in
+`python2-font-lock-keywords-level-2', as well as constants,
+decorators, exceptions, and assignments.")
+
 (defvar python-font-lock-keywords
   '(python-font-lock-keywords-level-1   ; When `font-lock-maximum-decoration' is nil.
     python-font-lock-keywords-level-1   ; When `font-lock-maximum-decoration' is 1.
@@ -936,6 +987,18 @@ python-font-lock-keywords
 Which one will be chosen depends on the value of
 `font-lock-maximum-decoration'.")
 
+(defvar python2-font-lock-keywords
+  '(python2-font-lock-keywords-level-1  ; When `font-lock-maximum-decoration' is nil.
+    python2-font-lock-keywords-level-1  ; When `font-lock-maximum-decoration' is 1.
+    python2-font-lock-keywords-level-2  ; When `font-lock-maximum-decoration' is 2.
+    python2-font-lock-keywords-maximum-decoration ; When `font-lock-maximum-decoration'
+                                                  ; is more than 1, or t (which it is,
+                                                  ; by default).
+    )
+  "List of font lock keyword specifications to use in `python2-mode'.
+
+Which one will be chosen depends on the value of
+`font-lock-maximum-decoration'.")
 
 (defconst python-syntax-propertize-function
   (syntax-propertize-rules
@@ -1033,15 +1096,24 @@ python-dotty-syntax-table
 ;; NOTE: Tree-sitter and font-lock works differently so this can't
 ;; merge with `python-font-lock-keywords-level-2'.
 
-(defvar python--treesit-keywords
-  '("as" "assert" "async" "await" "break" "case" "class" "continue" "def"
+(defvar python2--treesit-keywords
+  '("as" "assert" "break" "class" "continue" "def"
     "del" "elif" "else" "except" "exec" "finally" "for" "from"
-    "global" "if" "import" "lambda" "match" "nonlocal" "pass" "print"
+    "global" "if" "import" "lambda" "pass" "print"
     "raise" "return" "try" "while" "with" "yield"
     ;; These are technically operators, but we fontify them as
     ;; keywords.
     "and" "in" "is" "not" "or" "not in" "is not"))
 
+(defvar python--treesit-keywords
+  (append python2--treesit-keywords
+          '("async" "await" "case" "match" "nonlocal")))
+
+(defun python--treesit-keywords (version)
+  "Return a list of keywords for the VERSION of Python."
+  (if (= version 2) python2--treesit-keywords
+    python--treesit-keywords))
+
 (defvar python--treesit-builtin-types
   python-font-lock-builtin-types)
 
@@ -1052,11 +1124,18 @@ python--treesit-type-regex
                   eol)))
 
 (defvar python--treesit-builtins
-  python-font-lock-builtins)
+  (python--font-lock-builtins 3))
+
+(defvar python2--treesit-builtins
+  (python--font-lock-builtins 2))
+
+(defun python--treesit-builtins (version)
+  "Return a list of builtins for the VERSION of Python."
+  (if (= version 2) python2--treesit-builtins
+    python--treesit-builtins))
 
 (defvar python--treesit-constants
-  '("Ellipsis" "False" "None" "NotImplemented" "True" "__debug__"
-    "copyright" "credits" "exit" "license" "quit"))
+  python-font-lock-constants)
 
 (defvar python--treesit-operators
   '("-" "-=" "!=" "*" "**" "**=" "*=" "/" "//" "//=" "/=" "&" "&=" "%" "%="
@@ -1067,7 +1146,15 @@ python--treesit-special-attributes
   python-font-lock-special-attributes)
 
 (defvar python--treesit-exceptions
-  python-font-lock-builtin-exceptions)
+  (python--font-lock-builtin-exceptions 3))
+
+(defvar python2--treesit-exceptions
+  (python--font-lock-builtin-exceptions 2))
+
+(defun python--treesit-exceptions (version)
+  "Return a list of builtin exceptions for the VERSION of Python."
+  (if (= version 2) python2--treesit-exceptions
+    python--treesit-exceptions))
 
 (defun python--treesit-fontify-string (node override start end &rest _)
   "Fontify string.
@@ -1191,7 +1278,8 @@ python--treesit-fontify-dotted-decorator
       ("attribute"
        (python--treesit-fontify-dotted-decorator child override start end)))))
 
-(defvar python--treesit-settings
+(defun python--treesit-settings (version)
+  "Return the tree-sitter font-lock settings for the VERSION of Python."
   (treesit-font-lock-rules
    :feature 'comment
    :language 'python
@@ -1205,7 +1293,7 @@ python--treesit-settings
 
    :feature 'keyword
    :language 'python
-   `([,@python--treesit-keywords] @font-lock-keyword-face
+   `([,@(python--treesit-keywords version)] @font-lock-keyword-face
      ((identifier) @font-lock-keyword-face
       (:match "\\`self\\'" @font-lock-keyword-face)))
 
@@ -1223,7 +1311,7 @@ python--treesit-settings
    :language 'python
    `((call function: (identifier) @font-lock-builtin-face
            (:match ,(rx-to-string
-                     `(seq bol (or ,@python--treesit-builtins) eol))
+                     `(seq bol (or ,@(python--treesit-builtins version)) eol))
                    @font-lock-builtin-face))
      (attribute attribute: (identifier) @font-lock-builtin-face
                 (:match ,(rx-to-string
@@ -1278,7 +1366,7 @@ python--treesit-settings
    :override t
    `(((identifier) @font-lock-type-face
       (:match ,(rx-to-string
-                `(seq bol (or ,@python--treesit-exceptions)
+                `(seq bol (or ,@(python--treesit-exceptions version))
                   eol))
               @font-lock-type-face))
      (type [(identifier) (none)] @font-lock-type-face)
@@ -1355,8 +1443,15 @@ python--treesit-settings
 
    :feature 'variable
    :language 'python
-   '((identifier) @python--treesit-fontify-variable))
-  "Tree-sitter font-lock settings.")
+   '((identifier) @python--treesit-fontify-variable)))
+
+(defvar python--treesit-settings
+  (python--treesit-settings 3)
+  "Tree-sitter font-lock settings for `python-ts-mode'.")
+
+(defvar python2--treesit-settings
+  (python--treesit-settings 2)
+  "Tree-sitter font-lock settings for `python2-ts-mode'.")
 
 (defun python--treesit-variable-p (node)
   "Check whether NODE is a variable.
@@ -5539,9 +5634,9 @@ python-ffap-module-path
 (defvar ffap-alist)
 
 (eval-after-load "ffap"
-  '(progn
-     (push '(python-mode . python-ffap-module-path) ffap-alist)
-     (push '(inferior-python-mode . python-ffap-module-path) ffap-alist)))
+  '(dolist (mode '(python-mode python2-mode python-ts-mode python2-ts-mode
+                               inferior-python-mode))
+     (add-to-list 'ffap-alist `(,mode . python-ffap-module-path))))
 
 
 ;;; Code check
@@ -7120,7 +7215,7 @@ python-base-mode
                       #'python-eldoc-function))))
 
   ;; TODO: Use tree-sitter to figure out the block in `python-ts-mode'.
-  (dolist (mode '(python-mode python-ts-mode))
+  (dolist (mode '(python-mode python2-mode python-ts-mode python2-ts-mode))
     (add-to-list
      'hs-special-modes-alist
      `(,mode
@@ -7179,6 +7274,20 @@ python-mode
   (when python-indent-guess-indent-offset
     (python-indent-guess-indent-offset)))
 
+;;;###autoload
+(defalias 'python3-mode #'python-mode)
+
+;;;###autoload
+(define-derived-mode python2-mode python-mode "Python2"
+  "Major mode for editing Python 2 files.
+
+\\{python-mode-map}"
+  (setq-local font-lock-defaults
+              `(,python2-font-lock-keywords
+                nil nil nil nil
+                (font-lock-syntactic-face-function
+                 . python-font-lock-syntactic-face-function))))
+
 ;;;###autoload
 (define-derived-mode python-ts-mode python-base-mode "Python"
   "Major mode for editing Python files, using tree-sitter library.
@@ -7228,6 +7337,18 @@ python-ts-mode
 
 (derived-mode-add-parents 'python-ts-mode '(python-mode))
 
+;;;###autoload
+(define-derived-mode python2-ts-mode python-ts-mode "Python2"
+  "Major mode for editing Python 2 files, using tree-sitter library.
+
+\\{python-ts-mode-map}"
+  (when (treesit-ready-p 'python)
+    (setq-local treesit-font-lock-settings python2--treesit-settings)
+    (treesit-major-mode-setup)
+    (add-to-list 'interpreter-mode-alist '("python2[0-9.]*" . python2-ts-mode))))
+
+(derived-mode-add-parents 'python2-ts-mode '(python2-mode))
+
 ;;; Completion predicates for M-x
 ;; Commands that only make sense when editing Python code.
 (dolist (sym '(python-add-import
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 898e2b036e0..fffb5f70743 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -130,11 +130,18 @@ python-tests-look-at
         found-point
       (and restore-point (goto-char starting-point)))))
 
-(defun python-tests-assert-faces (content faces)
-  "Assert that font faces for CONTENT are equal to FACES."
-  (python-tests-with-temp-buffer content
-    (font-lock-ensure nil nil)
-    (should (equal faces (python-tests-get-buffer-faces)))))
+(defun python-tests-assert-faces (content faces &optional python2-faces)
+  "Assert that font faces for CONTENT are equal to FACES.
+If PYTHON2-FACES is specified, test it with `python2-mode'."
+  (python-tests-with-temp-buffer
+   content
+   (when faces
+     (font-lock-ensure nil nil)
+     (should (equal faces (python-tests-get-buffer-faces))))
+   (when python2-faces
+     (python2-mode)
+     (font-lock-ensure nil nil)
+     (should (equal python2-faces (python-tests-get-buffer-faces))))))
 
 (defun python-tests-get-buffer-faces ()
   "Return a list of (position . face) for each face change positions."
@@ -290,6 +297,36 @@ python-font-lock-keywords-level-1-2
    "def 1func():"
    '((1 . font-lock-keyword-face) (4))))
 
+(ert-deftest python-font-lock-keywords-1 ()
+  (python-tests-assert-faces
+   "async def func():"
+   '((1 . font-lock-keyword-face) (10)
+     (11 . font-lock-function-name-face) (15))
+   '((1) (7 . font-lock-keyword-face) (10)
+     (11 . font-lock-function-name-face) (15))))
+
+(ert-deftest python-font-lock-builtins-1 ()
+  (python-tests-assert-faces
+   "file('test')"
+   '((1)
+     (6 . font-lock-string-face) (12))
+   '((1 . font-lock-builtin-face) (5)
+     (6 . font-lock-string-face) (12))))
+
+(ert-deftest python-font-lock-builtin-exceptions-1 ()
+  (python-tests-assert-faces
+   "raise StandardError()"
+   '((1 . font-lock-keyword-face) (6))
+   '((1 . font-lock-keyword-face) (6)
+     (7 . font-lock-type-face) (20))))
+
+(ert-deftest python-font-lock-builtin-exceptions-2 ()
+  (python-tests-assert-faces
+   "raise FileNotFoundError()"
+   '((1 . font-lock-keyword-face) (6)
+     (7 . font-lock-type-face) (24))
+   '((1 . font-lock-keyword-face) (6))))
+
 (ert-deftest python-font-lock-assignment-statement-1 ()
   (python-tests-assert-faces
    "a, b, c = 1, 2, 3"
@@ -7692,6 +7729,31 @@ python-ts-tests-with-temp-buffer
        (goto-char (point-min))
        ,@body)))
 
+(defmacro python2-ts-tests-with-temp-buffer (contents &rest body)
+  "Create a `python2-ts-mode' enabled temp buffer with CONTENTS.
+BODY is code to be executed within the temp buffer.  Point is
+always located at the beginning of buffer."
+  (declare (indent 1) (debug t))
+  `(python-ts-tests-with-temp-buffer
+    ,contents
+    (python2-ts-mode)
+    (font-lock-ensure)
+    ,@body))
+
+(ert-deftest python-ts-mode-keyword-face ()
+  (python-ts-tests-with-temp-buffer
+   "async def func():"
+   (should (eq (face-at-point) 'font-lock-keyword-face))
+   (forward-to-word 1)
+   (should (eq (face-at-point) 'font-lock-keyword-face))))
+
+(ert-deftest python2-ts-mode-keyword-face ()
+  (python2-ts-tests-with-temp-buffer
+   "async def func():"
+   (should-not (face-at-point))
+   (forward-to-word 1)
+   (should (eq (face-at-point) 'font-lock-keyword-face))))
+
 (ert-deftest python-ts-mode-compound-keywords-face ()
   (dolist (test '("is not" "not in"))
     (python-ts-tests-with-temp-buffer
@@ -7701,6 +7763,40 @@ python-ts-mode-compound-keywords-face
      (forward-to-word 1)
      (should (eq (face-at-point) 'font-lock-keyword-face)))))
 
+(ert-deftest python-ts-mode-builtin-face ()
+  (python-ts-tests-with-temp-buffer
+   "file('test')"
+   (should-not (face-at-point))))
+
+(ert-deftest python2-ts-mode-builtin-face ()
+  (python2-ts-tests-with-temp-buffer
+   "file('test')"
+   (should (eq (face-at-point) 'font-lock-builtin-face))))
+
+(ert-deftest python-ts-mode-exception-1 ()
+  (python-ts-tests-with-temp-buffer
+   "raise StandardError()"
+   (forward-to-word 1)
+   (should-not (face-at-point))))
+
+(ert-deftest python2-ts-mode-exception-1 ()
+  (python2-ts-tests-with-temp-buffer
+   "raise StandardError()"
+   (forward-to-word 1)
+   (should (eq (face-at-point) 'font-lock-type-face))))
+
+(ert-deftest python-ts-mode-exception-2 ()
+  (python-ts-tests-with-temp-buffer
+   "raise FileNotFoundError()"
+   (forward-to-word 1)
+   (should (eq (face-at-point) 'font-lock-type-face))))
+
+(ert-deftest python2-ts-mode-exception-2 ()
+  (python2-ts-tests-with-temp-buffer
+   "raise FileNotFoundError()"
+   (forward-to-word 1)
+   (should-not (face-at-point))))
+
 (ert-deftest python-ts-mode-named-assignment-face-1 ()
   (python-ts-tests-with-temp-buffer
    "var := 3"
-- 
2.43.0


--Multipart_Mon_Feb_17_07:31:31_2025-1--




Acknowledgement sent to kobarity <kobarity@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#76353; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 19 Feb 2025 02:15:03 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.