Subject: bug#76353: [PATCH] Add python2-mode and python2-ts-mode

From: kobarity <[email-masked]>
Date: Mon, 17 Feb 2025 07:31:31 +0900

There was a request to prevent the Python 2-only builtin "file" from
being highlighted, and we discussed this in emacs-devel:

https://lists.gnu.org/archive/html/emacs-devel/2025-01/msg00839.html
https://lists.gnu.org/archive/html/emacs-devel/2025-02/msg00041.html

One idea was to introduce the customizable variable `python-2-support'
and it was implemented in commit
999d054dc1e265f1a39c10035a3a3f7f75de8445.  However, there was a
suggestion to create a mode for Python 2.

Attached is a patch to add `python2-mode' and `python2-ts-mode'.
Please give your opinion on introducing them.  I think the pros and
cons of this patch are as follows:

Pros:
- While `python-2-support' is a global setting, `python2-mode' and
  `python2-ts-mode' can be used simultaneously with `python-mode' and
  `python-ts-mode'.
- You can take advantage of the various means of mode selection
  offered by Emacs.
- While Python 3-only keywords/builtins are highlighted even if
  `python-2-support' is enabled, they are not highlighted in
  `python2-mode' and `python2-ts-mode'.
- Keywords/Builtins are organized so they can be easily customized in
  init.el.

Cons:
- There is a risk of bugs being introduced because of a certain amount
  of change.
- The separation of features is incomplete.  For example, Python
  3-only features such as f-strings and type annotations are
  supported even in `python2-mode' or `python2-ts-mode'.

In the process of making this patch, I noticed that the FFAP support
does not work in `python-ts-mode'.  This patch includes that fix.  If
we decide not to adopt this patch, I will propose only the FFAP
support fix in another patch.