Subject: Re: bug#75526: python.el uses treesit-declare-unavailable-functions despite requiring emacs >v24.4

From: Stefan Monnier <[email-masked]>
Date: Sun, 02 Mar 2025 11:51:15 -0500

>> 4. More complicated to resolve perhaps are these symbols from Emacs 29.1:
>>
>>     29.1 treesit [require]
>>     29.1 treesit-buffer-root-node
>>     29.1 treesit-defun-name
>>     29.1 treesit-filter-child
>>     29.1 treesit-font-lock-rules
>>     29.1 treesit-fontify-with-override
>>     29.1 treesit-induce-sparse-tree
>>     29.1 treesit-major-mode-setup
>>     29.1 treesit-node-at
>>     29.1 treesit-node-child-by-field-name
>>     29.1 treesit-node-children
>>     29.1 treesit-node-end
>>     29.1 treesit-node-field-name
>>     29.1 treesit-node-parent
>>     29.1 treesit-node-prev-sibling
>>     29.1 treesit-node-start
>>     29.1 treesit-node-text
>>     29.1 treesit-node-type
>>     29.1 treesit-parser-create
>>     29.1 treesit-ready-p
>>
>>    Yuan, Philip, Daniel, any ideas for how to handle this compatibility
>>    issue?
>
> I still haven't familiarised myself with the treesit API, and I don't
> know if there is a reasonable way to translate these into fontlock...

We definitely don't want to translate those into fontlock.
AFAIK, there are just two ways to solve this:

- Bump package-requires to Emacs-29.
- Use (require 'treesit nil t) and than sprinkle enough `fboundp` tests
  around treesitter code to allow loading `python.el` into Emacs<29.
  It's perfectly OK if `python-ts-mode` doesn't work in Emacs<29.

Bumping package-requires to 29 might not be a bad idea since noone
complained (until now) in the 2½ years since we added (require 'treesit)
to the code.

        Stefan