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: Konstantin Kharlamov
Subject: Re: [RFE] python-mode: removing `file` keyword from syntax highlight
Date: Fri, 24 Jan 2025 20:28:15 +0300
User-agent: Evolution 3.54.3

On Sat, 2025-01-25 at 01:03 +0900, kobarity wrote:
> 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.

I see. Okay, what do you think then about adding to the mode
initialization a check that would check if the first line of the buffer
has word `python2`, and would otherwise assume it is python3 and turn
off the python2 keywords highlight?



reply via email to

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