diff options
| author | Yuan Fu | 2023-04-23 23:55:22 -0700 |
|---|---|---|
| committer | Yuan Fu | 2023-04-24 10:38:40 -0700 |
| commit | 8f71c1546dfc70ae7e646834c8d8baf23d4b4d90 (patch) | |
| tree | 8ff80a536f13a40d8522731ca8ad6b0614072d52 /src | |
| parent | 99add09d5e16a4fef752abedc3ee96989f1b9ae2 (diff) | |
| download | emacs-8f71c1546dfc70ae7e646834c8d8baf23d4b4d90.tar.gz emacs-8f71c1546dfc70ae7e646834c8d8baf23d4b4d90.zip | |
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) | |||
| 404 | 404 | ||
| 405 | static Lisp_Object Vtreesit_str_libtree_sitter; | 405 | static Lisp_Object Vtreesit_str_libtree_sitter; |
| 406 | static Lisp_Object Vtreesit_str_tree_sitter; | 406 | static Lisp_Object Vtreesit_str_tree_sitter; |
| 407 | static Lisp_Object Vtreesit_str_dot_0; | ||
| 407 | static Lisp_Object Vtreesit_str_dot; | 408 | static Lisp_Object Vtreesit_str_dot; |
| 408 | static Lisp_Object Vtreesit_str_question_mark; | 409 | static Lisp_Object Vtreesit_str_question_mark; |
| 409 | static Lisp_Object Vtreesit_str_star; | 410 | static Lisp_Object Vtreesit_str_star; |
| @@ -529,8 +530,19 @@ treesit_load_language_push_for_each_suffix (Lisp_Object lib_base_name, | |||
| 529 | suffixes = Vdynamic_library_suffixes; | 530 | suffixes = Vdynamic_library_suffixes; |
| 530 | 531 | ||
| 531 | FOR_EACH_TAIL (suffixes) | 532 | FOR_EACH_TAIL (suffixes) |
| 532 | *path_candidates = Fcons (concat2 (lib_base_name, XCAR (suffixes)), | 533 | { |
| 533 | *path_candidates); | 534 | Lisp_Object candidate1 = concat2 (lib_base_name, XCAR (suffixes)); |
| 535 | /* Support libraries named with ABI version numbers. In the | ||
| 536 | foreseeable future we only need to support version 0.0. See | ||
| 537 | the thread titled "Versioned Tree-sitter parser libraries" on | ||
| 538 | emacs-devel. */ | ||
| 539 | Lisp_Object candidate2 = concat2 (candidate1, Vtreesit_str_dot_0); | ||
| 540 | Lisp_Object candidate3 = concat2 (candidate2, Vtreesit_str_dot_0); | ||
| 541 | |||
| 542 | *path_candidates = Fcons (candidate3, *path_candidates); | ||
| 543 | *path_candidates = Fcons (candidate2, *path_candidates); | ||
| 544 | *path_candidates = Fcons (candidate1, *path_candidates); | ||
| 545 | } | ||
| 534 | } | 546 | } |
| 535 | 547 | ||
| 536 | /* Load the dynamic library of LANGUAGE_SYMBOL and return the pointer | 548 | /* 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. */); | |||
| 3583 | Vtreesit_str_libtree_sitter = build_pure_c_string ("libtree-sitter-"); | 3595 | Vtreesit_str_libtree_sitter = build_pure_c_string ("libtree-sitter-"); |
| 3584 | staticpro (&Vtreesit_str_tree_sitter); | 3596 | staticpro (&Vtreesit_str_tree_sitter); |
| 3585 | Vtreesit_str_tree_sitter = build_pure_c_string ("tree-sitter-"); | 3597 | Vtreesit_str_tree_sitter = build_pure_c_string ("tree-sitter-"); |
| 3598 | staticpro (&Vtreesit_str_dot_0); | ||
| 3599 | Vtreesit_str_dot_0 = build_pure_c_string (".0"); | ||
| 3586 | staticpro (&Vtreesit_str_dot); | 3600 | staticpro (&Vtreesit_str_dot); |
| 3587 | Vtreesit_str_dot = build_pure_c_string ("."); | 3601 | Vtreesit_str_dot = build_pure_c_string ("."); |
| 3588 | staticpro (&Vtreesit_str_question_mark); | 3602 | staticpro (&Vtreesit_str_question_mark); |