GNU bug report logs -
#43298
27.1; Do font locking for Python 3, not 2
Previous Next
Reported by: Per Starbäck <starback <at> cl.lingfil.uu.se>
Date: Wed, 9 Sep 2020 21:09:01 UTC
Severity: normal
Found in version 27.1
Fixed in version 29.1
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43298 in the body.
You can then email your comments to 43298 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#43298
; Package
emacs
.
(Wed, 09 Sep 2020 21:09:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Per Starbäck <starback <at> cl.lingfil.uu.se>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 09 Sep 2020 21:09:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#43298
; Package
emacs
.
(Thu, 10 Sep 2020 17:24:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
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…
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#43298
; Package
emacs
.
(Mon, 11 Oct 2021 13:26:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 43298 <at> debbugs.gnu.org (full text, mbox):
close 43298 29.1
thanks
Per Starbäck <starback <at> cl.lingfil.uu.se> 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 built-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 this
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.
bug marked as fixed in version 29.1, send any further explanations to
43298 <at> debbugs.gnu.org and Per Starbäck <starback <at> cl.lingfil.uu.se>
Request was from
Stefan Kangas <stefan <at> marxist.se>
to
control <at> debbugs.gnu.org
.
(Mon, 11 Oct 2021 13:26:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 09 Nov 2021 12:24:10 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 168 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.