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: Ship Mints
Subject: Re: [RFE] python-mode: removing `file` keyword from syntax highlight
Date: Sat, 25 Jan 2025 06:23:18 -0500

To me, it's not worth the trouble to have two modes, or extra configuration settings, or complex dynamic detectors just to deprecate a couple of now non-keywords.

I'd rather have "file" no longer be a keyword than incorrectly display it as a keyword in now more popular python3 code.

-Stephane

On Sat, Jan 25, 2025 at 6:11 AM Kévin Le Gouguec <kevin.legouguec@gmail.com> wrote:
Konstantin Kharlamov <Hi-Angel@yandex.ru> writes:

>> 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?

An idea that I've never acted on:

* a defcustom (python-dialect?) to pick between 2, 3, 'guess,

* python-mode initialization would amend font-lock-defaults depending on
  that option (not unlike e.g. sh-builtins which maps shells to literals
  to sh-font-lock-keywords, which eventually finds its way to
  font-lock-defaults)

* 'guess could, as you say, peek at the shebang to hopefully do TRT,

* (maybe an additional value ('six?) to ask for "maximum coverage", for
  codebases that purport to still support 2 & 3?)

* users could explicitly set that variable per-project via
  .dir-locals.el.


reply via email to

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