diff options
author | Yuan Fu <casouri@gmail.com> | 2023-04-23 23:55:22 -0700 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2023-04-24 10:38:40 -0700 |
commit | 8f71c1546dfc70ae7e646834c8d8baf23d4b4d90 (patch) | |
tree | 8ff80a536f13a40d8522731ca8ad6b0614072d52 /src | |
parent | 99add09d5e16a4fef752abedc3ee96989f1b9ae2 (diff) | |
download | emacs-8f71c1546dfc70ae7e646834c8d8baf23d4b4d90.tar.gz |
Accept versioned tree-sitter language grammar files
By discussion on emacs-devel, titled "Versioned Tree-sitter parser
libraries".
* src/treesit.c (Vtreesit_str_dot_0): New variable.
(treesit_load_language_push_for_each_suffix): Additionally look for
lib_base_name.0 and lib_base_name.0.0.
(syms_of_treesit): Initialize Vtreesit_str_dot_0.
Diffstat (limited to 'src')
-rw-r--r-- | src/treesit.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/treesit.c b/src/treesit.c index 53dbeb68882..2d0df10ec44 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -404,6 +404,7 @@ init_treesit_functions (void) static Lisp_Object Vtreesit_str_libtree_sitter; static Lisp_Object Vtreesit_str_tree_sitter; +static Lisp_Object Vtreesit_str_dot_0; static Lisp_Object Vtreesit_str_dot; static Lisp_Object Vtreesit_str_question_mark; static Lisp_Object Vtreesit_str_star; @@ -529,8 +530,19 @@ treesit_load_language_push_for_each_suffix (Lisp_Object lib_base_name, suffixes = Vdynamic_library_suffixes; FOR_EACH_TAIL (suffixes) - *path_candidates = Fcons (concat2 (lib_base_name, XCAR (suffixes)), - *path_candidates); + { + Lisp_Object candidate1 = concat2 (lib_base_name, XCAR (suffixes)); + /* Support libraries named with ABI version numbers. In the + foreseeable future we only need to support version 0.0. See + the thread titled "Versioned Tree-sitter parser libraries" on + emacs-devel. */ + Lisp_Object candidate2 = concat2 (candidate1, Vtreesit_str_dot_0); + Lisp_Object candidate3 = concat2 (candidate2, Vtreesit_str_dot_0); + + *path_candidates = Fcons (candidate3, *path_candidates); + *path_candidates = Fcons (candidate2, *path_candidates); + *path_candidates = Fcons (candidate1, *path_candidates); + } } /* Load the dynamic library of LANGUAGE_SYMBOL and return the pointer @@ -3583,6 +3595,8 @@ then in the system default locations for dynamic libraries, in that order. */); Vtreesit_str_libtree_sitter = build_pure_c_string ("libtree-sitter-"); staticpro (&Vtreesit_str_tree_sitter); Vtreesit_str_tree_sitter = build_pure_c_string ("tree-sitter-"); + staticpro (&Vtreesit_str_dot_0); + Vtreesit_str_dot_0 = build_pure_c_string (".0"); staticpro (&Vtreesit_str_dot); Vtreesit_str_dot = build_pure_c_string ("."); staticpro (&Vtreesit_str_question_mark); |