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