Crandel / tempel-collection

Collection tempel templates
GNU General Public License v3.0
76 stars 27 forks source link

Enable aliases for (treesitter) modes #22

Closed benjaminor closed 1 year ago

benjaminor commented 1 year ago

This PR is related to #14 and #20 and fixes both of them.

The background is the kind of messy handling of treesitter/non-treesitter modes in Emacs core: Some modes do not have a treesitter mode, some only have a treesitter mode and there is only sometimes a base mode from which both the treesitter and the non-treesitter mode inherit.

We want to have a set of lazy-loaded templates for both the regular mode and, if it exists, the counterpart treesitter mode. As symlinking does not work for aliasing template files, this PR instead implements aliases in temple-collection.el with a tempel-collection--aliases variable, mapping modes to the associated template file name. If a template file with the name of the mode cannot be found, the code tries to fallback on the template file for the mode alias, if it exists.

Where possible, we do not alias treesitter modes which have a common base mode with their non-treesitter counterpart: python-base-mode, html-mode, ruby-base-mode, sh-base-mode.