emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFE] python-mode: removing `file` keyword from syntax highlight


From: kobarity
Subject: Re: [RFE] python-mode: removing `file` keyword from syntax highlight
Date: Sat, 25 Jan 2025 01:03:14 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/31.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Konstantin Kharlamov wrote:
> 
> On Wed, 2025-01-22 at 15:57 +0300, Konstantin Kharlamov wrote:
> > Seems to be a simple change, but knowing sometimes such things raise
> > discussions, decided to ask here first.
> > 
> > While working with Python I frequently notice word `file` highlighted
> > as a keyword, even though I never remember using such library
> > function
> > or a keyword.
> > 
> > Some digging showed that `file` was a built-in type in Python2 that's
> > gone in Python3 in preference of `open()` function which returns type
> > `IO[Any]`.
> > 
> > Nowadays word `file` is just a typical variable name you can see
> > while
> > working with open (pun intended), case in point¹. Seeing it's
> > highlighted as if it's any special is annoying. Given that Python2
> > has
> > been dead for ½ a decade at this point, can we perhaps remove `file`
> > from the list of keywords?
> > 
> > 1: https://stackoverflow.com/a/8369345/2388257
> 
> CC: kobarity

python-mode highlights both Python 2 and Python 3 keywords:

           ;; Python 2:
           "basestring" "cmp" "execfile" "file" "long" "raw_input" "reduce"
           "reload" "unichr" "unicode" "xrange" "apply" "buffer" "coerce"
           "intern"
           ;; Python 3:
           "aiter" "anext" "ascii" "breakpoint" "bytearray" "bytes" "exec"

I think this is a compromise based on the idea that it is better to
have a few extra words highlighted than to have keywords that are not
highlighted.  As I wrote in #70815, I personally do not want to drop
supporting Python 2 yet.

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70815

I am also one of those in a position where I still need to support
Python 2 code.

However, I know that Python 2 has already been EOL for a long time and
that very few people still use it.  Furthermore, even if some
keywords are not highlighted, it does not mean that we cannot edit
Python 2 code.  So I am not strongly against removing the Python 2
keywords if many people want to.

One workaround to prevent Python 2 keywords from being highlighted
would be to use python-ts-mode.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]