From unknown Wed Sep 10 11:21:07 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#43298 <43298@debbugs.gnu.org> To: bug#43298 <43298@debbugs.gnu.org> Subject: Status: 27.1; Do font locking for Python 3, not 2 Reply-To: bug#43298 <43298@debbugs.gnu.org> Date: Wed, 10 Sep 2025 18:21:07 +0000 retitle 43298 27.1; Do font locking for Python 3, not 2 reassign 43298 emacs submitter 43298 Per Starb=C3=A4ck severity 43298 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 17:08:47 2020 Received: (at submit) by debbugs.gnu.org; 9 Sep 2020 21:08:47 +0000 Received: from localhost ([127.0.0.1]:34935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG7Kg-0008Tl-Mn for submit@debbugs.gnu.org; Wed, 09 Sep 2020 17:08:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:34964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG4xH-0004ft-2Y for submit@debbugs.gnu.org; Wed, 09 Sep 2020 14:36:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG4xG-0003cg-Rv for bug-gnu-emacs@gnu.org; Wed, 09 Sep 2020 14:36:26 -0400 Received: from dl.lingfil.uu.se ([130.238.78.148]:43372 helo=numerus.lingfil.uu.se) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG4xE-0006dt-9J for bug-gnu-emacs@gnu.org; Wed, 09 Sep 2020 14:36:26 -0400 Received: from localhost (localhost [127.0.0.1]) by numerus.lingfil.uu.se (Postfix) with ESMTP id D124EA1E6002; Wed, 9 Sep 2020 20:36:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at lingfil.uu.se X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-9999 required=6.2 tests=[ALL_TRUSTED=-1, MISSING_FROM=1] autolearn=no autolearn_force=no Received: from numerus.lingfil.uu.se ([127.0.0.1]) by localhost (numerus.lingfil.uu.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aac0hZK0VDvA; Wed, 9 Sep 2020 20:36:17 +0200 (CEST) Received: from numerus.lingfil.uu.se (localhost [127.0.0.1]) by numerus.lingfil.uu.se (Postfix) with ESMTP id A317DA1E6001; Wed, 9 Sep 2020 20:36:17 +0200 (CEST) Received: (from starback@localhost) by numerus.lingfil.uu.se (8.14.7/8.14.7/Submit) id 089IaHU1014462; Wed, 9 Sep 2020 20:36:17 +0200 From: =?iso-8859-1?Q?Per_Starb=E4ck?= To: bug-gnu-emacs@gnu.org Subject: 27.1; Do font locking for Python 3, not 2 Date: Wed, 09 Sep 2020 20:36:17 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: none client-ip=130.238.78.148; envelope-from=starback@stp.lingfil.uu.se; helo=numerus.lingfil.uu.se X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:36:19 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 09 Sep 2020 17:08:45 -0400 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: -3.3 (---) In GNU Emacs 27.1: $ emacs -Q -f /tmp/new.py for RET print RET len RET "print" gets the same colour as "for", that is as a keyword. I think it should get the same as "len", that is as a builtin function. Python.el has a section ;; Python 2: "print" "exec" because in Python 2 these two were keywords. But in Python 3 they are built-in functions. I think it's overkill to try to determine if the buffer contains Python 2 or 3 and highlight them differently. Using the same fontlocking is good enough, since it's not a big problem to get these in the wrong colour. But now when Python 2 is officially discontinued I think it's time to let it follow Python 3 and get the small inconvenience when editing old code and not when editing current code. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 10 13:23:38 2020 Received: (at submit) by debbugs.gnu.org; 10 Sep 2020 17:23:38 +0000 Received: from localhost ([127.0.0.1]:41103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGQIM-00036O-8O for submit@debbugs.gnu.org; Thu, 10 Sep 2020 13:23:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:44970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGQIK-00036G-Hu for submit@debbugs.gnu.org; Thu, 10 Sep 2020 13:23:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGQIK-0004hv-CD for bug-gnu-emacs@gnu.org; Thu, 10 Sep 2020 13:23:36 -0400 Received: from static.214.254.202.116.clients.your-server.de ([116.202.254.214]:46942 helo=ciao.gmane.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGQII-0000Oj-Jr for bug-gnu-emacs@gnu.org; Thu, 10 Sep 2020 13:23:36 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kGQIE-0007b6-Lk for bug-gnu-emacs@gnu.org; Thu, 10 Sep 2020 19:23:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= Subject: Re: bug#43298: 27.1; Do font locking for Python 3, not 2 Date: Thu, 10 Sep 2020 19:23:18 +0200 Message-ID: <87v9gl1r7d.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:UvMq67NqZsXLjOmM/ZvJ0T2ioHg= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geb-bug-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 13:23:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: submit 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.9 (/) This is one of my long-standing pet peeves, thanks for filing an issue about it. FWIW here is how I thought I'd go about fixing this Whenever I'd Find The Time™ (… needless to say, if anyone wants to beat me to it, there'll be no hard feelings): 1. Add fontification tests for the current fontification. (Because I expected the overall patch to be quite big, and I figured it'd be easier to get it merged if it came with a bunch of non-regression tests.) 2. Create 3 sets of font-lock settings in python.el: -2, -3, and -undecided (= whatever the current settings do). 3. Add a variable to control which settings to use (settable through Customize or through file/directory-local variables). 4. Add heuristics to pick the "right" style by default (e.g. look for a shebang). On the one hand, I agree that Emacs should be py3k-compliant by now out-of-the-box. On the other hand, I'd bet there are a lot of poor souls out there who will be stuck maintaining Python 2 code for a few more years. Messing with font-lock without giving them an escape hatch sounds like some form of double-jeopardy… From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 11 09:25:35 2021 Received: (at 43298) by debbugs.gnu.org; 11 Oct 2021 13:25:35 +0000 Received: from localhost ([127.0.0.1]:57097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZvJ8-000445-VI for submit@debbugs.gnu.org; Mon, 11 Oct 2021 09:25:35 -0400 Received: from mail-pj1-f41.google.com ([209.85.216.41]:53245) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZvJ6-00043Y-Fg for 43298@debbugs.gnu.org; Mon, 11 Oct 2021 09:25:33 -0400 Received: by mail-pj1-f41.google.com with SMTP id oa4so12568724pjb.2 for <43298@debbugs.gnu.org>; Mon, 11 Oct 2021 06:25:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc :content-transfer-encoding; bh=x2W/S9zyqBhgPzMIEqZzEjblRakozAgel0LjtOfimMM=; b=6N9sMAjvLBmeWmU1zVJUHPs/WkRh0g/FY7DmMDB5pRsha5QyeHO4NyiBJuPO/FI6EB npSDmuMsALDy+01wdTH2RpNkoEZRebdBdcystQt0lYs5hVyMDD48MqwdX5z1znghYpIt VZZD01vb0SK4WeurKPkG19Bzy5wueeEcn5iTO7+rXVa5IaI+GF7PdTSeJtrzfc52PCMf pCtnPz79aIn1hpggurHrc2Dgxz3siorugfOkCvohxXlZatvHdooMioXVnEWzMtsM6xYS 1AOr7m3rUTKyMi9LnV74HjhzyAsGHRgyMa4BxQJpY7y32/hhTVMzuHBRyMOuGkdXyn8+ aucQ== X-Gm-Message-State: AOAM533j674sHz+/9khJA54JNuDYp7W5PoqUdc5eXZwIFkpx3qmCcxtm 6JR2SU42B+U+5RNO/Xuz6L7ikIpWmjtHlNtfbDo= X-Google-Smtp-Source: ABdhPJwSjot4chkB8Uj6JF3pl9kGuu1BBd82Z4TzDfUxvufnhDFH5l0bBlquBxpHo2BigGZ9GUPMSxUN1oZ9gBt2Kzg= X-Received: by 2002:a17:90a:c70d:: with SMTP id o13mr12625891pjt.143.1633958726902; Mon, 11 Oct 2021 06:25:26 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 11 Oct 2021 06:25:26 -0700 From: Stefan Kangas In-Reply-To: =?UTF-8?B?PHNhNXdvMTJvbDBlLmZzZkBudW1lcnVzLmxpbmdmaWwudXUuc2U+ICgiUGVyIFN0?= =?UTF-8?B?YXJiw6RjayIncyBtZXNzYWdlIG9mICJXZWQsIDA5IFNlcCAyMDIwIDIwOjM2OjE3ICswMjAwIik=?= References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) MIME-Version: 1.0 Date: Mon, 11 Oct 2021 06:25:26 -0700 Message-ID: Subject: Re: bug#43298: 27.1; Do font locking for Python 3, not 2 To: =?UTF-8?Q?Per_Starb=C3=A4ck?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 43298 Cc: 43298@debbugs.gnu.org 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.5 (/) close 43298 29.1 thanks Per Starb=C3=A4ck writes: > In GNU Emacs 27.1: > > $ emacs -Q -f /tmp/new.py > for RET print RET len RET > > "print" gets the same colour as "for", that is as a keyword. > I think it should get the same as "len", that is as a builtin > function. > > Python.el has a section > > ;; Python 2: > "print" "exec" > > because in Python 2 these two were keywords. But in Python 3 they are bui= lt-in > functions. Thanks for the bug report! Your reasoning makes sense to me, so I have now fixed this on master (commit 9f9c9f934a). This change will be in Emacs 29. Feel free to verify that this fix works for you, but for now I'm closing th= is bug report. If you see anything that is wrong, please reply to this email (use "Reply to all" in your email client) and we can reopen the bug report. > I think it's overkill to try to determine if the buffer contains Python 2= or 3 > and highlight them differently. Using the same fontlocking is good enough= , > since it's not a big problem to get these in the wrong colour. > But now when Python 2 is officially discontinued I think it's time to > let it follow Python 3 and get the small inconvenience when editing old > code and not when editing current code. Agreed. From unknown Wed Sep 10 11:21:07 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 09 Nov 2021 12:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator